Debian Codegraph @

tests/phpunit/integration/includes/specials/SpecialRandomPageTest.php

raw symbols SCIP
1 <?php
2
3 use MediaWiki\Specials\SpecialRandomPage;
4 use Wikimedia\TestingAccessWrapper;
5
6 /**
7 * @covers \MediaWiki\Specials\SpecialRandomPage
8 */
9 class SpecialRandomPageTest extends MediaWikiIntegrationTestCase {
10
11 /** @var SpecialRandomPage */
12 private $page;
13
14 public function setUp(): void {
15 $services = $this->getServiceContainer();
16 $this->page = new SpecialRandomPage(
17 $services->getConnectionProvider(),
18 $services->getNamespaceInfo()
19 );
20 parent::setUp();
21 }
22
23 /**
24 * @dataProvider providerParsePar
25 * @param string $par
26 * @param array $expectedNS Array of integer namespace ids
27 */
28 public function testParsePar( $par, $expectedNS ) {
29 /** @var SpecialRandomPage $page */
30 $page = TestingAccessWrapper::newFromObject( $this->page );
31 $page->parsePar( $par );
32 $this->assertEquals( $expectedNS, $this->page->getNamespaces() );
33 }
34
35 public function providerParsePar() {
36 global $wgContentNamespaces;
37
38 return [
39 [ null, $wgContentNamespaces ],
40 [ '', [ NS_MAIN ] ],
41 [ 'main', [ NS_MAIN ] ],
42 [ 'article', [ NS_MAIN ] ],
43 [ '0', [ NS_MAIN ] ],
44 [ 'File', [ NS_FILE ] ],
45 [ 'file_talk', [ NS_FILE_TALK ] ],
46 [ 'hElP', [ NS_HELP ] ],
47 [ 'Project,', [ NS_PROJECT, NS_MAIN ] ],
48 [ 'Project,Help,User_talk', [ NS_PROJECT, NS_HELP, NS_USER_TALK ] ],
49 [ '|invalid|,|namespaces|', $wgContentNamespaces ],
50 ];
51 }
52 }