3 namespace MediaWiki\Tests\Api\Query
;
5 use MediaWiki\Tests\Api\ApiTestCase
;
6 use MediaWiki\Title\Title
;
12 * @covers \MediaWiki\Api\ApiQueryAllRevisions
14 class ApiQueryAllRevisionsTest
extends ApiTestCase
{
19 public function testContentComesWithContentModelAndFormat() {
20 $title = Title
::makeTitle( NS_HELP
, 'TestContentComesWithContentModelAndFormat' );
26 $this->getTestSysop()->getAuthority()
33 $this->getTestSysop()->getAuthority()
36 $apiResult = $this->doApiRequest( [
38 'list' => 'allrevisions',
39 'arvprop' => 'content',
44 $this->assertArrayHasKey( 'query', $apiResult[0] );
45 $this->assertArrayHasKey( 'allrevisions', $apiResult[0]['query'] );
46 $this->assertArrayHasKey( 0, $apiResult[0]['query']['allrevisions'] );
47 $this->assertArrayHasKey( 'title', $apiResult[0]['query']['allrevisions'][0] );
48 $this->assertSame( $title->getPrefixedText(), $apiResult[0]['query']['allrevisions'][0]['title'] );
49 $this->assertArrayHasKey( 'revisions', $apiResult[0]['query']['allrevisions'][0] );
50 $this->assertCount( 2, $apiResult[0]['query']['allrevisions'][0]['revisions'] );
52 foreach ( $apiResult[0]['query']['allrevisions'] as $page ) {
53 $this->assertArrayHasKey( 'revisions', $page );
54 foreach ( $page['revisions'] as $revision ) {
55 $this->assertArrayHasKey( 'slots', $revision );
56 $this->assertArrayHasKey( 'main', $revision['slots'] );
57 $this->assertArrayHasKey( 'contentformat', $revision['slots']['main'],
58 'contentformat should be included when asking content so client knows how to interpret it'
60 $this->assertArrayHasKey( 'contentmodel', $revision['slots']['main'],
61 'contentmodel should be included when asking content so client knows how to interpret it'