Remove unnecessary variable from UserTest
[lhc/web/wiklou.git] / tests / phpunit / includes / user / UserTest.php
index b8806e7..64bdf31 100644 (file)
@@ -599,7 +599,6 @@ class UserTest extends MediaWikiTestCase {
                ] );
 
                // 1. Log in a test user, and block them.
-               $userBlocker = $this->getTestSysop()->getUser();
                $user1tmp = $this->getTestUser()->getUser();
                $request1 = new FauxRequest();
                $request1->getSession()->setUser( $user1tmp );
@@ -610,7 +609,6 @@ class UserTest extends MediaWikiTestCase {
                ] );
                $block->setBlocker( $this->getTestSysop()->getUser() );
                $block->setTarget( $user1tmp );
-               $block->setBlocker( $userBlocker );
                $res = $block->insert();
                $this->assertTrue( (bool)$res['id'], 'Failed to insert block' );
                $user1 = User::newFromSession( $request1 );
@@ -682,14 +680,12 @@ class UserTest extends MediaWikiTestCase {
                ] );
 
                // 1. Log in a test user, and block them.
-               $userBlocker = $this->getTestSysop()->getUser();
                $testUser = $this->getTestUser()->getUser();
                $request1 = new FauxRequest();
                $request1->getSession()->setUser( $testUser );
                $block = new Block( [ 'enableAutoblock' => true ] );
                $block->setBlocker( $this->getTestSysop()->getUser() );
                $block->setTarget( $testUser );
-               $block->setBlocker( $userBlocker );
                $res = $block->insert();
                $this->assertTrue( (bool)$res['id'], 'Failed to insert block' );
                $user = User::newFromSession( $request1 );
@@ -729,14 +725,12 @@ class UserTest extends MediaWikiTestCase {
                ] );
 
                // 1. Log in a test user, and block them indefinitely.
-               $userBlocker = $this->getTestSysop()->getUser();
                $user1Tmp = $this->getTestUser()->getUser();
                $request1 = new FauxRequest();
                $request1->getSession()->setUser( $user1Tmp );
                $block = new Block( [ 'enableAutoblock' => true, 'expiry' => 'infinity' ] );
                $block->setBlocker( $this->getTestSysop()->getUser() );
                $block->setTarget( $user1Tmp );
-               $block->setBlocker( $userBlocker );
                $res = $block->insert();
                $this->assertTrue( (bool)$res['id'], 'Failed to insert block' );
                $user1 = User::newFromSession( $request1 );
@@ -829,14 +823,12 @@ class UserTest extends MediaWikiTestCase {
                ] );
 
                // 1. Log in a blocked test user.
-               $userBlocker = $this->getTestSysop()->getUser();
                $user1tmp = $this->getTestUser()->getUser();
                $request1 = new FauxRequest();
                $request1->getSession()->setUser( $user1tmp );
                $block = new Block( [ 'enableAutoblock' => true ] );
                $block->setBlocker( $this->getTestSysop()->getUser() );
                $block->setTarget( $user1tmp );
-               $block->setBlocker( $userBlocker );
                $res = $block->insert();
                $this->assertTrue( (bool)$res['id'], 'Failed to insert block' );
                $user1 = User::newFromSession( $request1 );
@@ -876,14 +868,12 @@ class UserTest extends MediaWikiTestCase {
                ] );
 
                // 1. Log in a blocked test user.
-               $userBlocker = $this->getTestSysop()->getUser();
                $user1tmp = $this->getTestUser()->getUser();
                $request1 = new FauxRequest();
                $request1->getSession()->setUser( $user1tmp );
                $block = new Block( [ 'enableAutoblock' => true ] );
                $block->setBlocker( $this->getTestSysop()->getUser() );
                $block->setTarget( $user1tmp );
-               $block->setBlocker( $userBlocker );
                $res = $block->insert();
                $this->assertTrue( (bool)$res['id'], 'Failed to insert block' );
                $user1 = User::newFromSession( $request1 );
