/** * Check if the user has permission to access the requested resources. * * @param string[] $resources * @param UserIdentifier $userIdentifier * @return bool */ protected function _isAnonymousOrSelfAllowed($resources, UserIdentifier $userIdentifier) { if (count($resources) == 1) { $resource = reset($resources); $isAnonymousAccess = $resource == self::PERMISSION_ANONYMOUS; $isSelfAccess = $userIdentifier->getUserType() == UserIdentifier::USER_TYPE_CUSTOMER && $resource == self::PERMISSION_SELF; if ($isAnonymousAccess || $isSelfAccess) { return true; } } return false; }
/** * @param string $userType * @param int $userId * @dataProvider constructProvider */ public function testConstruct($userType, $userId) { $context = new UserIdentifier($this->_userLocatorMock, $userType, $userId); $this->assertEquals($userId, $context->getUserId()); $this->assertEquals($userType, $context->getUserType()); }