From c38f247149efef1debc3353a0c588338283cad28 Mon Sep 17 00:00:00 2001 From: Thalia Date: Tue, 5 Feb 2019 17:20:58 +0000 Subject: [PATCH] Add test for User::isBlockedFrom In the complicated decision tree for checking if a blocked user is blocked from their talk page, one situation was not being tested: there's a partial block to the user talk namespace, the block is flagged as allowing a user to edit their talk page, BUT $wgBlockAllowsUTEdit is false. In this circumstance, the user should be blocked from editing their talk page, as outlined in T210475. Also, fix whitespace and make messages clearer, since this is now quite complicated. Change-Id: I234f3019d55a6da0da091a2eaae6c791be01b436 --- tests/phpunit/includes/user/UserTest.php | 46 +++++++++++++++--------- 1 file changed, 29 insertions(+), 17 deletions(-) diff --git a/tests/phpunit/includes/user/UserTest.php b/tests/phpunit/includes/user/UserTest.php index b8806e7f9f..863ff50bb3 100644 --- a/tests/phpunit/includes/user/UserTest.php +++ b/tests/phpunit/includes/user/UserTest.php @@ -1285,17 +1285,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 +1312,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, + ] + ], ]; } -- 2.20.1