MediaWiki
REL1_22
|
00001 <?php 00021 require_once 'ApiQueryContinueTestBase.php'; 00022 00032 class ApiQueryContinueTest extends ApiQueryContinueTestBase { 00037 function addDBData() { 00038 try { 00039 $this->editPage( 'Template:AQCT-T1', '**Template:AQCT-T1**' ); 00040 $this->editPage( 'Template:AQCT-T2', '**Template:AQCT-T2**' ); 00041 $this->editPage( 'Template:AQCT-T3', '**Template:AQCT-T3**' ); 00042 $this->editPage( 'Template:AQCT-T4', '**Template:AQCT-T4**' ); 00043 $this->editPage( 'Template:AQCT-T5', '**Template:AQCT-T5**' ); 00044 00045 $this->editPage( 'AQCT-1', '**AQCT-1** {{AQCT-T2}} {{AQCT-T3}} {{AQCT-T4}} {{AQCT-T5}}' ); 00046 $this->editPage( 'AQCT-2', '[[AQCT-1]] **AQCT-2** {{AQCT-T3}} {{AQCT-T4}} {{AQCT-T5}}' ); 00047 $this->editPage( 'AQCT-3', '[[AQCT-1]] [[AQCT-2]] **AQCT-3** {{AQCT-T4}} {{AQCT-T5}}' ); 00048 $this->editPage( 'AQCT-4', '[[AQCT-1]] [[AQCT-2]] [[AQCT-3]] **AQCT-4** {{AQCT-T5}}' ); 00049 $this->editPage( 'AQCT-5', '[[AQCT-1]] [[AQCT-2]] [[AQCT-3]] [[AQCT-4]] **AQCT-5**' ); 00050 } catch ( Exception $e ) { 00051 $this->exceptionFromAddDBData = $e; 00052 } 00053 } 00054 00059 public function test1List() { 00060 $this->mVerbose = false; 00061 $mk = function ( $l ) { 00062 return array( 00063 'list' => 'allpages', 00064 'apprefix' => 'AQCT-', 00065 'aplimit' => "$l", 00066 ); 00067 }; 00068 $data = $this->query( $mk( 99 ), 1, '1L', false ); 00069 00070 // 1 list 00071 $this->checkC( $data, $mk( 1 ), 5, '1L-1' ); 00072 $this->checkC( $data, $mk( 2 ), 3, '1L-2' ); 00073 $this->checkC( $data, $mk( 3 ), 2, '1L-3' ); 00074 $this->checkC( $data, $mk( 4 ), 2, '1L-4' ); 00075 $this->checkC( $data, $mk( 5 ), 1, '1L-5' ); 00076 } 00077 00082 public function test2Lists() { 00083 $this->mVerbose = false; 00084 $mk = function ( $l1, $l2 ) { 00085 return array( 00086 'list' => 'allpages|alltransclusions', 00087 'apprefix' => 'AQCT-', 00088 'atprefix' => 'AQCT-', 00089 'atunique' => '', 00090 'aplimit' => "$l1", 00091 'atlimit' => "$l2", 00092 ); 00093 }; 00094 // 2 lists 00095 $data = $this->query( $mk( 99, 99 ), 1, '2L', false ); 00096 $this->checkC( $data, $mk( 1, 1 ), 5, '2L-11' ); 00097 $this->checkC( $data, $mk( 2, 2 ), 3, '2L-22' ); 00098 $this->checkC( $data, $mk( 3, 3 ), 2, '2L-33' ); 00099 $this->checkC( $data, $mk( 4, 4 ), 2, '2L-44' ); 00100 $this->checkC( $data, $mk( 5, 5 ), 1, '2L-55' ); 00101 } 00102 00107 public function testGen1Prop() { 00108 $this->mVerbose = false; 00109 $mk = function ( $g, $p ) { 00110 return array( 00111 'generator' => 'allpages', 00112 'gapprefix' => 'AQCT-', 00113 'gaplimit' => "$g", 00114 'prop' => 'links', 00115 'pllimit' => "$p", 00116 ); 00117 }; 00118 // generator + 1 prop 00119 $data = $this->query( $mk( 99, 99 ), 1, 'G1P', false ); 00120 $this->checkC( $data, $mk( 1, 1 ), 11, 'G1P-11' ); 00121 $this->checkC( $data, $mk( 2, 2 ), 6, 'G1P-22' ); 00122 $this->checkC( $data, $mk( 3, 3 ), 4, 'G1P-33' ); 00123 $this->checkC( $data, $mk( 4, 4 ), 3, 'G1P-44' ); 00124 $this->checkC( $data, $mk( 5, 5 ), 2, 'G1P-55' ); 00125 } 00126 00131 public function testGen2Prop() { 00132 $this->mVerbose = false; 00133 $mk = function ( $g, $p1, $p2 ) { 00134 return array( 00135 'generator' => 'allpages', 00136 'gapprefix' => 'AQCT-', 00137 'gaplimit' => "$g", 00138 'prop' => 'links|templates', 00139 'pllimit' => "$p1", 00140 'tllimit' => "$p2", 00141 ); 00142 }; 00143 // generator + 2 props 00144 $data = $this->query( $mk( 99, 99, 99 ), 1, 'G2P', false ); 00145 $this->checkC( $data, $mk( 1, 1, 1 ), 16, 'G2P-111' ); 00146 $this->checkC( $data, $mk( 2, 2, 2 ), 9, 'G2P-222' ); 00147 $this->checkC( $data, $mk( 3, 3, 3 ), 6, 'G2P-333' ); 00148 $this->checkC( $data, $mk( 4, 4, 4 ), 4, 'G2P-444' ); 00149 $this->checkC( $data, $mk( 5, 5, 5 ), 2, 'G2P-555' ); 00150 $this->checkC( $data, $mk( 5, 1, 1 ), 10, 'G2P-511' ); 00151 $this->checkC( $data, $mk( 4, 2, 2 ), 7, 'G2P-422' ); 00152 $this->checkC( $data, $mk( 2, 3, 3 ), 7, 'G2P-233' ); 00153 $this->checkC( $data, $mk( 2, 4, 4 ), 5, 'G2P-244' ); 00154 $this->checkC( $data, $mk( 1, 5, 5 ), 5, 'G2P-155' ); 00155 } 00156 00161 public function testGen1Prop1List() { 00162 $this->mVerbose = false; 00163 $mk = function ( $g, $p, $l ) { 00164 return array( 00165 'generator' => 'allpages', 00166 'gapprefix' => 'AQCT-', 00167 'gaplimit' => "$g", 00168 'prop' => 'links', 00169 'pllimit' => "$p", 00170 'list' => 'alltransclusions', 00171 'atprefix' => 'AQCT-', 00172 'atunique' => '', 00173 'atlimit' => "$l", 00174 ); 00175 }; 00176 // generator + 1 prop + 1 list 00177 $data = $this->query( $mk( 99, 99, 99 ), 1, 'G1P1L', false ); 00178 $this->checkC( $data, $mk( 1, 1, 1 ), 11, 'G1P1L-111' ); 00179 $this->checkC( $data, $mk( 2, 2, 2 ), 6, 'G1P1L-222' ); 00180 $this->checkC( $data, $mk( 3, 3, 3 ), 4, 'G1P1L-333' ); 00181 $this->checkC( $data, $mk( 4, 4, 4 ), 3, 'G1P1L-444' ); 00182 $this->checkC( $data, $mk( 5, 5, 5 ), 2, 'G1P1L-555' ); 00183 $this->checkC( $data, $mk( 5, 5, 1 ), 4, 'G1P1L-551' ); 00184 $this->checkC( $data, $mk( 5, 5, 2 ), 2, 'G1P1L-552' ); 00185 } 00186 00192 public function testGen2Prop2List1Meta() { 00193 $this->mVerbose = false; 00194 $mk = function ( $g, $p1, $p2, $l1, $l2 ) { 00195 return array( 00196 'generator' => 'allpages', 00197 'gapprefix' => 'AQCT-', 00198 'gaplimit' => "$g", 00199 'prop' => 'links|templates', 00200 'pllimit' => "$p1", 00201 'tllimit' => "$p2", 00202 'list' => 'alllinks|alltransclusions', 00203 'alprefix' => 'AQCT-', 00204 'alunique' => '', 00205 'allimit' => "$l1", 00206 'atprefix' => 'AQCT-', 00207 'atunique' => '', 00208 'atlimit' => "$l2", 00209 'meta' => 'siteinfo', 00210 'siprop' => 'namespaces', 00211 ); 00212 }; 00213 // generator + 1 prop + 1 list 00214 $data = $this->query( $mk( 99, 99, 99, 99, 99 ), 1, 'G2P2L1M', false ); 00215 $this->checkC( $data, $mk( 1, 1, 1, 1, 1 ), 16, 'G2P2L1M-11111' ); 00216 $this->checkC( $data, $mk( 2, 2, 2, 2, 2 ), 9, 'G2P2L1M-22222' ); 00217 $this->checkC( $data, $mk( 3, 3, 3, 3, 3 ), 6, 'G2P2L1M-33333' ); 00218 $this->checkC( $data, $mk( 4, 4, 4, 4, 4 ), 4, 'G2P2L1M-44444' ); 00219 $this->checkC( $data, $mk( 5, 5, 5, 5, 5 ), 2, 'G2P2L1M-55555' ); 00220 $this->checkC( $data, $mk( 5, 5, 5, 1, 1 ), 4, 'G2P2L1M-55511' ); 00221 $this->checkC( $data, $mk( 5, 5, 5, 2, 2 ), 2, 'G2P2L1M-55522' ); 00222 $this->checkC( $data, $mk( 5, 1, 1, 5, 5 ), 10, 'G2P2L1M-51155' ); 00223 $this->checkC( $data, $mk( 5, 2, 2, 5, 5 ), 5, 'G2P2L1M-52255' ); 00224 } 00225 00230 public function testSameGenAndProp() { 00231 $this->mVerbose = false; 00232 $mk = function ( $g, $gDir, $p, $pDir ) { 00233 return array( 00234 'titles' => 'AQCT-1', 00235 'generator' => 'templates', 00236 'gtllimit' => "$g", 00237 'gtldir' => $gDir ? 'ascending' : 'descending', 00238 'prop' => 'templates', 00239 'tllimit' => "$p", 00240 'tldir' => $pDir ? 'ascending' : 'descending', 00241 ); 00242 }; 00243 // generator + 1 prop 00244 $data = $this->query( $mk( 99, true, 99, true ), 1, 'G=P', false ); 00245 00246 $this->checkC( $data, $mk( 1, true, 1, true ), 4, 'G=P-1t1t' ); 00247 $this->checkC( $data, $mk( 2, true, 2, true ), 2, 'G=P-2t2t' ); 00248 $this->checkC( $data, $mk( 3, true, 3, true ), 2, 'G=P-3t3t' ); 00249 $this->checkC( $data, $mk( 1, true, 3, true ), 4, 'G=P-1t3t' ); 00250 $this->checkC( $data, $mk( 3, true, 1, true ), 2, 'G=P-3t1t' ); 00251 00252 $this->checkC( $data, $mk( 1, true, 1, false ), 4, 'G=P-1t1f' ); 00253 $this->checkC( $data, $mk( 2, true, 2, false ), 2, 'G=P-2t2f' ); 00254 $this->checkC( $data, $mk( 3, true, 3, false ), 2, 'G=P-3t3f' ); 00255 $this->checkC( $data, $mk( 1, true, 3, false ), 4, 'G=P-1t3f' ); 00256 $this->checkC( $data, $mk( 3, true, 1, false ), 2, 'G=P-3t1f' ); 00257 00258 $this->checkC( $data, $mk( 1, false, 1, true ), 4, 'G=P-1f1t' ); 00259 $this->checkC( $data, $mk( 2, false, 2, true ), 2, 'G=P-2f2t' ); 00260 $this->checkC( $data, $mk( 3, false, 3, true ), 2, 'G=P-3f3t' ); 00261 $this->checkC( $data, $mk( 1, false, 3, true ), 4, 'G=P-1f3t' ); 00262 $this->checkC( $data, $mk( 3, false, 1, true ), 2, 'G=P-3f1t' ); 00263 00264 $this->checkC( $data, $mk( 1, false, 1, false ), 4, 'G=P-1f1f' ); 00265 $this->checkC( $data, $mk( 2, false, 2, false ), 2, 'G=P-2f2f' ); 00266 $this->checkC( $data, $mk( 3, false, 3, false ), 2, 'G=P-3f3f' ); 00267 $this->checkC( $data, $mk( 1, false, 3, false ), 4, 'G=P-1f3f' ); 00268 $this->checkC( $data, $mk( 3, false, 1, false ), 2, 'G=P-3f1f' ); 00269 } 00270 00275 public function testSameGenList() { 00276 $this->mVerbose = false; 00277 $mk = function ( $g, $gDir, $l, $pDir ) { 00278 return array( 00279 'generator' => 'allpages', 00280 'gapprefix' => 'AQCT-', 00281 'gaplimit' => "$g", 00282 'gapdir' => $gDir ? 'ascending' : 'descending', 00283 'list' => 'allpages', 00284 'apprefix' => 'AQCT-', 00285 'aplimit' => "$l", 00286 'apdir' => $pDir ? 'ascending' : 'descending', 00287 ); 00288 }; 00289 // generator + 1 list 00290 $data = $this->query( $mk( 99, true, 99, true ), 1, 'G=L', false ); 00291 00292 $this->checkC( $data, $mk( 1, true, 1, true ), 5, 'G=L-1t1t' ); 00293 $this->checkC( $data, $mk( 2, true, 2, true ), 3, 'G=L-2t2t' ); 00294 $this->checkC( $data, $mk( 3, true, 3, true ), 2, 'G=L-3t3t' ); 00295 $this->checkC( $data, $mk( 1, true, 3, true ), 5, 'G=L-1t3t' ); 00296 $this->checkC( $data, $mk( 3, true, 1, true ), 5, 'G=L-3t1t' ); 00297 $this->checkC( $data, $mk( 1, true, 1, false ), 5, 'G=L-1t1f' ); 00298 $this->checkC( $data, $mk( 2, true, 2, false ), 3, 'G=L-2t2f' ); 00299 $this->checkC( $data, $mk( 3, true, 3, false ), 2, 'G=L-3t3f' ); 00300 $this->checkC( $data, $mk( 1, true, 3, false ), 5, 'G=L-1t3f' ); 00301 $this->checkC( $data, $mk( 3, true, 1, false ), 5, 'G=L-3t1f' ); 00302 $this->checkC( $data, $mk( 1, false, 1, true ), 5, 'G=L-1f1t' ); 00303 $this->checkC( $data, $mk( 2, false, 2, true ), 3, 'G=L-2f2t' ); 00304 $this->checkC( $data, $mk( 3, false, 3, true ), 2, 'G=L-3f3t' ); 00305 $this->checkC( $data, $mk( 1, false, 3, true ), 5, 'G=L-1f3t' ); 00306 $this->checkC( $data, $mk( 3, false, 1, true ), 5, 'G=L-3f1t' ); 00307 $this->checkC( $data, $mk( 1, false, 1, false ), 5, 'G=L-1f1f' ); 00308 $this->checkC( $data, $mk( 2, false, 2, false ), 3, 'G=L-2f2f' ); 00309 $this->checkC( $data, $mk( 3, false, 3, false ), 2, 'G=L-3f3f' ); 00310 $this->checkC( $data, $mk( 1, false, 3, false ), 5, 'G=L-1f3f' ); 00311 $this->checkC( $data, $mk( 3, false, 1, false ), 5, 'G=L-3f1f' ); 00312 } 00313 }