diff -u b/core/tests/Drupal/Tests/Core/Route/RouterRoleTest.php b/core/tests/Drupal/Tests/Core/Route/RouterRoleTest.php --- b/core/tests/Drupal/Tests/Core/Route/RouterRoleTest.php +++ b/core/tests/Drupal/Tests/Core/Route/RouterRoleTest.php @@ -28,13 +28,6 @@ */ class RouterRoleTest extends UnitTestCase { - /** - * Stores a list of user objects used in this test. - * - * @var array - */ - public $accounts = array(); - public static function getInfo() { return array( 'name' => 'Router Role tests', @@ -91,53 +84,27 @@ // Setup one user with the first role, one with the second, one with both // and one final without any of these two roles. - $this->accounts = array(); - $account_1 = new User(array('uid' => 1), 'user'); $account_1->roles[$rid_1] = $rid_1; - $this->accounts[] = $account_1; $account_2 = new User(array('uid' => 2), 'user'); $account_2->roles[$rid_2] = $rid_2; - $this->accounts[] = $account_2; $account_12 = new User(array('uid' => 3), 'user'); $account_12->roles[$rid_1] = $rid_1; $account_12->roles[$rid_2] = $rid_2; - $this->accounts[] = $account_12; $account_none = new User(array('uid' => 4), 'user'); - $this->accounts[] = $account_none; // Setup expected values; specify which paths can be accessed by which user. return array( - array('role_test_1', array($account_1, $account_12)), - array('role_test_2', array($account_2, $account_12)), - array('role_test_3', array($account_12)), + array('role_test_1', array($account_1, $account_12), array($account_2, $account_none)), + array('role_test_2', array($account_2, $account_12), array($account_1, $account_none)), + array('role_test_3', array($account_12), array($account_1, $account_2, $account_none)), ); } /** - * Returns accounts filtered by the passed in accounts. - * - * @param array $grant_users - * A list of users which should not be part of the result list. - * - * @return array - * All users which are not granted. - */ - protected function accountsToDeny($grant_users) { - return array_filter($this->accounts, function($account) use ($grant_users) { - foreach ($grant_users as $grant_user) { - if ($account == $grant_user) { - return FALSE; - } - } - return TRUE; - }); - } - - /** * Tests role requirements on routes. * * @param string $path @@ -150,7 +117,7 @@ * * @dataProvider roleAccessProvider */ - public function testRoleAccess($path, $grant_accounts) { + public function testRoleAccess($path, $grant_accounts, $deny_accounts) { $role_access_check = new RoleAccessCheck(); $collection = $this->getTestRouteCollection(); @@ -164,7 +131,7 @@ } // Check all users which don't have access. - foreach ($this->accountsToDeny($grant_accounts) as $account) { + foreach ($deny_accounts as $account) { $GLOBALS['user'] = $account; $subrequest = Request::create($path, 'GET');