3 namespace MediaWiki\Tests\Api\Query
;
5 use MediaWiki\MainConfigNames
;
6 use MediaWiki\Tests\Api\ApiTestCase
;
7 use MediaWiki\Title\Title
;
12 * @covers \MediaWiki\Api\ApiQueryAllDeletedRevisions
14 class ApiQueryAllDeletedRevisionsTest
extends ApiTestCase
{
16 public function testFromToPrefixParameter() {
17 $this->overrideConfigValues( [
18 MainConfigNames
::CapitalLinks
=> false,
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( [
38 'list' => 'alldeletedrevisions',
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( [
52 'list' => 'alldeletedrevisions',
54 'adrnamespace' => '0|2',
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( [
66 'list' => 'alldeletedrevisions',
68 'adrnamespace' => '0|2',
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] );