| 1 |
<?php |
| 2 |
|
| 3 |
namespace MediaWiki\Extension\DiscussionTools\Tests; |
| 4 |
|
| 5 |
use MediaWiki\Tests\Api\ApiTestCase; |
| 6 |
use MediaWiki\Title\Title; |
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
class ApiDiscussionToolsCompareTest extends ApiTestCase { |
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
public function testExecuteApiDiscussionToolsCompare() { |
| 19 |
$title = Title::newFromText( 'Talk:' . __METHOD__ ); |
| 20 |
$page = $this->getNonexistingTestPage( $title ); |
| 21 |
|
| 22 |
$this->editPage( $page, "== Test ==\n\nadd DT pageinfo content\n" ); |
| 23 |
$rev1 = $page->getLatest(); |
| 24 |
|
| 25 |
$this->editPage( $page, ':adding another edit' ); |
| 26 |
$rev2 = $page->getLatest(); |
| 27 |
|
| 28 |
$params = [ |
| 29 |
'action' => 'discussiontoolscompare', |
| 30 |
'fromrev' => $rev1, |
| 31 |
'torev' => $rev2, |
| 32 |
]; |
| 33 |
|
| 34 |
$result = $this->doApiRequestWithToken( $params ); |
| 35 |
|
| 36 |
$this->assertNotEmpty( $result[0]['discussiontoolscompare'] ); |
| 37 |
$this->assertArrayHasKey( 'fromrevid', $result[0]['discussiontoolscompare'] ); |
| 38 |
$this->assertSame( $rev1, $result[0]['discussiontoolscompare']['fromrevid'] ); |
| 39 |
$this->assertArrayHasKey( 'torevid', $result[0]['discussiontoolscompare'] ); |
| 40 |
$this->assertSame( $rev2, $result[0]['discussiontoolscompare']['torevid'] ); |
| 41 |
$this->assertArrayHasKey( 'removedcomments', $result[0]['discussiontoolscompare'] ); |
| 42 |
$this->assertArrayHasKey( 'addedcomments', $result[0]['discussiontoolscompare'] ); |
| 43 |
} |
| 44 |
|
| 45 |
} |