1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
<?php
/**
* Tests for MediaWiki api.php?action=edit.
*
* @author Daniel Kinzler
*
* @group API
* @group Database
*/
class ApiEditPageTest extends ApiTestCase {
function setUp() {
parent::setUp();
$this->doLogin();
}
function testEdit( ) {
$name = 'ApiEditPageTest_testEdit';
// -- test new page --------------------------------------------
$apiResult = $this->doApiRequestWithToken( array(
'action' => 'edit',
'title' => $name,
'text' => 'some text', ) );
$apiResult = $apiResult[0];
# Validate API result data
$this->assertArrayHasKey( 'edit', $apiResult );
$this->assertArrayHasKey( 'result', $apiResult['edit'] );
$this->assertEquals( 'Success', $apiResult['edit']['result'] );
$this->assertArrayHasKey( 'new', $apiResult['edit'] );
$this->assertArrayNotHasKey( 'nochange', $apiResult['edit'] );
$this->assertArrayHasKey( 'pageid', $apiResult['edit'] );
// -- test existing page, no change ----------------------------
$data = $this->doApiRequestWithToken( array(
'action' => 'edit',
'title' => $name,
'text' => 'some text', ) );
$this->assertEquals( 'Success', $data[0]['edit']['result'] );
$this->assertArrayNotHasKey( 'new', $data[0]['edit'] );
$this->assertArrayHasKey( 'nochange', $data[0]['edit'] );
// -- test existing page, with change --------------------------
$data = $this->doApiRequestWithToken( array(
'action' => 'edit',
'title' => $name,
'text' => 'different text' ) );
$this->assertEquals( 'Success', $data[0]['edit']['result'] );
$this->assertArrayNotHasKey( 'new', $data[0]['edit'] );
$this->assertArrayNotHasKey( 'nochange', $data[0]['edit'] );
$this->assertArrayHasKey( 'oldrevid', $data[0]['edit'] );
$this->assertArrayHasKey( 'newrevid', $data[0]['edit'] );
$this->assertNotEquals(
$data[0]['edit']['newrevid'],
$data[0]['edit']['oldrevid'],
"revision id should change after edit"
);
}
function testEditAppend() {
$this->markTestIncomplete( "not yet implemented" );
}
function testEditSection() {
$this->markTestIncomplete( "not yet implemented" );
}
function testUndo() {
$this->markTestIncomplete( "not yet implemented" );
}
function testEditNonText() {
$this->markTestIncomplete( "not yet implemented" );
}
}
|