Merge "Remove use of BagOStuff TTL constants from unrelated code"
[mediawiki.git] / tests / phpunit / includes / api / query / ApiQueryAllRevisionsTest.php
blobe60ff7bbe4c05d635e95b82e028c55d826211040
1 <?php
3 namespace MediaWiki\Tests\Api\Query;
5 use MediaWiki\Tests\Api\ApiTestCase;
6 use MediaWiki\Title\Title;
8 /**
9 * @group API
10 * @group Database
11 * @group medium
12 * @covers \MediaWiki\Api\ApiQueryAllRevisions
14 class ApiQueryAllRevisionsTest extends ApiTestCase {
16 /**
17 * @group medium
19 public function testContentComesWithContentModelAndFormat() {
20 $title = Title::makeTitle( NS_HELP, 'TestContentComesWithContentModelAndFormat' );
21 $this->editPage(
22 $title,
23 'Some text',
24 'inserting content',
25 NS_MAIN,
26 $this->getTestSysop()->getAuthority()
28 $this->editPage(
29 $title,
30 'Some other text',
31 'adding revision',
32 NS_MAIN,
33 $this->getTestSysop()->getAuthority()
36 $apiResult = $this->doApiRequest( [
37 'action' => 'query',
38 'list' => 'allrevisions',
39 'arvprop' => 'content',
40 'arvslots' => 'main',
41 'arvdir' => 'older',
42 ] );
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'