Remove reliance on Block properties being public
[lhc/web/wiklou.git] / tests / phpunit / includes / specials / SpecialBlockTest.php
index 0643e0e..182ca0d 100644 (file)
@@ -12,7 +12,7 @@ use Wikimedia\TestingAccessWrapper;
  */
 class SpecialBlockTest extends SpecialPageTestBase {
        /**
-        * {@inheritdoc}
+        * @inheritDoc
         */
        protected function newSpecialPage() {
                return new SpecialBlock();
@@ -88,10 +88,10 @@ class SpecialBlockTest extends SpecialPageTestBase {
 
                $this->assertSame( (string)$block->getTarget(), $fields['Target']['default'] );
                $this->assertSame( $block->isHardblock(), $fields['HardBlock']['default'] );
-               $this->assertSame( $block->prevents( 'createaccount' ), $fields['CreateAccount']['default'] );
+               $this->assertSame( $block->isCreateAccountBlocked(), $fields['CreateAccount']['default'] );
                $this->assertSame( $block->isAutoblocking(), $fields['AutoBlock']['default'] );
-               $this->assertSame( $block->prevents( 'editownusertalk' ), $fields['DisableUTEdit']['default'] );
-               $this->assertSame( $block->mReason, $fields['Reason']['default'] );
+               $this->assertSame( !$block->isUsertalkEditAllowed(), $fields['DisableUTEdit']['default'] );
+               $this->assertSame( $block->getReason(), $fields['Reason']['default'] );
                $this->assertSame( 'infinite', $fields['Expiry']['default'] );
        }
 
@@ -121,6 +121,8 @@ class SpecialBlockTest extends SpecialPageTestBase {
                        new PageRestriction( 0, $pageSaturn->getId() ),
                        new PageRestriction( 0, $pageMars->getId() ),
                        new NamespaceRestriction( 0, NS_TALK ),
+                       // Deleted page.
+                       new PageRestriction( 0, 999999 ),
                ] );
 
                $block->insert();
@@ -177,7 +179,7 @@ class SpecialBlockTest extends SpecialPageTestBase {
                $this->assertTrue( $result );
 
                $block = Block::newFromTarget( $badActor );
-               $this->assertSame( $reason, $block->mReason );
+               $this->assertSame( $reason, $block->getReason() );
                $this->assertSame( $expiry, $block->getExpiry() );
        }
 
@@ -226,7 +228,7 @@ class SpecialBlockTest extends SpecialPageTestBase {
                $this->assertTrue( $result );
 
                $block = Block::newFromTarget( $badActor );
-               $this->assertSame( $reason, $block->mReason );
+               $this->assertSame( $reason, $block->getReason() );
                $this->assertSame( $expiry, $block->getExpiry() );
                $this->assertSame( '1', $block->isAutoblocking() );
        }
@@ -275,7 +277,7 @@ class SpecialBlockTest extends SpecialPageTestBase {
                $this->assertTrue( $result );
 
                $block = Block::newFromTarget( $badActor );
-               $this->assertSame( $reason, $block->mReason );
+               $this->assertSame( $reason, $block->getReason() );
                $this->assertSame( $expiry, $block->getExpiry() );
                $this->assertCount( 2, $block->getRestrictions() );
                $this->assertTrue( BlockRestriction::equals( $block->getRestrictions(), [
@@ -329,7 +331,7 @@ class SpecialBlockTest extends SpecialPageTestBase {
                $this->assertTrue( $result );
 
                $block = Block::newFromTarget( $badActor );
-               $this->assertSame( $reason, $block->mReason );
+               $this->assertSame( $reason, $block->getReason() );
                $this->assertSame( $expiry, $block->getExpiry() );
                $this->assertFalse( $block->isSitewide() );
                $this->assertCount( 2, $block->getRestrictions() );
@@ -345,7 +347,7 @@ class SpecialBlockTest extends SpecialPageTestBase {
                $this->assertTrue( $result );
 
                $block = Block::newFromTarget( $badActor );
-               $this->assertSame( $reason, $block->mReason );
+               $this->assertSame( $reason, $block->getReason() );
                $this->assertSame( $expiry, $block->getExpiry() );
                $this->assertFalse( $block->isSitewide() );
                $this->assertCount( 1, $block->getRestrictions() );
@@ -360,7 +362,7 @@ class SpecialBlockTest extends SpecialPageTestBase {
                $this->assertTrue( $result );
 
                $block = Block::newFromTarget( $badActor );
-               $this->assertSame( $reason, $block->mReason );
+               $this->assertSame( $reason, $block->getReason() );
                $this->assertSame( $expiry, $block->getExpiry() );
                $this->assertFalse( $block->isSitewide() );
                $this->assertCount( 0, $block->getRestrictions() );
@@ -372,7 +374,7 @@ class SpecialBlockTest extends SpecialPageTestBase {
                $this->assertTrue( $result );
 
                $block = Block::newFromTarget( $badActor );
-               $this->assertSame( $reason, $block->mReason );
+               $this->assertSame( $reason, $block->getReason() );
                $this->assertSame( $expiry, $block->getExpiry() );
                $this->assertTrue( $block->isSitewide() );
                $this->assertCount( 0, $block->getRestrictions() );
@@ -399,6 +401,9 @@ class SpecialBlockTest extends SpecialPageTestBase {
                $expectedResult,
                $reason
        ) {
+               $this->setMwGlobals( [
+                       'wgBlockDisablesLogin' => false,
+               ] );
                $this->setGroupPermissions( 'sysop', 'unblockself', true );
                $this->setGroupPermissions( 'user', 'block', true );
                // Getting errors about creating users in db in provider.