maintenance: Script to rename titles for Unicode uppercasing changes
[lhc/web/wiklou.git] / tests / phpunit / includes / BlockTest.php
index 50a4e2f..df3de4a 100644 (file)
@@ -1,8 +1,9 @@
 <?php
 
-use MediaWiki\Block\BlockRestriction;
+use MediaWiki\Block\BlockRestrictionStore;
 use MediaWiki\Block\Restriction\PageRestriction;
 use MediaWiki\Block\Restriction\NamespaceRestriction;
+use MediaWiki\MediaWikiServices;
 
 /**
  * @group Database
@@ -94,7 +95,7 @@ class BlockTest extends MediaWikiLangTestCase {
                $madeAt = wfTimestamp( TS_MW );
 
                // delta to stop one-off errors when things happen to go over a second mark.
-               $delta = abs( $madeAt - $block->mTimestamp );
+               $delta = abs( $madeAt - $block->getTimestamp() );
                $this->assertLessThan(
                        2,
                        $delta,
@@ -302,8 +303,8 @@ class BlockTest extends MediaWikiLangTestCase {
                        $block = new Block();
                        $block->setTarget( $target );
                        $block->setBlocker( $blocker );
-                       $block->mReason = $insBlock['desc'];
-                       $block->mExpiry = 'infinity';
+                       $block->setReason( $insBlock['desc'] );
+                       $block->setExpiry( 'infinity' );
                        $block->isCreateAccountBlocked( $insBlock['ACDisable'] );
                        $block->isHardblock( $insBlock['isHardblock'] );
                        $block->isAutoblocking( $insBlock['isAutoBlocking'] );
@@ -369,7 +370,9 @@ class BlockTest extends MediaWikiLangTestCase {
                $xffblocks = Block::getBlocksForIPList( $list, true );
                $this->assertEquals( $exCount, count( $xffblocks ), 'Number of blocks for ' . $xff );
                $block = Block::chooseBlock( $xffblocks, $list );
-               $this->assertEquals( $exResult, $block->mReason, 'Correct block type for XFF header ' . $xff );
+               $this->assertEquals(
+                       $exResult, $block->getReason(), 'Correct block type for XFF header ' . $xff
+               );
        }
 
        /**
@@ -610,7 +613,7 @@ class BlockTest extends MediaWikiLangTestCase {
 
                $pageRestriction = new PageRestriction( $block->getId(), $pageFoo->getId() );
                $namespaceRestriction = new NamespaceRestriction( $block->getId(), NS_USER );
-               BlockRestriction::insert( [ $pageRestriction, $namespaceRestriction ] );
+               $this->getBlockRestrictionStore()->insert( [ $pageRestriction, $namespaceRestriction ] );
 
                $this->assertTrue( $block->appliesToTitle( $pageFoo->getTitle() ) );
                $this->assertFalse( $block->appliesToTitle( $pageBar->getTitle() ) );
@@ -671,7 +674,7 @@ class BlockTest extends MediaWikiLangTestCase {
                        $block->getId(),
                        $title->getArticleID()
                );
-               BlockRestriction::insert( [ $pageRestriction ] );
+               $this->getBlockRestrictionStore()->insert( [ $pageRestriction ] );
 
                $this->assertTrue( $block->appliesToPage( $title->getArticleID() ) );
 
@@ -697,7 +700,7 @@ class BlockTest extends MediaWikiLangTestCase {
                $block->insert();
 
                $namespaceRestriction = new NamespaceRestriction( $block->getId(), NS_MAIN );
-               BlockRestriction::insert( [ $namespaceRestriction ] );
+               $this->getBlockRestrictionStore()->insert( [ $namespaceRestriction ] );
 
                $this->assertTrue( $block->appliesToNamespace( NS_MAIN ) );
                $this->assertFalse( $block->appliesToNamespace( NS_USER ) );
@@ -716,4 +719,12 @@ class BlockTest extends MediaWikiLangTestCase {
                $this->assertFalse( $block->appliesToRight( 'purge' ) );
        }
 
+       /**
+        * Get an instance of BlockRestrictionStore
+        *
+        * @return BlockRestrictionStore
+        */
+       protected function getBlockRestrictionStore() : BlockRestrictionStore {
+               return MediaWikiServices::getInstance()->getBlockRestrictionStore();
+       }
 }