MediaWiki  1.23.12
ApiQueryContinueTest.php
Go to the documentation of this file.
1 <?php
21 require_once 'ApiQueryContinueTestBase.php';
22 
35 
40  function addDBData() {
41  try {
42  $this->editPage( 'Template:AQCT-T1', '**Template:AQCT-T1**' );
43  $this->editPage( 'Template:AQCT-T2', '**Template:AQCT-T2**' );
44  $this->editPage( 'Template:AQCT-T3', '**Template:AQCT-T3**' );
45  $this->editPage( 'Template:AQCT-T4', '**Template:AQCT-T4**' );
46  $this->editPage( 'Template:AQCT-T5', '**Template:AQCT-T5**' );
47 
48  $this->editPage( 'AQCT-1', '**AQCT-1** {{AQCT-T2}} {{AQCT-T3}} {{AQCT-T4}} {{AQCT-T5}}' );
49  $this->editPage( 'AQCT-2', '[[AQCT-1]] **AQCT-2** {{AQCT-T3}} {{AQCT-T4}} {{AQCT-T5}}' );
50  $this->editPage( 'AQCT-3', '[[AQCT-1]] [[AQCT-2]] **AQCT-3** {{AQCT-T4}} {{AQCT-T5}}' );
51  $this->editPage( 'AQCT-4', '[[AQCT-1]] [[AQCT-2]] [[AQCT-3]] **AQCT-4** {{AQCT-T5}}' );
52  $this->editPage( 'AQCT-5', '[[AQCT-1]] [[AQCT-2]] [[AQCT-3]] [[AQCT-4]] **AQCT-5**' );
53  } catch ( Exception $e ) {
54  $this->exceptionFromAddDBData = $e;
55  }
56  }
57 
62  public function test1List() {
63  $this->mVerbose = false;
64  $mk = function ( $l ) {
65  return array(
66  'list' => 'allpages',
67  'apprefix' => 'AQCT-',
68  'aplimit' => "$l",
69  );
70  };
71  $data = $this->query( $mk( 99 ), 1, '1L', false );
72 
73  // 1 list
74  $this->checkC( $data, $mk( 1 ), 5, '1L-1' );
75  $this->checkC( $data, $mk( 2 ), 3, '1L-2' );
76  $this->checkC( $data, $mk( 3 ), 2, '1L-3' );
77  $this->checkC( $data, $mk( 4 ), 2, '1L-4' );
78  $this->checkC( $data, $mk( 5 ), 1, '1L-5' );
79  }
80 
85  public function test2Lists() {
86  $this->mVerbose = false;
87  $mk = function ( $l1, $l2 ) {
88  return array(
89  'list' => 'allpages|alltransclusions',
90  'apprefix' => 'AQCT-',
91  'atprefix' => 'AQCT-',
92  'atunique' => '',
93  'aplimit' => "$l1",
94  'atlimit' => "$l2",
95  );
96  };
97  // 2 lists
98  $data = $this->query( $mk( 99, 99 ), 1, '2L', false );
99  $this->checkC( $data, $mk( 1, 1 ), 5, '2L-11' );
100  $this->checkC( $data, $mk( 2, 2 ), 3, '2L-22' );
101  $this->checkC( $data, $mk( 3, 3 ), 2, '2L-33' );
102  $this->checkC( $data, $mk( 4, 4 ), 2, '2L-44' );
103  $this->checkC( $data, $mk( 5, 5 ), 1, '2L-55' );
104  }
105 
110  public function testGen1Prop() {
111  $this->mVerbose = false;
112  $mk = function ( $g, $p ) {
113  return array(
114  'generator' => 'allpages',
115  'gapprefix' => 'AQCT-',
116  'gaplimit' => "$g",
117  'prop' => 'links',
118  'pllimit' => "$p",
119  );
120  };
121  // generator + 1 prop
122  $data = $this->query( $mk( 99, 99 ), 1, 'G1P', false );
123  $this->checkC( $data, $mk( 1, 1 ), 11, 'G1P-11' );
124  $this->checkC( $data, $mk( 2, 2 ), 6, 'G1P-22' );
125  $this->checkC( $data, $mk( 3, 3 ), 4, 'G1P-33' );
126  $this->checkC( $data, $mk( 4, 4 ), 3, 'G1P-44' );
127  $this->checkC( $data, $mk( 5, 5 ), 2, 'G1P-55' );
128  }
129 
134  public function testGen2Prop() {
135  $this->mVerbose = false;
136  $mk = function ( $g, $p1, $p2 ) {
137  return array(
138  'generator' => 'allpages',
139  'gapprefix' => 'AQCT-',
140  'gaplimit' => "$g",
141  'prop' => 'links|templates',
142  'pllimit' => "$p1",
143  'tllimit' => "$p2",
144  );
145  };
146  // generator + 2 props
147  $data = $this->query( $mk( 99, 99, 99 ), 1, 'G2P', false );
148  $this->checkC( $data, $mk( 1, 1, 1 ), 16, 'G2P-111' );
149  $this->checkC( $data, $mk( 2, 2, 2 ), 9, 'G2P-222' );
150  $this->checkC( $data, $mk( 3, 3, 3 ), 6, 'G2P-333' );
151  $this->checkC( $data, $mk( 4, 4, 4 ), 4, 'G2P-444' );
152  $this->checkC( $data, $mk( 5, 5, 5 ), 2, 'G2P-555' );
153  $this->checkC( $data, $mk( 5, 1, 1 ), 10, 'G2P-511' );
154  $this->checkC( $data, $mk( 4, 2, 2 ), 7, 'G2P-422' );
155  $this->checkC( $data, $mk( 2, 3, 3 ), 7, 'G2P-233' );
156  $this->checkC( $data, $mk( 2, 4, 4 ), 5, 'G2P-244' );
157  $this->checkC( $data, $mk( 1, 5, 5 ), 5, 'G2P-155' );
158  }
159 
164  public function testGen1Prop1List() {
165  $this->mVerbose = false;
166  $mk = function ( $g, $p, $l ) {
167  return array(
168  'generator' => 'allpages',
169  'gapprefix' => 'AQCT-',
170  'gaplimit' => "$g",
171  'prop' => 'links',
172  'pllimit' => "$p",
173  'list' => 'alltransclusions',
174  'atprefix' => 'AQCT-',
175  'atunique' => '',
176  'atlimit' => "$l",
177  );
178  };
179  // generator + 1 prop + 1 list
180  $data = $this->query( $mk( 99, 99, 99 ), 1, 'G1P1L', false );
181  $this->checkC( $data, $mk( 1, 1, 1 ), 11, 'G1P1L-111' );
182  $this->checkC( $data, $mk( 2, 2, 2 ), 6, 'G1P1L-222' );
183  $this->checkC( $data, $mk( 3, 3, 3 ), 4, 'G1P1L-333' );
184  $this->checkC( $data, $mk( 4, 4, 4 ), 3, 'G1P1L-444' );
185  $this->checkC( $data, $mk( 5, 5, 5 ), 2, 'G1P1L-555' );
186  $this->checkC( $data, $mk( 5, 5, 1 ), 4, 'G1P1L-551' );
187  $this->checkC( $data, $mk( 5, 5, 2 ), 2, 'G1P1L-552' );
188  }
189 
195  public function testGen2Prop2List1Meta() {
196  $this->mVerbose = false;
197  $mk = function ( $g, $p1, $p2, $l1, $l2 ) {
198  return array(
199  'generator' => 'allpages',
200  'gapprefix' => 'AQCT-',
201  'gaplimit' => "$g",
202  'prop' => 'links|templates',
203  'pllimit' => "$p1",
204  'tllimit' => "$p2",
205  'list' => 'alllinks|alltransclusions',
206  'alprefix' => 'AQCT-',
207  'alunique' => '',
208  'allimit' => "$l1",
209  'atprefix' => 'AQCT-',
210  'atunique' => '',
211  'atlimit' => "$l2",
212  'meta' => 'siteinfo',
213  'siprop' => 'namespaces',
214  );
215  };
216  // generator + 1 prop + 1 list
217  $data = $this->query( $mk( 99, 99, 99, 99, 99 ), 1, 'G2P2L1M', false );
218  $this->checkC( $data, $mk( 1, 1, 1, 1, 1 ), 16, 'G2P2L1M-11111' );
219  $this->checkC( $data, $mk( 2, 2, 2, 2, 2 ), 9, 'G2P2L1M-22222' );
220  $this->checkC( $data, $mk( 3, 3, 3, 3, 3 ), 6, 'G2P2L1M-33333' );
221  $this->checkC( $data, $mk( 4, 4, 4, 4, 4 ), 4, 'G2P2L1M-44444' );
222  $this->checkC( $data, $mk( 5, 5, 5, 5, 5 ), 2, 'G2P2L1M-55555' );
223  $this->checkC( $data, $mk( 5, 5, 5, 1, 1 ), 4, 'G2P2L1M-55511' );
224  $this->checkC( $data, $mk( 5, 5, 5, 2, 2 ), 2, 'G2P2L1M-55522' );
225  $this->checkC( $data, $mk( 5, 1, 1, 5, 5 ), 10, 'G2P2L1M-51155' );
226  $this->checkC( $data, $mk( 5, 2, 2, 5, 5 ), 5, 'G2P2L1M-52255' );
227  }
228 
233  public function testSameGenAndProp() {
234  $this->mVerbose = false;
235  $mk = function ( $g, $gDir, $p, $pDir ) {
236  return array(
237  'titles' => 'AQCT-1',
238  'generator' => 'templates',
239  'gtllimit' => "$g",
240  'gtldir' => $gDir ? 'ascending' : 'descending',
241  'prop' => 'templates',
242  'tllimit' => "$p",
243  'tldir' => $pDir ? 'ascending' : 'descending',
244  );
245  };
246  // generator + 1 prop
247  $data = $this->query( $mk( 99, true, 99, true ), 1, 'G=P', false );
248 
249  $this->checkC( $data, $mk( 1, true, 1, true ), 4, 'G=P-1t1t' );
250  $this->checkC( $data, $mk( 2, true, 2, true ), 2, 'G=P-2t2t' );
251  $this->checkC( $data, $mk( 3, true, 3, true ), 2, 'G=P-3t3t' );
252  $this->checkC( $data, $mk( 1, true, 3, true ), 4, 'G=P-1t3t' );
253  $this->checkC( $data, $mk( 3, true, 1, true ), 2, 'G=P-3t1t' );
254 
255  $this->checkC( $data, $mk( 1, true, 1, false ), 4, 'G=P-1t1f' );
256  $this->checkC( $data, $mk( 2, true, 2, false ), 2, 'G=P-2t2f' );
257  $this->checkC( $data, $mk( 3, true, 3, false ), 2, 'G=P-3t3f' );
258  $this->checkC( $data, $mk( 1, true, 3, false ), 4, 'G=P-1t3f' );
259  $this->checkC( $data, $mk( 3, true, 1, false ), 2, 'G=P-3t1f' );
260 
261  $this->checkC( $data, $mk( 1, false, 1, true ), 4, 'G=P-1f1t' );
262  $this->checkC( $data, $mk( 2, false, 2, true ), 2, 'G=P-2f2t' );
263  $this->checkC( $data, $mk( 3, false, 3, true ), 2, 'G=P-3f3t' );
264  $this->checkC( $data, $mk( 1, false, 3, true ), 4, 'G=P-1f3t' );
265  $this->checkC( $data, $mk( 3, false, 1, true ), 2, 'G=P-3f1t' );
266 
267  $this->checkC( $data, $mk( 1, false, 1, false ), 4, 'G=P-1f1f' );
268  $this->checkC( $data, $mk( 2, false, 2, false ), 2, 'G=P-2f2f' );
269  $this->checkC( $data, $mk( 3, false, 3, false ), 2, 'G=P-3f3f' );
270  $this->checkC( $data, $mk( 1, false, 3, false ), 4, 'G=P-1f3f' );
271  $this->checkC( $data, $mk( 3, false, 1, false ), 2, 'G=P-3f1f' );
272  }
273 
278  public function testSameGenList() {
279  $this->mVerbose = false;
280  $mk = function ( $g, $gDir, $l, $pDir ) {
281  return array(
282  'generator' => 'allpages',
283  'gapprefix' => 'AQCT-',
284  'gaplimit' => "$g",
285  'gapdir' => $gDir ? 'ascending' : 'descending',
286  'list' => 'allpages',
287  'apprefix' => 'AQCT-',
288  'aplimit' => "$l",
289  'apdir' => $pDir ? 'ascending' : 'descending',
290  );
291  };
292  // generator + 1 list
293  $data = $this->query( $mk( 99, true, 99, true ), 1, 'G=L', false );
294 
295  $this->checkC( $data, $mk( 1, true, 1, true ), 5, 'G=L-1t1t' );
296  $this->checkC( $data, $mk( 2, true, 2, true ), 3, 'G=L-2t2t' );
297  $this->checkC( $data, $mk( 3, true, 3, true ), 2, 'G=L-3t3t' );
298  $this->checkC( $data, $mk( 1, true, 3, true ), 5, 'G=L-1t3t' );
299  $this->checkC( $data, $mk( 3, true, 1, true ), 5, 'G=L-3t1t' );
300  $this->checkC( $data, $mk( 1, true, 1, false ), 5, 'G=L-1t1f' );
301  $this->checkC( $data, $mk( 2, true, 2, false ), 3, 'G=L-2t2f' );
302  $this->checkC( $data, $mk( 3, true, 3, false ), 2, 'G=L-3t3f' );
303  $this->checkC( $data, $mk( 1, true, 3, false ), 5, 'G=L-1t3f' );
304  $this->checkC( $data, $mk( 3, true, 1, false ), 5, 'G=L-3t1f' );
305  $this->checkC( $data, $mk( 1, false, 1, true ), 5, 'G=L-1f1t' );
306  $this->checkC( $data, $mk( 2, false, 2, true ), 3, 'G=L-2f2t' );
307  $this->checkC( $data, $mk( 3, false, 3, true ), 2, 'G=L-3f3t' );
308  $this->checkC( $data, $mk( 1, false, 3, true ), 5, 'G=L-1f3t' );
309  $this->checkC( $data, $mk( 3, false, 1, true ), 5, 'G=L-3f1t' );
310  $this->checkC( $data, $mk( 1, false, 1, false ), 5, 'G=L-1f1f' );
311  $this->checkC( $data, $mk( 2, false, 2, false ), 3, 'G=L-2f2f' );
312  $this->checkC( $data, $mk( 3, false, 3, false ), 2, 'G=L-3f3f' );
313  $this->checkC( $data, $mk( 1, false, 3, false ), 5, 'G=L-1f3f' );
314  $this->checkC( $data, $mk( 3, false, 1, false ), 5, 'G=L-3f1f' );
315  }
316 }
ApiQueryContinueTest\$exceptionFromAddDBData
$exceptionFromAddDBData
Definition: ApiQueryContinueTest.php:34
ApiQueryContinueTest\testSameGenList
testSameGenList()
Test smart continue - generator=allpages, list=allpages @medium.
Definition: ApiQueryContinueTest.php:278
php
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
Definition: skin.txt:62
ApiQueryContinueTest\testGen2Prop2List1Meta
testGen2Prop2List1Meta()
Test smart continue - generator=allpages, prop=links|templates, list=alllinks|alltransclusions,...
Definition: ApiQueryContinueTest.php:195
array
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
ApiQueryContinueTest\testSameGenAndProp
testSameGenAndProp()
Test smart continue - generator=templates, prop=templates @medium.
Definition: ApiQueryContinueTest.php:233
ApiQueryContinueTest\test1List
test1List()
Test smart continue - list=allpages @medium.
Definition: ApiQueryContinueTest.php:62
ApiQueryContinueTest\testGen1Prop1List
testGen1Prop1List()
Test smart continue - generator=allpages, prop=links, list=alltransclusions @medium.
Definition: ApiQueryContinueTest.php:164
ApiQueryContinueTestBase\checkC
checkC( $expected, $params, $expectedCount, $id, $continue=true)
Run query() and compare against expected values.
Definition: ApiQueryContinueTestBase.php:37
ApiTestCase\editPage
editPage( $pageName, $text, $summary='', $defaultNs=NS_MAIN)
Edits or creates a page/revision.
Definition: ApiTestCase.php:51
ApiQueryContinueTest\test2Lists
test2Lists()
Test smart continue - list=allpages|alltransclusions @medium.
Definition: ApiQueryContinueTest.php:85
ApiQueryContinueTest
Copyright © 2013 Yuri Astrakhan "<Firstname><Lastname>@gmail.com".
Definition: ApiQueryContinueTest.php:33
ApiQueryContinueTestBase
Definition: ApiQueryContinueTestBase.php:27
ApiQueryContinueTest\testGen1Prop
testGen1Prop()
Test smart continue - generator=allpages, prop=links @medium.
Definition: ApiQueryContinueTest.php:110
ApiQueryContinueTestBase\query
query( $params, $expectedCount, $id, $useContinue=true)
Run query in a loop until no more values are available.
Definition: ApiQueryContinueTestBase.php:51
ApiQueryContinueTest\testGen2Prop
testGen2Prop()
Test smart continue - generator=allpages, prop=links|templates @medium.
Definition: ApiQueryContinueTest.php:134
ApiQueryContinueTest\addDBData
addDBData()
Create a set of pages.
Definition: ApiQueryContinueTest.php:40
$e
div flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException' returning false will NOT prevent logging $e
Definition: hooks.txt:1632