Merge "Add missing `@return` PHPDoc to __sleep() function"
[lhc/web/wiklou.git] / tests / phpunit / includes / block / Restriction / NamespaceRestrictionTest.php
1 <?php
2
3 namespace MediaWiki\Tests\Block\Restriction;
4
5 use MediaWiki\Block\Restriction\NamespaceRestriction;
6
7 /**
8 * @group Database
9 * @group Blocking
10 * @covers \MediaWiki\Block\Restriction\AbstractRestriction
11 * @covers \MediaWiki\Block\Restriction\NamespaceRestriction
12 */
13 class NamespaceRestrictionTest extends RestrictionTestCase {
14
15 public function testMatches() {
16 $class = $this->getClass();
17 $page = $this->getExistingTestPage( 'Saturn' );
18 $restriction = new $class( 1, NS_MAIN );
19 $this->assertTrue( $restriction->matches( $page->getTitle() ) );
20
21 $page = $this->getExistingTestPage( 'Talk:Saturn' );
22 $this->assertFalse( $restriction->matches( $page->getTitle() ) );
23 }
24
25 public function testGetType() {
26 $class = $this->getClass();
27 $restriction = new $class( 1, 2 );
28 $this->assertEquals( 'ns', $restriction->getType() );
29 }
30
31 /**
32 * {@inheritdoc}
33 */
34 protected function getClass() {
35 return NamespaceRestriction::class;
36 }
37 }