Refactor ApiTestCase to get token from ApiQueryTokens
[lhc/web/wiklou.git] / tests / phpunit / includes / api / ApiPurgeTest.php
1 <?php
2
3 /**
4 * @group API
5 * @group Database
6 * @group medium
7 *
8 * @covers ApiPurge
9 */
10 class ApiPurgeTest extends ApiTestCase {
11
12 protected function setUp() {
13 parent::setUp();
14 $this->doLogin();
15 }
16
17 /**
18 * @group Broken
19 */
20 public function testPurgeMainPage() {
21 if ( !Title::newFromText( 'UTPage' )->exists() ) {
22 $this->markTestIncomplete( "The article [[UTPage]] does not exist" );
23 }
24
25 $somePage = mt_rand();
26
27 $data = $this->doApiRequest( [
28 'action' => 'purge',
29 'titles' => 'UTPage|' . $somePage . '|%5D' ] );
30
31 $this->assertArrayHasKey( 'purge', $data[0],
32 "Must receive a 'purge' result from API" );
33
34 $this->assertEquals(
35 3,
36 count( $data[0]['purge'] ),
37 "Purge request for three articles should give back three results received: "
38 . var_export( $data[0]['purge'], true ) );
39
40 $pages = [ 'UTPage' => 'purged', $somePage => 'missing', '%5D' => 'invalid' ];
41 foreach ( $data[0]['purge'] as $v ) {
42 $this->assertArrayHasKey( $pages[$v['title']], $v );
43 }
44 }
45 }