@@ -1285,17 +1275,18 @@ class UserTest extends MediaWikiTestCase {
 
        public static function provideIsBlockedFrom() {
                return [
-                       'Basic operation' => [ 'Test page', true ],
-                       'User talk page, not allowed' => [ self::USER_TALK_PAGE, true, [
+                       'Sitewide block, basic operation' => [ 'Test page', true ],
+                       'Sitewide block, not allowing user talk' => [
+                               self::USER_TALK_PAGE, true, [
                                        'allowUsertalk' => false,
                                ]
                        ],
-                       'User talk page, allowed' => [
-                                       self::USER_TALK_PAGE, false, [
+                       'Sitewide block, allowing user talk' => [
+                               self::USER_TALK_PAGE, false, [
                                        'allowUsertalk' => true,
                                ]
                        ],
-                       'User talk page, allowed but $wgBlockAllowsUTEdit is false' => [
+                       'Sitewide block, allowing user talk but $wgBlockAllowsUTEdit is false' => [
                                self::USER_TALK_PAGE, true, [
                                        'allowUsertalk' => true,
                                        'blockAllowsUTEdit' => false,
@@ -1311,40 +1302,51 @@ class UserTest extends MediaWikiTestCase {
                                        'pageRestrictions' => [ 'Test page' ],
                                ]
                        ],
-                       'Partial block, allowing user talk' => [
+                       'Partial block, not allowing user talk but user talk page is not blocked' => [
                                self::USER_TALK_PAGE, false, [
                                        'allowUsertalk' => false,
                                        'pageRestrictions' => [ 'Test page' ],
                                ]
                        ],
-                       'Partial block, not allowing user talk' => [
+                       'Partial block, allowing user talk but user talk page is blocked' => [
                                self::USER_TALK_PAGE, true, [
                                        'allowUsertalk' => true,
                                        'pageRestrictions' => [ self::USER_TALK_PAGE ],
                                ]
                        ],
-                       'Partial block, allowing user talk but $wgBlockAllowsUTEdit is false' => [
+                       'Partial block, user talk page is not blocked but $wgBlockAllowsUTEdit is false' => [
                                self::USER_TALK_PAGE, false, [
                                        'allowUsertalk' => false,
                                        'pageRestrictions' => [ 'Test page' ],
                                        'blockAllowsUTEdit' => false,
                                ]
                        ],
-                       'Partial block, not allowing user talk with $wgBlockAllowsUTEdit set to false' => [
+                       'Partial block, user talk page is blocked and $wgBlockAllowsUTEdit is false' => [
                                self::USER_TALK_PAGE, true, [
                                        'allowUsertalk' => true,
                                        'pageRestrictions' => [ self::USER_TALK_PAGE ],
                                        'blockAllowsUTEdit' => false,
                                ]
                        ],
-                       'Partial namespace block, not allowing user talk' => [ self::USER_TALK_PAGE, true, [
-                               'allowUsertalk' => false,
-                               'namespaceRestrictions' => [ NS_USER_TALK ],
-                       ] ],
-                       'Partial namespace block, not allowing user talk' => [ self::USER_TALK_PAGE, false, [
-                               'allowUsertalk' => true,
-                               'namespaceRestrictions' => [ NS_USER_TALK ],
-                       ] ],
+                       'Partial user talk namespace block, not allowing user talk' => [
+                               self::USER_TALK_PAGE, true, [
+                                       'allowUsertalk' => false,
+                                       'namespaceRestrictions' => [ NS_USER_TALK ],
+                               ]
+                       ],
+                       'Partial user talk namespace block, allowing user talk' => [
+                               self::USER_TALK_PAGE, false, [
+                                       'allowUsertalk' => true,
+                                       'namespaceRestrictions' => [ NS_USER_TALK ],
+                               ]
+                       ],
+                       'Partial user talk namespace block, where $wgBlockAllowsUTEdit is false' => [
+                               self::USER_TALK_PAGE, true, [
+                                       'allowUsertalk' => true,
+                                       'namespaceRestrictions' => [ NS_USER_TALK ],
+                                       'blockAllowsUTEdit' => false,
+                               ]
+                       ],
                ];
        }