5297d6daa73b5cbc473a8c645fbfa58c50bd9430
4 * Tests for MediaWiki api.php?action=edit.
6 * @author Daniel Kinzler
11 class ApiEditPageTest
extends ApiTestCase
{
18 function testEdit( ) {
19 $name = 'ApiEditPageTest_testEdit';
21 // -- test new page --------------------------------------------
22 $apiResult = $this->doApiRequestWithToken( array(
25 'text' => 'some text', ) );
26 $apiResult = $apiResult[0];
28 # Validate API result data
29 $this->assertArrayHasKey( 'edit', $apiResult );
30 $this->assertArrayHasKey( 'result', $apiResult['edit'] );
31 $this->assertEquals( 'Success', $apiResult['edit']['result'] );
33 $this->assertArrayHasKey( 'new', $apiResult['edit'] );
34 $this->assertArrayNotHasKey( 'nochange', $apiResult['edit'] );
36 $this->assertArrayHasKey( 'pageid', $apiResult['edit'] );
38 // -- test existing page, no change ----------------------------
39 $data = $this->doApiRequestWithToken( array(
42 'text' => 'some text', ) );
44 $this->assertEquals( 'Success', $data[0]['edit']['result'] );
46 $this->assertArrayNotHasKey( 'new', $data[0]['edit'] );
47 $this->assertArrayHasKey( 'nochange', $data[0]['edit'] );
49 // -- test existing page, with change --------------------------
50 $data = $this->doApiRequestWithToken( array(
53 'text' => 'different text' ) );
55 $this->assertEquals( 'Success', $data[0]['edit']['result'] );
57 $this->assertArrayNotHasKey( 'new', $data[0]['edit'] );
58 $this->assertArrayNotHasKey( 'nochange', $data[0]['edit'] );
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"
69 function testEditAppend() {
70 $this->markTestIncomplete( "not yet implemented" );
73 function testEditSection() {
74 $this->markTestIncomplete( "not yet implemented" );
78 $this->markTestIncomplete( "not yet implemented" );
81 function testEditNonText() {
82 $this->markTestIncomplete( "not yet implemented" );