Index: trunk/phase3/tests/phpunit/includes/api/ApiPurgeTest.php |
— | — | @@ -9,33 +9,25 @@ |
10 | 10 | parent::setUp(); |
11 | 11 | $this->doLogin(); |
12 | 12 | } |
13 | | - |
| 13 | + |
14 | 14 | function testPurgeMainPage() { |
15 | | - |
16 | 15 | if ( !Title::newFromText( 'UTPage' )->exists() ) { |
17 | 16 | $this->markTestIncomplete( "The article [[UTPage]] does not exist" ); |
18 | 17 | } |
19 | | - |
| 18 | + |
20 | 19 | $somePage = mt_rand(); |
21 | 20 | |
22 | 21 | $data = $this->doApiRequest( array( |
23 | 22 | 'action' => 'purge', |
24 | 23 | 'titles' => 'UTPage|' . $somePage . '|%5D' ) ); |
25 | | - |
| 24 | + |
26 | 25 | $this->assertArrayHasKey( 'purge', $data[0] ); |
27 | | - |
28 | | - $this->assertArrayHasKey( 0, $data[0]['purge'] ); |
29 | | - $this->assertArrayHasKey( 'purged', $data[0]['purge'][0] ); |
30 | | - $this->assertEquals( 'UTPage', $data[0]['purge'][0]['title'] ); |
31 | | - |
32 | | - $this->assertArrayHasKey( 1, $data[0]['purge'] ); |
33 | | - $this->assertArrayHasKey( 'missing', $data[0]['purge'][1] ); |
34 | | - $this->assertEquals( $somePage, $data[0]['purge'][1]['title'] ); |
35 | | - |
36 | | - $this->assertArrayHasKey( 2, $data[0]['purge'] ); |
37 | | - $this->assertArrayHasKey( 'invalid', $data[0]['purge'][2] ); |
38 | | - $this->assertEquals( '%5D', $data[0]['purge'][2]['title'] ); |
39 | | - |
| 26 | + $this->assertEquals( 3, count( $data[0]['purge'] ) ); |
| 27 | + |
| 28 | + $pages = array( 'UTPage' => 'purged', $somePage => 'missing', '%5D' => 'invalid' ); |
| 29 | + foreach( $data[0]['purge'] as $v ) { |
| 30 | + $this->assertArrayHasKey( $pages[$v['title']], $v ); |
| 31 | + } |
40 | 32 | } |
41 | 33 | |
42 | 34 | } |