Replace lowercase {@inheritdoc} with @inheritDoc
[lhc/web/wiklou.git] / tests / phpunit / includes / block / Restriction / PageRestrictionTest.php
1 <?php
2
3 namespace MediaWiki\Tests\Block\Restriction;
4
5 use MediaWiki\Block\Restriction\PageRestriction;
6
7 /**
8 * @group Database
9 * @group Blocking
10 * @covers \MediaWiki\Block\Restriction\AbstractRestriction
11 * @covers \MediaWiki\Block\Restriction\PageRestriction
12 */
13 class PageRestrictionTest extends RestrictionTestCase {
14
15 public function testMatches() {
16 $class = $this->getClass();
17 $page = $this->getExistingTestPage( 'Saturn' );
18 $restriction = new $class( 1, $page->getId() );
19 $this->assertTrue( $restriction->matches( $page->getTitle() ) );
20
21 $page = $this->getExistingTestPage( 'Mars' );
22 $this->assertFalse( $restriction->matches( $page->getTitle() ) );
23
24 // Deleted page.
25 $restriction = new $class( 2, 99999 );
26 $page = $this->getExistingTestPage( 'Saturn' );
27 $this->assertFalse( $restriction->matches( $page->getTitle() ) );
28 }
29
30 public function testGetType() {
31 $class = $this->getClass();
32 $restriction = new $class( 1, 2 );
33 $this->assertEquals( 'page', $restriction->getType() );
34 }
35
36 public function testGetTitle() {
37 $class = $this->getClass();
38 $restriction = new $class( 1, 2 );
39 $title = \Title::newFromText( 'Pluto' );
40 $title->mArticleID = 2;
41 $restriction->setTitle( $title );
42 $this->assertSame( $title, $restriction->getTitle() );
43
44 $restriction = new $class( 1, 1 );
45 $title = \Title::newFromId( 1 );
46 $this->assertEquals( $title->getArticleID(), $restriction->getTitle()->getArticleID() );
47 }
48
49 public function testNewFromRow() {
50 $class = $this->getClass();
51 $restriction = $class::newFromRow( (object)[
52 'ir_ipb_id' => 1,
53 'ir_value' => 2,
54 'page_namespace' => 0,
55 'page_title' => 'Saturn',
56 ] );
57
58 $this->assertSame( 1, $restriction->getBlockId() );
59 $this->assertSame( 2, $restriction->getValue() );
60 $this->assertSame( 'Saturn', $restriction->getTitle()->getText() );
61 }
62
63 /**
64 * @inheritDoc
65 */
66 protected function getClass() {
67 return PageRestriction::class;
68 }
69 }