Merge "Remove use of BagOStuff TTL constants from unrelated code"
[mediawiki.git] / tests / phpunit / includes / api / query / ApiQueryAllDeletedRevisionsTest.php
blob4d123cdd23bd632898b71ec57c5a574060f1e450
1 <?php
3 namespace MediaWiki\Tests\Api\Query;
5 use MediaWiki\MainConfigNames;
6 use MediaWiki\Tests\Api\ApiTestCase;
7 use MediaWiki\Title\Title;
9 /**
10 * @group API
11 * @group Database
12 * @covers \MediaWiki\Api\ApiQueryAllDeletedRevisions
14 class ApiQueryAllDeletedRevisionsTest extends ApiTestCase {
16 public function testFromToPrefixParameter() {
17 $this->overrideConfigValues( [
18 MainConfigNames::CapitalLinks => false,
19 ] );
20 $performer = $this->getTestSysop()->getAuthority();
22 $title = Title::makeTitle( NS_MAIN, 'pageM' );
23 $page = $this->getServiceContainer()->getWikiPageFactory()->newFromTitle( $title );
24 $this->editPage( $page, 'Some text', 'Create', NS_MAIN, $performer );
25 $this->deletePage( $page, 'Delete', $performer );
27 $userTitle = Title::makeTitle( NS_USER, 'PageU' );
28 $userPage = $this->getServiceContainer()->getWikiPageFactory()->newFromTitle( $userTitle );
29 $this->editPage( $userPage, 'Some text', 'Create', NS_MAIN, $performer );
30 $this->deletePage( $userPage, 'Delete', $performer );
32 $expectedResult0 = [ 'ns' => $title->getNamespace(), 'title' => $title->getPrefixedDbKey() ];
33 $expectedResult1 = [ 'ns' => $userTitle->getNamespace(), 'title' => $userTitle->getPrefixedDbKey() ];
35 // Search the page with prefix
36 [ $result ] = $this->doApiRequest( [
37 'action' => 'query',
38 'list' => 'alldeletedrevisions',
39 'adrdir' => 'newer',
40 'adrnamespace' => '0|2',
41 'adrprefix' => 'page',
42 ], null, false, $performer );
44 $this->assertArrayHasKey( 'query', $result );
45 $this->assertArrayHasKey( 'alldeletedrevisions', $result['query'] );
46 $this->assertArrayContains( $expectedResult0, $result['query']['alldeletedrevisions'][0] );
47 $this->assertArrayContains( $expectedResult1, $result['query']['alldeletedrevisions'][1] );
49 // Search the page with from
50 [ $result ] = $this->doApiRequest( [
51 'action' => 'query',
52 'list' => 'alldeletedrevisions',
53 'adrdir' => 'newer',
54 'adrnamespace' => '0|2',
55 'adrfrom' => 'pageA',
56 ], null, false, $performer );
58 $this->assertArrayHasKey( 'query', $result );
59 $this->assertArrayHasKey( 'alldeletedrevisions', $result['query'] );
60 $this->assertArrayContains( $expectedResult0, $result['query']['alldeletedrevisions'][0] );
61 $this->assertArrayContains( $expectedResult1, $result['query']['alldeletedrevisions'][1] );
63 // Search the page with to
64 [ $result ] = $this->doApiRequest( [
65 'action' => 'query',
66 'list' => 'alldeletedrevisions',
67 'adrdir' => 'newer',
68 'adrnamespace' => '0|2',
69 'adrto' => 'pageZ',
70 ], null, false, $performer );
72 $this->assertArrayHasKey( 'query', $result );
73 $this->assertArrayHasKey( 'alldeletedrevisions', $result['query'] );
74 $this->assertArrayContains( $expectedResult0, $result['query']['alldeletedrevisions'][0] );
75 $this->assertArrayContains( $expectedResult1, $result['query']['alldeletedrevisions'][1] );