5297d6daa73b5cbc473a8c645fbfa58c50bd9430
[lhc/web/wiklou.git] / tests / phpunit / includes / api / ApiEditPageTest.php
1 <?php
2
3 /**
4 * Tests for MediaWiki api.php?action=edit.
5 *
6 * @author Daniel Kinzler
7 *
8 * @group API
9 * @group Database
10 */
11 class ApiEditPageTest extends ApiTestCase {
12
13 function setUp() {
14 parent::setUp();
15 $this->doLogin();
16 }
17
18 function testEdit( ) {
19 $name = 'ApiEditPageTest_testEdit';
20
21 // -- test new page --------------------------------------------
22 $apiResult = $this->doApiRequestWithToken( array(
23 'action' => 'edit',
24 'title' => $name,
25 'text' => 'some text', ) );
26 $apiResult = $apiResult[0];
27
28 # Validate API result data
29 $this->assertArrayHasKey( 'edit', $apiResult );
30 $this->assertArrayHasKey( 'result', $apiResult['edit'] );
31 $this->assertEquals( 'Success', $apiResult['edit']['result'] );
32
33 $this->assertArrayHasKey( 'new', $apiResult['edit'] );
34 $this->assertArrayNotHasKey( 'nochange', $apiResult['edit'] );
35
36 $this->assertArrayHasKey( 'pageid', $apiResult['edit'] );
37
38 // -- test existing page, no change ----------------------------
39 $data = $this->doApiRequestWithToken( array(
40 'action' => 'edit',
41 'title' => $name,
42 'text' => 'some text', ) );
43
44 $this->assertEquals( 'Success', $data[0]['edit']['result'] );
45
46 $this->assertArrayNotHasKey( 'new', $data[0]['edit'] );
47 $this->assertArrayHasKey( 'nochange', $data[0]['edit'] );
48
49 // -- test existing page, with change --------------------------
50 $data = $this->doApiRequestWithToken( array(
51 'action' => 'edit',
52 'title' => $name,
53 'text' => 'different text' ) );
54
55 $this->assertEquals( 'Success', $data[0]['edit']['result'] );
56
57 $this->assertArrayNotHasKey( 'new', $data[0]['edit'] );
58 $this->assertArrayNotHasKey( 'nochange', $data[0]['edit'] );
59
60 $this->assertArrayHasKey( 'oldrevid', $data[0]['edit'] );
61 $this->assertArrayHasKey( 'newrevid', $data[0]['edit'] );
62 $this->assertNotEquals(
63 $data[0]['edit']['newrevid'],
64 $data[0]['edit']['oldrevid'],
65 "revision id should change after edit"
66 );
67 }
68
69 function testEditAppend() {
70 $this->markTestIncomplete( "not yet implemented" );
71 }
72
73 function testEditSection() {
74 $this->markTestIncomplete( "not yet implemented" );
75 }
76
77 function testUndo() {
78 $this->markTestIncomplete( "not yet implemented" );
79 }
80
81 function testEditNonText() {
82 $this->markTestIncomplete( "not yet implemented" );
83 }
84 }