MediaWiki  REL1_20
ApiEditPageTest.php
Go to the documentation of this file.
00001 <?php
00002 
00011 class ApiEditPageTest extends ApiTestCase {
00012 
00013         function setUp() {
00014                 parent::setUp();
00015                 $this->doLogin();
00016         }
00017 
00018         function testEdit( ) {
00019                 $name = 'ApiEditPageTest_testEdit';
00020 
00021                 // -- test new page --------------------------------------------
00022                 $apiResult = $this->doApiRequestWithToken( array(
00023                                 'action' => 'edit',
00024                                 'title' => $name,
00025                                 'text' => 'some text', ) );
00026                 $apiResult = $apiResult[0];
00027 
00028                 # Validate API result data
00029                 $this->assertArrayHasKey( 'edit', $apiResult );
00030                 $this->assertArrayHasKey( 'result', $apiResult['edit'] );
00031                 $this->assertEquals( 'Success', $apiResult['edit']['result'] );
00032 
00033                 $this->assertArrayHasKey( 'new', $apiResult['edit'] );
00034                 $this->assertArrayNotHasKey( 'nochange', $apiResult['edit'] );
00035 
00036                 $this->assertArrayHasKey( 'pageid', $apiResult['edit'] );
00037 
00038                 // -- test existing page, no change ----------------------------
00039                 $data = $this->doApiRequestWithToken( array(
00040                                 'action' => 'edit',
00041                                 'title' => $name,
00042                                 'text' => 'some text', ) );
00043 
00044                 $this->assertEquals( 'Success', $data[0]['edit']['result'] );
00045 
00046                 $this->assertArrayNotHasKey( 'new', $data[0]['edit'] );
00047                 $this->assertArrayHasKey( 'nochange', $data[0]['edit'] );
00048 
00049                 // -- test existing page, with change --------------------------
00050                 $data = $this->doApiRequestWithToken( array(
00051                                 'action' => 'edit',
00052                                 'title' => $name,
00053                                 'text' => 'different text' ) );
00054 
00055                 $this->assertEquals( 'Success', $data[0]['edit']['result'] );
00056 
00057                 $this->assertArrayNotHasKey( 'new', $data[0]['edit'] );
00058                 $this->assertArrayNotHasKey( 'nochange', $data[0]['edit'] );
00059 
00060                 $this->assertArrayHasKey( 'oldrevid', $data[0]['edit'] );
00061                 $this->assertArrayHasKey( 'newrevid', $data[0]['edit'] );
00062                 $this->assertNotEquals(
00063                         $data[0]['edit']['newrevid'],
00064                         $data[0]['edit']['oldrevid'],
00065                         "revision id should change after edit"
00066                 );
00067         }
00068 
00069         function testEditAppend() {
00070                 $this->markTestIncomplete( "not yet implemented" );
00071         }
00072 
00073         function testEditSection() {
00074                 $this->markTestIncomplete( "not yet implemented" );
00075         }
00076 
00077         function testUndo() {
00078                 $this->markTestIncomplete( "not yet implemented" );
00079         }
00080 
00081         function testEditNonText() {
00082                 $this->markTestIncomplete( "not yet implemented" );
00083         }
00084 }