MCR deprecated the Revision class in favor of the broadly similar RevisionRecord, and more interestingly added the concept of multiple content "slots" to revisions. Thus, prop=revisions, prop=deletedrevisions, and so on gain a parameter to specify which slots are wanted. When this new parameter is not specified (and any content-related props are specified), a warning about the legacy format will be issued. The rest of the modules just needed to call methods or use constants on RevisionRecord instead of Revision. ApiQueryDeletedrevs wasn't touched, since it has been deprecated since 1.25 anyway. This also updates a few non-query modules that don't depend on details of editing, diffing, or viewing MCR revisions that haven't been figured out yet. Bug: T200568 Change-Id: I1327d1784f5cedb006cd74df834cf9a560a77a5d
47 lines
1.4 KiB
PHP
47 lines
1.4 KiB
PHP
<?php
|
|
|
|
/**
|
|
* @group API
|
|
* @group Database
|
|
* @group medium
|
|
* @covers ApiQueryRevisions
|
|
*/
|
|
class ApiQueryRevisionsTest extends ApiTestCase {
|
|
|
|
/**
|
|
* @group medium
|
|
*/
|
|
public function testContentComesWithContentModelAndFormat() {
|
|
$pageName = 'Help:' . __METHOD__;
|
|
$title = Title::newFromText( $pageName );
|
|
$page = WikiPage::factory( $title );
|
|
|
|
$page->doEditContent(
|
|
ContentHandler::makeContent( 'Some text', $page->getTitle() ),
|
|
'inserting content'
|
|
);
|
|
|
|
$apiResult = $this->doApiRequest( [
|
|
'action' => 'query',
|
|
'prop' => 'revisions',
|
|
'titles' => $pageName,
|
|
'rvprop' => 'content',
|
|
'rvslots' => 'main',
|
|
] );
|
|
$this->assertArrayHasKey( 'query', $apiResult[0] );
|
|
$this->assertArrayHasKey( 'pages', $apiResult[0]['query'] );
|
|
foreach ( $apiResult[0]['query']['pages'] as $page ) {
|
|
$this->assertArrayHasKey( 'revisions', $page );
|
|
foreach ( $page['revisions'] as $revision ) {
|
|
$this->assertArrayHasKey( 'slots', $revision );
|
|
$this->assertArrayHasKey( 'main', $revision['slots'] );
|
|
$this->assertArrayHasKey( 'contentformat', $revision['slots']['main'],
|
|
'contentformat should be included when asking content so client knows how to interpret it'
|
|
);
|
|
$this->assertArrayHasKey( 'contentmodel', $revision['slots']['main'],
|
|
'contentmodel should be included when asking content so client knows how to interpret it'
|
|
);
|
|
}
|
|
}
|
|
}
|
|
}
|