3ed983b01adf89e1be1dd1fbf2e6e63f0a49be35
7 class ApiEditPageTest
extends ApiTestCase
{
14 function getTokens() {
15 return $this->getTokenList( self
::$users['sysop'] );
19 $name = 'ApiEditPageTest_testEdit';
21 $tokenData = $this->getTokens();
23 if( !isset( $tokenData[0]['query']['pages'] ) ) {
24 $this->markTestIncomplete( "No edit token found" );
27 $keys = array_keys( $tokenData[0]['query']['pages'] );
28 $key = array_pop( $keys );
29 $pageinfo = $tokenData[0]['query']['pages'][$key];
30 $session = $tokenData[2];
32 // -----------------------------------------------------------------------
34 $data = $this->doApiRequest( array(
37 'text' => 'some text',
38 'token' => $pageinfo['edittoken'] ),
41 self
::$users['sysop']->user
);
43 $this->assertArrayHasKey( 'edit', $data[0] );
44 $this->assertArrayHasKey( 'result', $data[0]['edit'] );
45 $this->assertEquals( 'Success', $data[0]['edit']['result'] );
47 $this->assertArrayHasKey( 'new', $data[0]['edit'] );
48 $this->assertArrayNotHasKey( 'nochange', $data[0]['edit'] );
50 $this->assertArrayHasKey( 'pageid', $data[0]['edit'] );
51 $this->assertArrayHasKey( 'contentmodel', $data[0]['edit'] );
52 $this->assertEquals( CONTENT_MODEL_WIKITEXT
, $data[0]['edit']['contentmodel'] );
54 // -----------------------------------------------------------------------
55 $data = $this->doApiRequest( array(
58 'text' => 'some text',
59 'token' => $pageinfo['edittoken'] ),
62 self
::$users['sysop']->user
);
64 $this->assertEquals( 'Success', $data[0]['edit']['result'] );
66 $this->assertArrayNotHasKey( 'new', $data[0]['edit'] );
67 $this->assertArrayHasKey( 'nochange', $data[0]['edit'] );
69 // -----------------------------------------------------------------------
70 $data = $this->doApiRequest( array(
73 'text' => 'different text',
74 'token' => $pageinfo['edittoken'] ),
77 self
::$users['sysop']->user
);
79 $this->assertEquals( 'Success', $data[0]['edit']['result'] );
81 $this->assertArrayNotHasKey( 'new', $data[0]['edit'] );
82 $this->assertArrayNotHasKey( 'nochange', $data[0]['edit'] );
84 $this->assertArrayHasKey( 'oldrevid', $data[0]['edit'] );
85 $this->assertArrayHasKey( 'newrevid', $data[0]['edit'] );
86 $this->assertTrue( $data[0]['edit']['newrevid'] !== $data[0]['edit']['oldrevid'], "revision id should change after edit" );
89 function testEditAppend() {
90 $this->markTestIncomplete( "not yet implemented" );
93 function testEditSection() {
94 $this->markTestIncomplete( "not yet implemented" );
98 $this->markTestIncomplete( "not yet implemented" );
101 function testEditNonText() {
102 $this->markTestIncomplete( "not yet implemented" );