2de8efd45ed5bb1b3cc54453ad2e02646ad6af1b
8 class ApiEditPageTest
extends ApiTestCase
{
15 function getTokens() {
16 return $this->getTokenList( self
::$users['sysop'] );
20 $name = 'ApiEditPageTest_testEdit';
22 $tokenData = $this->getTokens();
24 if( !isset( $tokenData[0]['query']['pages'] ) ) {
25 $this->markTestIncomplete( "No edit token found" );
28 $keys = array_keys( $tokenData[0]['query']['pages'] );
29 $key = array_pop( $keys );
30 $pageinfo = $tokenData[0]['query']['pages'][$key];
31 $session = $tokenData[2];
33 // -----------------------------------------------------------------------
35 $data = $this->doApiRequest( array(
38 'text' => 'some text',
39 'token' => $pageinfo['edittoken'] ),
42 self
::$users['sysop']->user
);
44 $this->assertArrayHasKey( 'edit', $data[0] );
45 $this->assertArrayHasKey( 'result', $data[0]['edit'] );
46 $this->assertEquals( 'Success', $data[0]['edit']['result'] );
48 $this->assertArrayHasKey( 'new', $data[0]['edit'] );
49 $this->assertArrayNotHasKey( 'nochange', $data[0]['edit'] );
51 $this->assertArrayHasKey( 'pageid', $data[0]['edit'] );
52 $this->assertArrayHasKey( 'contentmodel', $data[0]['edit'] );
53 $this->assertEquals( CONTENT_MODEL_WIKITEXT
, $data[0]['edit']['contentmodel'] );
55 // -----------------------------------------------------------------------
56 $data = $this->doApiRequest( array(
59 'text' => 'some text',
60 'token' => $pageinfo['edittoken'] ),
63 self
::$users['sysop']->user
);
65 $this->assertEquals( 'Success', $data[0]['edit']['result'] );
67 $this->assertArrayNotHasKey( 'new', $data[0]['edit'] );
68 $this->assertArrayHasKey( 'nochange', $data[0]['edit'] );
70 // -----------------------------------------------------------------------
71 $data = $this->doApiRequest( array(
74 'text' => 'different text',
75 'token' => $pageinfo['edittoken'] ),
78 self
::$users['sysop']->user
);
80 $this->assertEquals( 'Success', $data[0]['edit']['result'] );
82 $this->assertArrayNotHasKey( 'new', $data[0]['edit'] );
83 $this->assertArrayNotHasKey( 'nochange', $data[0]['edit'] );
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" );
90 function testEditAppend() {
91 $this->markTestIncomplete( "not yet implemented" );
94 function testEditSection() {
95 $this->markTestIncomplete( "not yet implemented" );
99 $this->markTestIncomplete( "not yet implemented" );
102 function testEditNonText() {
103 $this->markTestIncomplete( "not yet implemented" );