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