Revert "merged master"
[lhc/web/wiklou.git] / tests / phpunit / includes / api / ApiEditPageTest.php
1 <?php
2
3 /**
4 * @group Editing
5 * @group API
6 * @group Database
7 */
8 class ApiEditPageTest extends ApiTestCase {
9
10 function setUp() {
11 parent::setUp();
12 $this->doLogin();
13 }
14
15 function getTokens() {
16 return $this->getTokenList( self::$users['sysop'] );
17 }
18
19 function testEdit() {
20 $name = 'ApiEditPageTest_testEdit';
21
22 $tokenData = $this->getTokens();
23
24 if( !isset( $tokenData[0]['query']['pages'] ) ) {
25 $this->markTestIncomplete( "No edit token found" );
26 }
27
28 $keys = array_keys( $tokenData[0]['query']['pages'] );
29 $key = array_pop( $keys );
30 $pageinfo = $tokenData[0]['query']['pages'][$key];
31 $session = $tokenData[2];
32
33 // -----------------------------------------------------------------------
34
35 $data = $this->doApiRequest( array(
36 'action' => 'edit',
37 'title' => $name,
38 'text' => 'some text',
39 'token' => $pageinfo['edittoken'] ),
40 $session,
41 false,
42 self::$users['sysop']->user );
43
44 $this->assertArrayHasKey( 'edit', $data[0] );
45 $this->assertArrayHasKey( 'result', $data[0]['edit'] );
46 $this->assertEquals( 'Success', $data[0]['edit']['result'] );
47
48 $this->assertArrayHasKey( 'new', $data[0]['edit'] );
49 $this->assertArrayNotHasKey( 'nochange', $data[0]['edit'] );
50
51 $this->assertArrayHasKey( 'pageid', $data[0]['edit'] );
52 $this->assertArrayHasKey( 'contentmodel', $data[0]['edit'] );
53 $this->assertEquals( CONTENT_MODEL_WIKITEXT, $data[0]['edit']['contentmodel'] );
54
55 // -----------------------------------------------------------------------
56 $data = $this->doApiRequest( array(
57 'action' => 'edit',
58 'title' => $name,
59 'text' => 'some text',
60 'token' => $pageinfo['edittoken'] ),
61 $session,
62 false,
63 self::$users['sysop']->user );
64
65 $this->assertEquals( 'Success', $data[0]['edit']['result'] );
66
67 $this->assertArrayNotHasKey( 'new', $data[0]['edit'] );
68 $this->assertArrayHasKey( 'nochange', $data[0]['edit'] );
69
70 // -----------------------------------------------------------------------
71 $data = $this->doApiRequest( array(
72 'action' => 'edit',
73 'title' => $name,
74 'text' => 'different text',
75 'token' => $pageinfo['edittoken'] ),
76 $session,
77 false,
78 self::$users['sysop']->user );
79
80 $this->assertEquals( 'Success', $data[0]['edit']['result'] );
81
82 $this->assertArrayNotHasKey( 'new', $data[0]['edit'] );
83 $this->assertArrayNotHasKey( 'nochange', $data[0]['edit'] );
84
85 $this->assertArrayHasKey( 'oldrevid', $data[0]['edit'] );
86 $this->assertArrayHasKey( 'newrevid', $data[0]['edit'] );
87 $this->assertTrue( $data[0]['edit']['newrevid'] !== $data[0]['edit']['oldrevid'], "revision id should change after edit" );
88 }
89
90 function testEditAppend() {
91 $this->markTestIncomplete( "not yet implemented" );
92 }
93
94 function testEditSection() {
95 $this->markTestIncomplete( "not yet implemented" );
96 }
97
98 function testUndo() {
99 $this->markTestIncomplete( "not yet implemented" );
100 }
101
102 function testEditNonText() {
103 $this->markTestIncomplete( "not yet implemented" );
104 }
105 }