diff --git a/.travis.yml b/.travis.yml
index d67b6911..e5bdfacd 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,18 +1,16 @@
language: php
php:
- - 5.3.3
- - 5.4
- - 5.5
- 5.6
- - hhvm
+ - 7.0
matrix:
- allow_failures:
- - php: hhvm
+ include:
+ - php: 5.6
+ env: dependencies="--prefer-lowest --prefer-stable"
script:
- - vendor/bin/tester tests -s -p php
- - php code-checker/src/code-checker.php
+ - vendor/bin/tester tests -s $coverage
+ - php temp/code-checker/src/code-checker.php --short-arrays
after_failure:
# Print *.actual content
@@ -20,5 +18,20 @@ after_failure:
before_script:
# Install Nette Tester & Code Checker
- - composer install --no-interaction --dev --prefer-source
- - composer create-project nette/code-checker code-checker ~2.3 --no-interaction --prefer-source
+ - travis_retry composer update --no-interaction --prefer-dist $dependencies
+ - travis_retry composer create-project nette/code-checker temp/code-checker ~2.5 --no-interaction
+ - if [ $TRAVIS_PHP_VERSION == "7.0" ]; then coverage="-p phpdbg --coverage ./coverage.xml --coverage-src ./src"; fi
+
+after_script:
+ # Report Code Coverage
+ - >
+ if [ "$coverage" != "" ]; then
+ wget https://github.com/satooshi/php-coveralls/releases/download/v1.0.1/coveralls.phar
+ && php coveralls.phar --verbose --config tests/.coveralls.yml
+ || true; fi
+
+sudo: false
+
+cache:
+ directories:
+ - $HOME/.composer/cache
diff --git a/composer.json b/composer.json
index 993cb4d3..cf2a1b65 100644
--- a/composer.json
+++ b/composer.json
@@ -1,26 +1,27 @@
{
"name": "nette/security",
"description": "Nette Security: Access Control Component",
- "homepage": "http://nette.org",
+ "homepage": "https://nette.org",
"license": ["BSD-3-Clause", "GPL-2.0", "GPL-3.0"],
"authors": [
{
"name": "David Grudl",
- "homepage": "http://davidgrudl.com"
+ "homepage": "https://davidgrudl.com"
},
{
"name": "Nette Community",
- "homepage": "http://nette.org/contributors"
+ "homepage": "https://nette.org/contributors"
}
],
"require": {
- "php": ">=5.3.1",
- "nette/utils": "~2.2"
+ "php": ">=5.6.0",
+ "nette/utils": "~2.4"
},
"require-dev": {
"nette/di": "~2.3",
"nette/http": "~2.3",
- "nette/tester": "~1.0"
+ "nette/tester": "~2.0",
+ "tracy/tracy": "^2.3"
},
"conflict": {
"nette/nette": "<2.2"
@@ -31,7 +32,7 @@
"minimum-stability": "dev",
"extra": {
"branch-alias": {
- "dev-master": "2.3-dev"
+ "dev-master": "2.4-dev"
}
}
}
diff --git a/contributing.md b/contributing.md
index a1cbbd53..860882bf 100644
--- a/contributing.md
+++ b/contributing.md
@@ -5,7 +5,7 @@ The issue tracker is the preferred channel for bug reports, features requests
and submitting pull requests, but please respect the following restrictions:
* Please **do not** use the issue tracker for personal support requests (use
- [Nette forum](http://forum.nette.org) or [Stack Overflow](http://stackoverflow.com)).
+ [Nette forum](https://forum.nette.org) or [Stack Overflow](http://stackoverflow.com)).
* Please **do not** derail or troll issues. Keep the discussion on topic and
respect the opinions of others.
@@ -21,7 +21,7 @@ fits with the scope and aims of the project. It's up to *you* to make a strong
case to convince the project's developers of the merits of this feature.
Nette welcomes **pull requests**. If you'd like to contribute, please take a moment
-to [read the guidelines](http://nette.org/en/contributing) in order to make
+to [read the guidelines](https://nette.org/en/contributing) in order to make
the contribution process easy and effective for everyone involved.
Thanks!
diff --git a/license.md b/license.md
index af571d59..cf741bd0 100644
--- a/license.md
+++ b/license.md
@@ -21,7 +21,7 @@ If your stuff is good, it will not take long to establish a reputation for yours
New BSD License
---------------
-Copyright (c) 2004, 2014 David Grudl (http://davidgrudl.com)
+Copyright (c) 2004, 2014 David Grudl (https://davidgrudl.com)
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
diff --git a/readme.md b/readme.md
index 29a17251..17e2c204 100644
--- a/readme.md
+++ b/readme.md
@@ -3,6 +3,9 @@ Nette Security: Access Control
[](https://packagist.org/packages/nette/security)
[](https://travis-ci.org/nette/security)
+[](https://coveralls.io/github/nette/security?branch=master)
+[](https://github.com/nette/security/releases)
+[](https://github.com/nette/security/blob/master/license.md)
- user login and logout
- verifying user privileges
@@ -120,7 +123,7 @@ class MyAuthenticator extends Nette\Object implements NS\IAuthenticator
throw new NS\AuthenticationException('User not found.');
}
- if ($row->password !== md5($password)) {
+ if (!NS\Passwords::verify($password, $row->password)) {
throw new NS\AuthenticationException('Invalid password.');
}
@@ -129,7 +132,7 @@ class MyAuthenticator extends Nette\Object implements NS\IAuthenticator
}
```
-Class `MyAuthenticator` communicates with the database using [Nette\Database |database] layer and works with table `users`, where it grabs `username` and md5 hash of `password` in the appropriate columns. If the password check is successful, it returns new identity with user ID and role, which we will mention [later | #roles];
+Class `MyAuthenticator` communicates with the database using [Nette\Database |database] layer and works with table `users`, where it grabs `username` and hash of `password` in the appropriate columns. If the password check is successful, it returns new identity with user ID and role, which we will mention [later | #roles];
This authenticator would be configured in the `config.neon` file like this:
diff --git a/src/Bridges/SecurityDI/SecurityExtension.php b/src/Bridges/SecurityDI/SecurityExtension.php
index 82c6713d..0a86194b 100644
--- a/src/Bridges/SecurityDI/SecurityExtension.php
+++ b/src/Bridges/SecurityDI/SecurityExtension.php
@@ -1,8 +1,8 @@
TRUE,
- 'users' => array(), // of [user => password] or [user => ['password' => password, 'roles' => [role]]]
- 'roles' => array(), // of [role => parents]
- 'resources' => array(), // of [resource => parents]
- );
+ 'users' => [], // of [user => password] or [user => ['password' => password, 'roles' => [role]]]
+ 'roles' => [], // of [role => parents]
+ 'resources' => [], // of [resource => parents]
+ ];
/** @var bool */
private $debugMode;
@@ -37,59 +35,59 @@ public function __construct($debugMode = FALSE)
public function loadConfiguration()
{
$config = $this->validateConfig($this->defaults);
- $container = $this->getContainerBuilder();
+ $builder = $this->getContainerBuilder();
- $container->addDefinition($this->prefix('userStorage'))
- ->setClass('Nette\Security\IUserStorage')
- ->setFactory('Nette\Http\UserStorage');
+ $builder->addDefinition($this->prefix('userStorage'))
+ ->setClass(Nette\Security\IUserStorage::class)
+ ->setFactory(Nette\Http\UserStorage::class);
- $user = $container->addDefinition($this->prefix('user'))
- ->setClass('Nette\Security\User');
+ $user = $builder->addDefinition($this->prefix('user'))
+ ->setClass(Nette\Security\User::class);
if ($this->debugMode && $config['debugger']) {
- $user->addSetup('@Tracy\Bar::addPanel', array(
- new Nette\DI\Statement('Nette\Bridges\SecurityTracy\UserPanel')
- ));
+ $user->addSetup('@Tracy\Bar::addPanel', [
+ new Nette\DI\Statement(Nette\Bridges\SecurityTracy\UserPanel::class),
+ ]);
}
if ($config['users']) {
- $usersList = $usersRoles = array();
+ $usersList = $usersRoles = [];
foreach ($config['users'] as $username => $data) {
- $data = is_array($data) ? $data : array('password' => $data);
- $this->validateConfig(array('password' => NULL, 'roles' => NULL), $data, $this->prefix("security.users.$username"));
+ $data = is_array($data) ? $data : ['password' => $data];
+ $this->validateConfig(['password' => NULL, 'roles' => NULL], $data, $this->prefix("security.users.$username"));
$usersList[$username] = $data['password'];
$usersRoles[$username] = isset($data['roles']) ? $data['roles'] : NULL;
}
- $container->addDefinition($this->prefix('authenticator'))
- ->setClass('Nette\Security\IAuthenticator')
- ->setFactory('Nette\Security\SimpleAuthenticator', array($usersList, $usersRoles));
+ $builder->addDefinition($this->prefix('authenticator'))
+ ->setClass(Nette\Security\IAuthenticator::class)
+ ->setFactory(Nette\Security\SimpleAuthenticator::class, [$usersList, $usersRoles]);
if ($this->name === 'security') {
- $container->addAlias('nette.authenticator', $this->prefix('authenticator'));
+ $builder->addAlias('nette.authenticator', $this->prefix('authenticator'));
}
}
if ($config['roles'] || $config['resources']) {
- $authorizator = $container->addDefinition($this->prefix('authorizator'))
- ->setClass('Nette\Security\IAuthorizator')
- ->setFactory('Nette\Security\Permission');
+ $authorizator = $builder->addDefinition($this->prefix('authorizator'))
+ ->setClass(Nette\Security\IAuthorizator::class)
+ ->setFactory(Nette\Security\Permission::class);
foreach ($config['roles'] as $role => $parents) {
- $authorizator->addSetup('addRole', array($role, $parents));
+ $authorizator->addSetup('addRole', [$role, $parents]);
}
foreach ($config['resources'] as $resource => $parents) {
- $authorizator->addSetup('addResource', array($resource, $parents));
+ $authorizator->addSetup('addResource', [$resource, $parents]);
}
if ($this->name === 'security') {
- $container->addAlias('nette.authorizator', $this->prefix('authorizator'));
+ $builder->addAlias('nette.authorizator', $this->prefix('authorizator'));
}
}
if ($this->name === 'security') {
- $container->addAlias('user', $this->prefix('user'));
- $container->addAlias('nette.userStorage', $this->prefix('userStorage'));
+ $builder->addAlias('user', $this->prefix('user'));
+ $builder->addAlias('nette.userStorage', $this->prefix('userStorage'));
}
}
diff --git a/src/Bridges/SecurityTracy/UserPanel.php b/src/Bridges/SecurityTracy/UserPanel.php
index e25f40a5..5bfd0a92 100644
--- a/src/Bridges/SecurityTracy/UserPanel.php
+++ b/src/Bridges/SecurityTracy/UserPanel.php
@@ -1,23 +1,23 @@
user;
require __DIR__ . '/templates/UserPanel.tab.phtml';
return ob_get_clean();
@@ -51,7 +51,7 @@ public function getTab()
*/
public function getPanel()
{
- ob_start();
+ ob_start(function () {});
$user = $this->user;
require __DIR__ . '/templates/UserPanel.panel.phtml';
return ob_get_clean();
diff --git a/src/Bridges/SecurityTracy/templates/UserPanel.panel.phtml b/src/Bridges/SecurityTracy/templates/UserPanel.panel.phtml
index 1e8244ac..c18dfeaa 100644
--- a/src/Bridges/SecurityTracy/templates/UserPanel.panel.phtml
+++ b/src/Bridges/SecurityTracy/templates/UserPanel.panel.phtml
@@ -9,5 +9,5 @@ use Nette,
isLoggedIn()): ?>Logged inUnlogged
- getIdentity()): echo Dumper::toHtml($user->getIdentity(), array(Dumper::LIVE => TRUE)); else: ?>
no identity
+ getIdentity()): echo Dumper::toHtml($user->getIdentity(), [Dumper::LIVE => TRUE]); else: ?>
no identity
diff --git a/src/Bridges/SecurityTracy/templates/UserPanel.tab.phtml b/src/Bridges/SecurityTracy/templates/UserPanel.tab.phtml
index 38a461a1..ec658b48 100644
--- a/src/Bridges/SecurityTracy/templates/UserPanel.tab.phtml
+++ b/src/Bridges/SecurityTracy/templates/UserPanel.tab.phtml
@@ -5,8 +5,6 @@ namespace Nette\Bridges\SecurityTracy;
use Nette;
?>
-isLoggedIn()): ?>
-
-
-
-
+
+
+
diff --git a/src/Security/AuthenticationException.php b/src/Security/AuthenticationException.php
index 7dee689c..c03803d9 100644
--- a/src/Security/AuthenticationException.php
+++ b/src/Security/AuthenticationException.php
@@ -1,19 +1,15 @@
parentIsSet($key)) {
+ $this->parentSet($key, $value);
} else {
$this->data[$key] = $value;
@@ -122,8 +126,8 @@ public function __set($key, $value)
*/
public function &__get($key)
{
- if (parent::__isset($key)) {
- return parent::__get($key);
+ if ($this->parentIsSet($key)) {
+ return $this->parentGet($key);
} else {
return $this->data[$key];
@@ -138,19 +142,7 @@ public function &__get($key)
*/
public function __isset($key)
{
- return isset($this->data[$key]) || parent::__isset($key);
- }
-
-
- /**
- * Removes property.
- * @param string property name
- * @return void
- * @throws Nette\MemberAccessException
- */
- public function __unset($name)
- {
- Nette\Utils\ObjectMixin::remove($this, $name);
+ return isset($this->data[$key]) || $this->parentIsSet($key);
}
}
diff --git a/src/Security/Passwords.php b/src/Security/Passwords.php
index cbb771e9..26ad2fb3 100644
--- a/src/Security/Passwords.php
+++ b/src/Security/Passwords.php
@@ -1,8 +1,8 @@
= 5.3.7.
- *
- * @author David Grudl
+ * Passwords tools.
*/
class Passwords
{
+ use Nette\StaticClass;
+
+ /** @deprecated */
const BCRYPT_COST = 10;
/**
* Computes salted password hash.
* @param string
- * @param array with cost (4-31), salt (22 chars)
+ * @param array with cost (4-31)
* @return string 60 chars long
*/
- public static function hash($password, array $options = NULL)
+ public static function hash($password, array $options = [])
{
- $cost = isset($options['cost']) ? (int) $options['cost'] : self::BCRYPT_COST;
- $salt = isset($options['salt']) ? (string) $options['salt'] : Nette\Utils\Random::generate(22, '0-9A-Za-z./');
-
- if (PHP_VERSION_ID < 50307) {
- throw new Nette\NotSupportedException(__METHOD__ . ' requires PHP >= 5.3.7.');
- } elseif (($len = strlen($salt)) < 22) {
- throw new Nette\InvalidArgumentException("Salt must be 22 characters long, $len given.");
- } elseif ($cost < 4 || $cost > 31) {
- throw new Nette\InvalidArgumentException("Cost must be in range 4-31, $cost given.");
+ if (isset($options['cost']) && ($options['cost'] < 4 || $options['cost'] > 31)) {
+ throw new Nette\InvalidArgumentException("Cost must be in range 4-31, $options[cost] given.");
}
- $hash = crypt($password, '$2y$' . ($cost < 10 ? 0 : '') . $cost . '$' . $salt);
- if (strlen($hash) < 60) {
- throw new Nette\InvalidStateException('Hash returned by crypt is invalid.');
+ $hash = password_hash($password, PASSWORD_BCRYPT, $options);
+ if ($hash === FALSE || strlen($hash) < 60) {
+ throw new Nette\InvalidStateException('Hash computed by password_hash is invalid.');
}
return $hash;
}
@@ -53,9 +47,7 @@ public static function hash($password, array $options = NULL)
*/
public static function verify($password, $hash)
{
- return preg_match('#^\$2y\$(?P\d\d)\$(?P.{22})#', $hash, $m)
- && $m['cost'] >= 4 && $m['cost'] <= 31
- && self::hash($password, $m) === $hash;
+ return password_verify($password, $hash);
}
@@ -65,11 +57,9 @@ public static function verify($password, $hash)
* @param array with cost (4-31)
* @return bool
*/
- public static function needsRehash($hash, array $options = NULL)
+ public static function needsRehash($hash, array $options = [])
{
- $cost = isset($options['cost']) ? (int) $options['cost'] : self::BCRYPT_COST;
- return !preg_match('#^\$2y\$(?P\d\d)\$(?P.{22})#', $hash, $m)
- || $m['cost'] < $cost;
+ return password_needs_rehash($hash, PASSWORD_BCRYPT, $options);
}
}
diff --git a/src/Security/Permission.php b/src/Security/Permission.php
index ca1ace7d..6e243ccb 100644
--- a/src/Security/Permission.php
+++ b/src/Security/Permission.php
@@ -1,8 +1,8 @@
array(
- 'allRoles' => array(
- 'allPrivileges' => array(
+ private $rules = [
+ 'allResources' => [
+ 'allRoles' => [
+ 'allPrivileges' => [
'type' => self::DENY,
'assert' => NULL,
- ),
- 'byPrivilege' => array(),
- ),
- 'byRole' => array(),
- ),
- 'byResource' => array(),
- );
+ ],
+ 'byPrivilege' => [],
+ ],
+ 'byRole' => [],
+ ],
+ 'byResource' => [],
+ ];
/** @var mixed */
private $queriedRole, $queriedResource;
@@ -69,11 +65,11 @@ public function addRole($role, $parents = NULL)
throw new Nette\InvalidStateException("Role '$role' already exists in the list.");
}
- $roleParents = array();
+ $roleParents = [];
if ($parents !== NULL) {
if (!is_array($parents)) {
- $parents = array($parents);
+ $parents = [$parents];
}
foreach ($parents as $parent) {
@@ -83,10 +79,10 @@ public function addRole($role, $parents = NULL)
}
}
- $this->roles[$role] = array(
- 'parents' => $roleParents,
- 'children' => array(),
- );
+ $this->roles[$role] = [
+ 'parents' => $roleParents,
+ 'children' => [],
+ ];
return $this;
}
@@ -222,7 +218,7 @@ public function removeRole($role)
*/
public function removeAllRoles()
{
- $this->roles = array();
+ $this->roles = [];
foreach ($this->rules['allResources']['byRole'] as $roleCurrent => $rules) {
unset($this->rules['allResources']['byRole'][$roleCurrent]);
@@ -263,10 +259,10 @@ public function addResource($resource, $parent = NULL)
$this->resources[$parent]['children'][$resource] = TRUE;
}
- $this->resources[$resource] = array(
- 'parent' => $parent,
- 'children' => array()
- );
+ $this->resources[$resource] = [
+ 'parent' => $parent,
+ 'children' => [],
+ ];
return $this;
}
@@ -366,7 +362,7 @@ public function removeResource($resource)
unset($this->resources[$parent]['children'][$resource]);
}
- $removed = array($resource);
+ $removed = [$resource];
foreach ($this->resources[$resource]['children'] as $child => $foo) {
$this->removeResource($child);
$removed[] = $child;
@@ -399,7 +395,7 @@ public function removeAllResources()
}
}
- $this->resources = array();
+ $this->resources = [];
return $this;
}
@@ -486,11 +482,11 @@ protected function setRule($toAdd, $type, $roles, $resources, $privileges, $asse
{
// ensure that all specified Roles exist; normalize input to array of Roles or NULL
if ($roles === self::ALL) {
- $roles = array(self::ALL);
+ $roles = [self::ALL];
} else {
if (!is_array($roles)) {
- $roles = array($roles);
+ $roles = [$roles];
}
foreach ($roles as $role) {
@@ -500,11 +496,11 @@ protected function setRule($toAdd, $type, $roles, $resources, $privileges, $asse
// ensure that all specified Resources exist; normalize input to array of Resources or NULL
if ($resources === self::ALL) {
- $resources = array(self::ALL);
+ $resources = [self::ALL];
} else {
if (!is_array($resources)) {
- $resources = array($resources);
+ $resources = [$resources];
}
foreach ($resources as $resource) {
@@ -514,10 +510,10 @@ protected function setRule($toAdd, $type, $roles, $resources, $privileges, $asse
// normalize privileges to array
if ($privileges === self::ALL) {
- $privileges = array();
+ $privileges = [];
} elseif (!is_array($privileges)) {
- $privileges = array($privileges);
+ $privileges = [$privileges];
}
if ($toAdd) { // add to the rules
@@ -528,7 +524,7 @@ protected function setRule($toAdd, $type, $roles, $resources, $privileges, $asse
$rules['allPrivileges']['type'] = $type;
$rules['allPrivileges']['assert'] = $assertion;
if (!isset($rules['byPrivilege'])) {
- $rules['byPrivilege'] = array();
+ $rules['byPrivilege'] = [];
}
} else {
foreach ($privileges as $privilege) {
@@ -549,13 +545,13 @@ protected function setRule($toAdd, $type, $roles, $resources, $privileges, $asse
if (count($privileges) === 0) {
if ($resource === self::ALL && $role === self::ALL) {
if ($type === $rules['allPrivileges']['type']) {
- $rules = array(
- 'allPrivileges' => array(
+ $rules = [
+ 'allPrivileges' => [
'type' => self::DENY,
- 'assert' => NULL
- ),
- 'byPrivilege' => array()
- );
+ 'assert' => NULL,
+ ],
+ 'byPrivilege' => [],
+ ];
}
continue;
}
@@ -681,10 +677,10 @@ public function getQueriedResource()
*/
private function searchRolePrivileges($all, $role, $resource, $privilege)
{
- $dfs = array(
- 'visited' => array(),
- 'stack' => array($role),
- );
+ $dfs = [
+ 'visited' => [],
+ 'stack' => [$role],
+ ];
while (NULL !== ($role = array_pop($dfs['stack']))) {
if (isset($dfs['visited'][$role])) {
@@ -778,7 +774,7 @@ private function & getRules($resource, $role, $create = FALSE)
if (!$create) {
return $null;
}
- $this->rules['byResource'][$resource] = array();
+ $this->rules['byResource'][$resource] = [];
}
$visitor = & $this->rules['byResource'][$resource];
}
@@ -788,7 +784,7 @@ private function & getRules($resource, $role, $create = FALSE)
if (!$create) {
return $null;
}
- $visitor['allRoles']['byPrivilege'] = array();
+ $visitor['allRoles']['byPrivilege'] = [];
}
return $visitor['allRoles'];
}
@@ -797,7 +793,7 @@ private function & getRules($resource, $role, $create = FALSE)
if (!$create) {
return $null;
}
- $visitor['byRole'][$role]['byPrivilege'] = array();
+ $visitor['byRole'][$role]['byPrivilege'] = [];
}
return $visitor['byRole'][$role];
diff --git a/src/Security/SimpleAuthenticator.php b/src/Security/SimpleAuthenticator.php
index 44492fd6..ac3dfeed 100644
--- a/src/Security/SimpleAuthenticator.php
+++ b/src/Security/SimpleAuthenticator.php
@@ -1,8 +1,8 @@
password
* @param array list of pairs username => role[]
*/
- public function __construct(array $userlist, array $usersRoles = array())
+ public function __construct(array $userlist, array $usersRoles = [])
{
$this->userlist = $userlist;
$this->usersRoles = $usersRoles;
diff --git a/src/Security/User.php b/src/Security/User.php
index e96209de..5872a0bb 100644
--- a/src/Security/User.php
+++ b/src/Security/User.php
@@ -1,8 +1,8 @@
isLoggedIn()) {
- return array($this->guestRole);
+ return [$this->guestRole];
}
$identity = $this->getIdentity();
- return $identity && $identity->getRoles() ? $identity->getRoles() : array($this->authenticatedRole);
+ return $identity && $identity->getRoles() ? $identity->getRoles() : [$this->authenticatedRole];
}
diff --git a/tests/.coveralls.yml b/tests/.coveralls.yml
new file mode 100644
index 00000000..82764a3f
--- /dev/null
+++ b/tests/.coveralls.yml
@@ -0,0 +1,4 @@
+# for php-coveralls
+service_name: travis-ci
+coverage_clover: coverage.xml
+json_path: coverage.json
diff --git a/tests/Security.DI/SecurityExtension.authenticator.phpt b/tests/Security.DI/SecurityExtension.authenticator.phpt
index 46938f13..e783f007 100644
--- a/tests/Security.DI/SecurityExtension.authenticator.phpt
+++ b/tests/Security.DI/SecurityExtension.authenticator.phpt
@@ -4,11 +4,11 @@
* Test: SecurityExtension
*/
-use Nette\DI,
- Nette\Bridges\HttpDI\HttpExtension,
- Nette\Bridges\HttpDI\SessionExtension,
- Nette\Bridges\SecurityDI\SecurityExtension,
- Tester\Assert;
+use Nette\DI;
+use Nette\Bridges\HttpDI\HttpExtension;
+use Nette\Bridges\HttpDI\SessionExtension;
+use Nette\Bridges\SecurityDI\SecurityExtension;
+use Tester\Assert;
require __DIR__ . '/../bootstrap.php';
@@ -29,28 +29,28 @@ security:
moderator: {password: moderator123, roles: moderator}
', 'neon'));
-eval($compiler->compile($config, 'Container1'));
-$container = new Container1;
+eval($compiler->addConfig($config)->compile());
+$container = new Container;
$authenticator = $container->getService('security.authenticator');
-Assert::type('Nette\Security\SimpleAuthenticator', $authenticator);
+Assert::type(Nette\Security\SimpleAuthenticator::class, $authenticator);
Assert::same($authenticator, $container->getService('nette.authenticator'));
-$userList = array(
+$userList = [
'john' => 'john123',
'admin' => 'admin123',
'user' => 'user123',
'moderator' => 'moderator123',
-);
-$expectedRoles = array(
- 'john' => array(),
- 'admin' => array('admin', 'user'),
- 'user' => array(),
- 'moderator' => array('moderator'),
-);
+];
+$expectedRoles = [
+ 'john' => [],
+ 'admin' => ['admin', 'user'],
+ 'user' => [],
+ 'moderator' => ['moderator'],
+];
foreach ($userList as $username => $password) {
- $identity = $authenticator->authenticate(array($username, $password));
+ $identity = $authenticator->authenticate([$username, $password]);
Assert::equal($username, $identity->getId());
Assert::equal($expectedRoles[$username], $identity->getRoles());
}
diff --git a/tests/Security.DI/SecurityExtension.user.phpt b/tests/Security.DI/SecurityExtension.user.phpt
index 4690919e..80c42e43 100644
--- a/tests/Security.DI/SecurityExtension.user.phpt
+++ b/tests/Security.DI/SecurityExtension.user.phpt
@@ -4,11 +4,11 @@
* Test: SecurityExtension
*/
-use Nette\DI,
- Nette\Bridges\HttpDI\HttpExtension,
- Nette\Bridges\HttpDI\SessionExtension,
- Nette\Bridges\SecurityDI\SecurityExtension,
- Tester\Assert;
+use Nette\DI;
+use Nette\Bridges\HttpDI\HttpExtension;
+use Nette\Bridges\HttpDI\SessionExtension;
+use Nette\Bridges\SecurityDI\SecurityExtension;
+use Tester\Assert;
require __DIR__ . '/../bootstrap.php';
@@ -19,11 +19,11 @@ $compiler->addExtension('foo', new HttpExtension);
$compiler->addExtension('bar', new SessionExtension);
$compiler->addExtension('security', new SecurityExtension);
-eval($compiler->compile(array(), 'Container1'));
-$container = new Container1;
+eval($compiler->compile());
+$container = new Container;
-Assert::type('Nette\Http\UserStorage', $container->getService('security.userStorage'));
-Assert::type('Nette\Security\User', $container->getService('security.user'));
+Assert::type(Nette\Http\UserStorage::class, $container->getService('security.userStorage'));
+Assert::type(Nette\Security\User::class, $container->getService('security.user'));
// aliases
Assert::same($container->getService('security.userStorage'), $container->getService('nette.userStorage'));
diff --git a/tests/Security/Identity.phpt b/tests/Security/Identity.phpt
index 62ab3671..1936f9f7 100644
--- a/tests/Security/Identity.phpt
+++ b/tests/Security/Identity.phpt
@@ -4,26 +4,27 @@
* Test: Nette\Security\Identity.
*/
-use Nette\Security\Identity,
- Tester\Assert;
+use Nette\Security\Identity;
+use Tester\Assert;
require __DIR__ . '/../bootstrap.php';
-test(function() {
- $id = new Identity(12, 'admin', array('name' => 'John'));
+test(function () {
+ $id = new Identity(12, 'admin', ['name' => 'John']);
Assert::same(12, $id->getId());
Assert::same(12, $id->id);
- Assert::same(array('admin'), $id->getRoles());
- Assert::same(array('admin'), $id->roles);
- Assert::same(array('name' => 'John'), $id->getData());
+ Assert::same(['admin'], $id->getRoles());
+ Assert::same(['admin'], $id->roles);
+ Assert::same(['name' => 'John'], $id->getData());
+ Assert::same(['name' => 'John'], $id->data);
Assert::same('John', $id->name);
});
-test(function() {
+test(function () {
$id = new Identity('12');
Assert::same(12, $id->getId());
diff --git a/tests/Security/MockUserStorage.php b/tests/Security/MockUserStorage.php
index 4a9824c7..57dc6b97 100644
--- a/tests/Security/MockUserStorage.php
+++ b/tests/Security/MockUserStorage.php
@@ -26,9 +26,10 @@ function getIdentity()
}
function setExpiration($time, $flags = 0)
- {}
+ {
+ }
function getLogoutReason()
- {}
-
+ {
+ }
}
diff --git a/tests/Security/Passwords.hash().phpt b/tests/Security/Passwords.hash().phpt
index af1e511c..dd1080a0 100644
--- a/tests/Security/Passwords.hash().phpt
+++ b/tests/Security/Passwords.hash().phpt
@@ -2,11 +2,10 @@
/**
* Test: Nette\Security\Passwords::hash()
- * @phpversion 5.3.7
*/
-use Nette\Security\Passwords,
- Tester\Assert;
+use Nette\Security\Passwords;
+use Tester\Assert;
require __DIR__ . '/../bootstrap.php';
@@ -18,23 +17,19 @@ Assert::truthy(
);
Assert::truthy(
- preg_match('#^\$2y\$05\$123456789012345678901.{32}\z#',
- $h = Passwords::hash('dg', array('cost' => 5, 'salt' => '1234567890123456789012')))
+ preg_match('#^\$2y\$05\$.{53}\z#',
+ $h = Passwords::hash('dg', ['cost' => 5]))
);
echo $h;
$hash = Passwords::hash('dg');
-Assert::same( $hash, crypt('dg', $hash) );
+Assert::same($hash, crypt('dg', $hash));
-Assert::exception(function() {
- Passwords::hash('dg', array('cost' => 3));
-}, 'Nette\InvalidArgumentException', 'Cost must be in range 4-31, 3 given.');
+Assert::exception(function () {
+ Passwords::hash('dg', ['cost' => 3]);
+}, Nette\InvalidArgumentException::class, 'Cost must be in range 4-31, 3 given.');
-Assert::exception(function() {
- Passwords::hash('dg', array('cost' => 32));
-}, 'Nette\InvalidArgumentException', 'Cost must be in range 4-31, 32 given.');
-
-Assert::exception(function() {
- Passwords::hash('dg', array('salt' => 'abc'));
-}, 'Nette\InvalidArgumentException', 'Salt must be 22 characters long, 3 given.');
+Assert::exception(function () {
+ Passwords::hash('dg', ['cost' => 32]);
+}, Nette\InvalidArgumentException::class, 'Cost must be in range 4-31, 32 given.');
diff --git a/tests/Security/Passwords.needsRehash().phpt b/tests/Security/Passwords.needsRehash().phpt
index d86a4ce5..4f3b9bc6 100644
--- a/tests/Security/Passwords.needsRehash().phpt
+++ b/tests/Security/Passwords.needsRehash().phpt
@@ -2,15 +2,14 @@
/**
* Test: Nette\Security\Passwords::needsRehash()
- * @phpversion 5.3.7
*/
-use Nette\Security\Passwords,
- Tester\Assert;
+use Nette\Security\Passwords;
+use Tester\Assert;
require __DIR__ . '/../bootstrap.php';
Assert::true(Passwords::needsRehash('$2y$05$123456789012345678901uTj3G.8OMqoqrOMca1z/iBLqLNaWe6DK'));
-Assert::false(Passwords::needsRehash('$2y$05$123456789012345678901uTj3G.8OMqoqrOMca1z/iBLqLNaWe6DK', array('cost' => 5)));
+Assert::false(Passwords::needsRehash('$2y$05$123456789012345678901uTj3G.8OMqoqrOMca1z/iBLqLNaWe6DK', ['cost' => 5]));
diff --git a/tests/Security/Passwords.verify().phpt b/tests/Security/Passwords.verify().phpt
index e2ad0ddf..b1d25dd7 100644
--- a/tests/Security/Passwords.verify().phpt
+++ b/tests/Security/Passwords.verify().phpt
@@ -2,16 +2,15 @@
/**
* Test: Nette\Security\Passwords::verify()
- * @phpversion 5.3.7
*/
-use Nette\Security\Passwords,
- Tester\Assert;
+use Nette\Security\Passwords;
+use Tester\Assert;
require __DIR__ . '/../bootstrap.php';
Assert::true(Passwords::verify('dg', '$2y$05$123456789012345678901uTj3G.8OMqoqrOMca1z/iBLqLNaWe6DK'));
-Assert::false(Passwords::verify('dg', '$2x$05$123456789012345678901uTj3G.8OMqoqrOMca1z/iBLqLNaWe6DK'));
+Assert::true(Passwords::verify('dg', '$2x$05$123456789012345678901uTj3G.8OMqoqrOMca1z/iBLqLNaWe6DK'));
Assert::false(Passwords::verify('dgx', '$2y$05$123456789012345678901uTj3G.8OMqoqrOMca1z/iBLqLNaWe6DK'));
diff --git a/tests/Security/Permission.CMSExample.phpt b/tests/Security/Permission.CMSExample.phpt
index b99598f4..19ac5ada 100644
--- a/tests/Security/Permission.CMSExample.phpt
+++ b/tests/Security/Permission.CMSExample.phpt
@@ -4,8 +4,8 @@
* Test: Nette\Security\Permission Ensures that an example for a content management system is operable.
*/
-use Nette\Security\Permission,
- Tester\Assert;
+use Nette\Security\Permission;
+use Tester\Assert;
require __DIR__ . '/../bootstrap.php';
@@ -21,55 +21,55 @@ $acl->addRole('administrator');
$acl->allow('guest', NULL, 'view');
// Staff inherits view privilege from guest, but also needs additional privileges
-$acl->allow('staff', NULL, array('edit', 'submit', 'revise'));
+$acl->allow('staff', NULL, ['edit', 'submit', 'revise']);
// Editor inherits view, edit, submit, and revise privileges, but also needs additional privileges
-$acl->allow('editor', NULL, array('publish', 'archive', 'delete'));
+$acl->allow('editor', NULL, ['publish', 'archive', 'delete']);
// Administrator inherits nothing but is allowed all privileges
$acl->allow('administrator');
// Access control checks based on above permission sets
-Assert::true( $acl->isAllowed('guest', NULL, 'view') );
-Assert::false( $acl->isAllowed('guest', NULL, 'edit') );
-Assert::false( $acl->isAllowed('guest', NULL, 'submit') );
-Assert::false( $acl->isAllowed('guest', NULL, 'revise') );
-Assert::false( $acl->isAllowed('guest', NULL, 'publish') );
-Assert::false( $acl->isAllowed('guest', NULL, 'archive') );
-Assert::false( $acl->isAllowed('guest', NULL, 'delete') );
-Assert::false( $acl->isAllowed('guest', NULL, 'unknown') );
-Assert::false( $acl->isAllowed('guest') );
-
-Assert::true( $acl->isAllowed('staff', NULL, 'view') );
-Assert::true( $acl->isAllowed('staff', NULL, 'edit') );
-Assert::true( $acl->isAllowed('staff', NULL, 'submit') );
-Assert::true( $acl->isAllowed('staff', NULL, 'revise') );
-Assert::false( $acl->isAllowed('staff', NULL, 'publish') );
-Assert::false( $acl->isAllowed('staff', NULL, 'archive') );
-Assert::false( $acl->isAllowed('staff', NULL, 'delete') );
-Assert::false( $acl->isAllowed('staff', NULL, 'unknown') );
-Assert::false( $acl->isAllowed('staff') );
-
-Assert::true( $acl->isAllowed('editor', NULL, 'view') );
-Assert::true( $acl->isAllowed('editor', NULL, 'edit') );
-Assert::true( $acl->isAllowed('editor', NULL, 'submit') );
-Assert::true( $acl->isAllowed('editor', NULL, 'revise') );
-Assert::true( $acl->isAllowed('editor', NULL, 'publish') );
-Assert::true( $acl->isAllowed('editor', NULL, 'archive') );
-Assert::true( $acl->isAllowed('editor', NULL, 'delete') );
-Assert::false( $acl->isAllowed('editor', NULL, 'unknown') );
-Assert::false( $acl->isAllowed('editor') );
-
-Assert::true( $acl->isAllowed('administrator', NULL, 'view') );
-Assert::true( $acl->isAllowed('administrator', NULL, 'edit') );
-Assert::true( $acl->isAllowed('administrator', NULL, 'submit') );
-Assert::true( $acl->isAllowed('administrator', NULL, 'revise') );
-Assert::true( $acl->isAllowed('administrator', NULL, 'publish') );
-Assert::true( $acl->isAllowed('administrator', NULL, 'archive') );
-Assert::true( $acl->isAllowed('administrator', NULL, 'delete') );
-Assert::true( $acl->isAllowed('administrator', NULL, 'unknown') );
-Assert::true( $acl->isAllowed('administrator') );
+Assert::true($acl->isAllowed('guest', NULL, 'view'));
+Assert::false($acl->isAllowed('guest', NULL, 'edit'));
+Assert::false($acl->isAllowed('guest', NULL, 'submit'));
+Assert::false($acl->isAllowed('guest', NULL, 'revise'));
+Assert::false($acl->isAllowed('guest', NULL, 'publish'));
+Assert::false($acl->isAllowed('guest', NULL, 'archive'));
+Assert::false($acl->isAllowed('guest', NULL, 'delete'));
+Assert::false($acl->isAllowed('guest', NULL, 'unknown'));
+Assert::false($acl->isAllowed('guest'));
+
+Assert::true($acl->isAllowed('staff', NULL, 'view'));
+Assert::true($acl->isAllowed('staff', NULL, 'edit'));
+Assert::true($acl->isAllowed('staff', NULL, 'submit'));
+Assert::true($acl->isAllowed('staff', NULL, 'revise'));
+Assert::false($acl->isAllowed('staff', NULL, 'publish'));
+Assert::false($acl->isAllowed('staff', NULL, 'archive'));
+Assert::false($acl->isAllowed('staff', NULL, 'delete'));
+Assert::false($acl->isAllowed('staff', NULL, 'unknown'));
+Assert::false($acl->isAllowed('staff'));
+
+Assert::true($acl->isAllowed('editor', NULL, 'view'));
+Assert::true($acl->isAllowed('editor', NULL, 'edit'));
+Assert::true($acl->isAllowed('editor', NULL, 'submit'));
+Assert::true($acl->isAllowed('editor', NULL, 'revise'));
+Assert::true($acl->isAllowed('editor', NULL, 'publish'));
+Assert::true($acl->isAllowed('editor', NULL, 'archive'));
+Assert::true($acl->isAllowed('editor', NULL, 'delete'));
+Assert::false($acl->isAllowed('editor', NULL, 'unknown'));
+Assert::false($acl->isAllowed('editor'));
+
+Assert::true($acl->isAllowed('administrator', NULL, 'view'));
+Assert::true($acl->isAllowed('administrator', NULL, 'edit'));
+Assert::true($acl->isAllowed('administrator', NULL, 'submit'));
+Assert::true($acl->isAllowed('administrator', NULL, 'revise'));
+Assert::true($acl->isAllowed('administrator', NULL, 'publish'));
+Assert::true($acl->isAllowed('administrator', NULL, 'archive'));
+Assert::true($acl->isAllowed('administrator', NULL, 'delete'));
+Assert::true($acl->isAllowed('administrator', NULL, 'unknown'));
+Assert::true($acl->isAllowed('administrator'));
// Some checks on specific areas, which inherit access controls from the root ACL node
$acl->addResource('newsletter');
@@ -78,14 +78,14 @@ $acl->addResource('gallery');
$acl->addResource('profiles', 'gallery');
$acl->addResource('config');
$acl->addResource('hosts', 'config');
-Assert::true( $acl->isAllowed('guest', 'pending', 'view') );
-Assert::true( $acl->isAllowed('staff', 'profiles', 'revise') );
-Assert::true( $acl->isAllowed('staff', 'pending', 'view') );
-Assert::true( $acl->isAllowed('staff', 'pending', 'edit') );
-Assert::false( $acl->isAllowed('staff', 'pending', 'publish') );
-Assert::false( $acl->isAllowed('staff', 'pending') );
-Assert::false( $acl->isAllowed('editor', 'hosts', 'unknown') );
-Assert::true( $acl->isAllowed('administrator', 'pending') );
+Assert::true($acl->isAllowed('guest', 'pending', 'view'));
+Assert::true($acl->isAllowed('staff', 'profiles', 'revise'));
+Assert::true($acl->isAllowed('staff', 'pending', 'view'));
+Assert::true($acl->isAllowed('staff', 'pending', 'edit'));
+Assert::false($acl->isAllowed('staff', 'pending', 'publish'));
+Assert::false($acl->isAllowed('staff', 'pending'));
+Assert::false($acl->isAllowed('editor', 'hosts', 'unknown'));
+Assert::true($acl->isAllowed('administrator', 'pending'));
// Add a new group, marketing, which bases its permissions on staff
$acl->addRole('marketing', 'staff');
@@ -93,12 +93,12 @@ $acl->addRole('marketing', 'staff');
// Refine the privilege sets for more specific needs
// Allow marketing to publish and archive newsletters
-$acl->allow('marketing', 'newsletter', array('publish', 'archive'));
+$acl->allow('marketing', 'newsletter', ['publish', 'archive']);
// Allow marketing to publish and archive latest news
$acl->addResource('news');
$acl->addResource('latest', 'news');
-$acl->allow('marketing', 'latest', array('publish', 'archive'));
+$acl->allow('marketing', 'latest', ['publish', 'archive']);
// Deny staff (and marketing, by inheritance) rights to revise latest news
$acl->deny('staff', 'latest', 'revise');
@@ -109,40 +109,40 @@ $acl->deny(NULL, 'announcement', 'archive');
// Access control checks for the above refined permission sets
-Assert::true( $acl->isAllowed('marketing', NULL, 'view') );
-Assert::true( $acl->isAllowed('marketing', NULL, 'edit') );
-Assert::true( $acl->isAllowed('marketing', NULL, 'submit') );
-Assert::true( $acl->isAllowed('marketing', NULL, 'revise') );
-Assert::false( $acl->isAllowed('marketing', NULL, 'publish') );
-Assert::false( $acl->isAllowed('marketing', NULL, 'archive') );
-Assert::false( $acl->isAllowed('marketing', NULL, 'delete') );
-Assert::false( $acl->isAllowed('marketing', NULL, 'unknown') );
-Assert::false( $acl->isAllowed('marketing') );
-
-Assert::true( $acl->isAllowed('marketing', 'newsletter', 'publish') );
-Assert::false( $acl->isAllowed('staff', 'pending', 'publish') );
-Assert::true( $acl->isAllowed('marketing', 'pending', 'publish') );
-Assert::true( $acl->isAllowed('marketing', 'newsletter', 'archive') );
-Assert::false( $acl->isAllowed('marketing', 'newsletter', 'delete') );
-Assert::false( $acl->isAllowed('marketing', 'newsletter') );
-
-Assert::true( $acl->isAllowed('marketing', 'latest', 'publish') );
-Assert::true( $acl->isAllowed('marketing', 'latest', 'archive') );
-Assert::false( $acl->isAllowed('marketing', 'latest', 'delete') );
-Assert::false( $acl->isAllowed('marketing', 'latest', 'revise') );
-Assert::false( $acl->isAllowed('marketing', 'latest') );
-
-Assert::false( $acl->isAllowed('marketing', 'announcement', 'archive') );
-Assert::false( $acl->isAllowed('staff', 'announcement', 'archive') );
-Assert::false( $acl->isAllowed('administrator', 'announcement', 'archive') );
-
-Assert::false( $acl->isAllowed('staff', 'latest', 'publish') );
-Assert::false( $acl->isAllowed('editor', 'announcement', 'archive') );
+Assert::true($acl->isAllowed('marketing', NULL, 'view'));
+Assert::true($acl->isAllowed('marketing', NULL, 'edit'));
+Assert::true($acl->isAllowed('marketing', NULL, 'submit'));
+Assert::true($acl->isAllowed('marketing', NULL, 'revise'));
+Assert::false($acl->isAllowed('marketing', NULL, 'publish'));
+Assert::false($acl->isAllowed('marketing', NULL, 'archive'));
+Assert::false($acl->isAllowed('marketing', NULL, 'delete'));
+Assert::false($acl->isAllowed('marketing', NULL, 'unknown'));
+Assert::false($acl->isAllowed('marketing'));
+
+Assert::true($acl->isAllowed('marketing', 'newsletter', 'publish'));
+Assert::false($acl->isAllowed('staff', 'pending', 'publish'));
+Assert::true($acl->isAllowed('marketing', 'pending', 'publish'));
+Assert::true($acl->isAllowed('marketing', 'newsletter', 'archive'));
+Assert::false($acl->isAllowed('marketing', 'newsletter', 'delete'));
+Assert::false($acl->isAllowed('marketing', 'newsletter'));
+
+Assert::true($acl->isAllowed('marketing', 'latest', 'publish'));
+Assert::true($acl->isAllowed('marketing', 'latest', 'archive'));
+Assert::false($acl->isAllowed('marketing', 'latest', 'delete'));
+Assert::false($acl->isAllowed('marketing', 'latest', 'revise'));
+Assert::false($acl->isAllowed('marketing', 'latest'));
+
+Assert::false($acl->isAllowed('marketing', 'announcement', 'archive'));
+Assert::false($acl->isAllowed('staff', 'announcement', 'archive'));
+Assert::false($acl->isAllowed('administrator', 'announcement', 'archive'));
+
+Assert::false($acl->isAllowed('staff', 'latest', 'publish'));
+Assert::false($acl->isAllowed('editor', 'announcement', 'archive'));
// Remove some previous permission specifications
// Marketing can no longer publish and archive newsletters
-$acl->removeAllow('marketing', 'newsletter', array('publish', 'archive'));
+$acl->removeAllow('marketing', 'newsletter', ['publish', 'archive']);
// Marketing can no longer archive the latest news
$acl->removeAllow('marketing', 'latest', 'archive');
@@ -152,19 +152,19 @@ $acl->removeDeny('staff', 'latest', 'revise');
// Access control checks for the above refinements
-Assert::false( $acl->isAllowed('marketing', 'newsletter', 'publish') );
-Assert::false( $acl->isAllowed('marketing', 'newsletter', 'archive') );
+Assert::false($acl->isAllowed('marketing', 'newsletter', 'publish'));
+Assert::false($acl->isAllowed('marketing', 'newsletter', 'archive'));
-Assert::false( $acl->isAllowed('marketing', 'latest', 'archive') );
+Assert::false($acl->isAllowed('marketing', 'latest', 'archive'));
-Assert::true( $acl->isAllowed('staff', 'latest', 'revise') );
-Assert::true( $acl->isAllowed('marketing', 'latest', 'revise') );
+Assert::true($acl->isAllowed('staff', 'latest', 'revise'));
+Assert::true($acl->isAllowed('marketing', 'latest', 'revise'));
// Grant marketing all permissions on the latest news
$acl->allow('marketing', 'latest');
// Access control checks for the above refinement
-Assert::true( $acl->isAllowed('marketing', 'latest', 'archive') );
-Assert::true( $acl->isAllowed('marketing', 'latest', 'publish') );
-Assert::true( $acl->isAllowed('marketing', 'latest', 'edit') );
-Assert::true( $acl->isAllowed('marketing', 'latest') );
+Assert::true($acl->isAllowed('marketing', 'latest', 'archive'));
+Assert::true($acl->isAllowed('marketing', 'latest', 'publish'));
+Assert::true($acl->isAllowed('marketing', 'latest', 'edit'));
+Assert::true($acl->isAllowed('marketing', 'latest'));
diff --git a/tests/Security/Permission.DefaultAssert.phpt b/tests/Security/Permission.DefaultAssert.phpt
index 97646b69..b0d3315e 100644
--- a/tests/Security/Permission.DefaultAssert.phpt
+++ b/tests/Security/Permission.DefaultAssert.phpt
@@ -4,8 +4,8 @@
* Test: Nette\Security\Permission Ensures that the default rule obeys its assertion.
*/
-use Nette\Security\Permission,
- Tester\Assert;
+use Nette\Security\Permission;
+use Tester\Assert;
require __DIR__ . '/../bootstrap.php';
@@ -19,4 +19,4 @@ function falseAssertion()
$acl = new Permission;
$acl->deny(NULL, NULL, NULL, 'falseAssertion');
-Assert::true( $acl->isAllowed(NULL, NULL, 'somePrivilege') );
+Assert::true($acl->isAllowed(NULL, NULL, 'somePrivilege'));
diff --git a/tests/Security/Permission.DefaultDeny.phpt b/tests/Security/Permission.DefaultDeny.phpt
index 31003737..2ac4a182 100644
--- a/tests/Security/Permission.DefaultDeny.phpt
+++ b/tests/Security/Permission.DefaultDeny.phpt
@@ -4,17 +4,17 @@
* Test: Nette\Security\Permission Ensures that by default denies access to everything by all.
*/
-use Nette\Security\Permission,
- Tester\Assert;
+use Nette\Security\Permission;
+use Tester\Assert;
require __DIR__ . '/../bootstrap.php';
$acl = new Permission;
-Assert::false( $acl->isAllowed() );
-Assert::false( $acl->isAllowed(NULL, NULL, 'somePrivilege') );
+Assert::false($acl->isAllowed());
+Assert::false($acl->isAllowed(NULL, NULL, 'somePrivilege'));
$acl->addRole('guest');
-Assert::false( $acl->isAllowed('guest') );
-Assert::false( $acl->isAllowed('guest', NULL, 'somePrivilege') );
+Assert::false($acl->isAllowed('guest'));
+Assert::false($acl->isAllowed('guest', NULL, 'somePrivilege'));
diff --git a/tests/Security/Permission.DefaultRuleSet.phpt b/tests/Security/Permission.DefaultRuleSet.phpt
index 6a2e612b..063218b1 100644
--- a/tests/Security/Permission.DefaultRuleSet.phpt
+++ b/tests/Security/Permission.DefaultRuleSet.phpt
@@ -4,8 +4,8 @@
* Test: Nette\Security\Permission Ensures that ACL-wide rules (all Roles, Resources, and privileges) work properly.
*/
-use Nette\Security\Permission,
- Tester\Assert;
+use Nette\Security\Permission;
+use Tester\Assert;
require __DIR__ . '/../bootstrap.php';
@@ -13,9 +13,9 @@ require __DIR__ . '/../bootstrap.php';
$acl = new Permission;
$acl->allow();
-Assert::true( $acl->isAllowed() );
-Assert::true( $acl->isAllowed(NULL, NULL, 'somePrivilege') );
+Assert::true($acl->isAllowed());
+Assert::true($acl->isAllowed(NULL, NULL, 'somePrivilege'));
$acl->deny();
-Assert::false( $acl->isAllowed() );
-Assert::false( $acl->isAllowed(NULL, NULL, 'somePrivilege') );
+Assert::false($acl->isAllowed());
+Assert::false($acl->isAllowed(NULL, NULL, 'somePrivilege'));
diff --git a/tests/Security/Permission.IsAllowedNonExistent.phpt b/tests/Security/Permission.IsAllowedNonExistent.phpt
index fd2b129f..433aea73 100644
--- a/tests/Security/Permission.IsAllowedNonExistent.phpt
+++ b/tests/Security/Permission.IsAllowedNonExistent.phpt
@@ -4,19 +4,19 @@
* Test: Nette\Security\Permission Ensures that an exception is thrown when a non-existent Role and Resource parameters are specified to isAllowed().
*/
-use Nette\Security\Permission,
- Tester\Assert;
+use Nette\Security\Permission;
+use Tester\Assert;
require __DIR__ . '/../bootstrap.php';
-Assert::exception(function() {
+Assert::exception(function () {
$acl = new Permission;
$acl->isAllowed('nonexistent');
-}, 'Nette\InvalidStateException', "Role 'nonexistent' does not exist.");
+}, Nette\InvalidStateException::class, "Role 'nonexistent' does not exist.");
-Assert::exception(function() {
+Assert::exception(function () {
$acl = new Permission;
$acl->isAllowed(NULL, 'nonexistent');
-}, 'Nette\InvalidStateException', "Resource 'nonexistent' does not exist.");
+}, Nette\InvalidStateException::class, "Resource 'nonexistent' does not exist.");
diff --git a/tests/Security/Permission.PrivilegeAllow.phpt b/tests/Security/Permission.PrivilegeAllow.phpt
index f93bd1ca..a5dd2141 100644
--- a/tests/Security/Permission.PrivilegeAllow.phpt
+++ b/tests/Security/Permission.PrivilegeAllow.phpt
@@ -4,8 +4,8 @@
* Test: Nette\Security\Permission Ensures that a privilege allowed for all Roles upon all Resources works properly.
*/
-use Nette\Security\Permission,
- Tester\Assert;
+use Nette\Security\Permission;
+use Tester\Assert;
require __DIR__ . '/../bootstrap.php';
@@ -13,4 +13,4 @@ require __DIR__ . '/../bootstrap.php';
$acl = new Permission;
$acl->allow(NULL, NULL, 'somePrivilege');
-Assert::true( $acl->isAllowed(NULL, NULL, 'somePrivilege') );
+Assert::true($acl->isAllowed(NULL, NULL, 'somePrivilege'));
diff --git a/tests/Security/Permission.PrivilegeAssert.phpt b/tests/Security/Permission.PrivilegeAssert.phpt
index 5a157bd6..557db609 100644
--- a/tests/Security/Permission.PrivilegeAssert.phpt
+++ b/tests/Security/Permission.PrivilegeAssert.phpt
@@ -4,8 +4,8 @@
* Test: Nette\Security\Permission Ensures that assertions on privileges work properly.
*/
-use Nette\Security\Permission,
- Tester\Assert;
+use Nette\Security\Permission;
+use Tester\Assert;
require __DIR__ . '/../bootstrap.php';
@@ -24,7 +24,7 @@ function trueAssertion()
$acl = new Permission;
$acl->allow(NULL, NULL, 'somePrivilege', 'trueAssertion');
-Assert::true( $acl->isAllowed(NULL, NULL, 'somePrivilege') );
+Assert::true($acl->isAllowed(NULL, NULL, 'somePrivilege'));
$acl->allow(NULL, NULL, 'somePrivilege', 'falseAssertion');
-Assert::false( $acl->isAllowed(NULL, NULL, 'somePrivilege') );
+Assert::false($acl->isAllowed(NULL, NULL, 'somePrivilege'));
diff --git a/tests/Security/Permission.PrivilegeDeny.phpt b/tests/Security/Permission.PrivilegeDeny.phpt
index 9d82d8cc..01d59d92 100644
--- a/tests/Security/Permission.PrivilegeDeny.phpt
+++ b/tests/Security/Permission.PrivilegeDeny.phpt
@@ -4,8 +4,8 @@
* Test: Nette\Security\Permission Ensures that a privilege denied for all Roles upon all Resources works properly.
*/
-use Nette\Security\Permission,
- Tester\Assert;
+use Nette\Security\Permission;
+use Tester\Assert;
require __DIR__ . '/../bootstrap.php';
@@ -14,4 +14,4 @@ require __DIR__ . '/../bootstrap.php';
$acl = new Permission;
$acl->allow();
$acl->deny(NULL, NULL, 'somePrivilege');
-Assert::false( $acl->isAllowed(NULL, NULL, 'somePrivilege') );
+Assert::false($acl->isAllowed(NULL, NULL, 'somePrivilege'));
diff --git a/tests/Security/Permission.Privileges.phpt b/tests/Security/Permission.Privileges.phpt
index 172990f7..0c95cbf4 100644
--- a/tests/Security/Permission.Privileges.phpt
+++ b/tests/Security/Permission.Privileges.phpt
@@ -4,21 +4,21 @@
* Test: Nette\Security\Permission Ensures that multiple privileges work properly.
*/
-use Nette\Security\Permission,
- Tester\Assert;
+use Nette\Security\Permission;
+use Tester\Assert;
require __DIR__ . '/../bootstrap.php';
$acl = new Permission;
-$acl->allow(NULL, NULL, array('p1', 'p2', 'p3'));
-Assert::true( $acl->isAllowed(NULL, NULL, 'p1') );
-Assert::true( $acl->isAllowed(NULL, NULL, 'p2') );
-Assert::true( $acl->isAllowed(NULL, NULL, 'p3') );
-Assert::false( $acl->isAllowed(NULL, NULL, 'p4') );
+$acl->allow(NULL, NULL, ['p1', 'p2', 'p3']);
+Assert::true($acl->isAllowed(NULL, NULL, 'p1'));
+Assert::true($acl->isAllowed(NULL, NULL, 'p2'));
+Assert::true($acl->isAllowed(NULL, NULL, 'p3'));
+Assert::false($acl->isAllowed(NULL, NULL, 'p4'));
$acl->deny(NULL, NULL, 'p1');
-Assert::false( $acl->isAllowed(NULL, NULL, 'p1') );
-$acl->deny(NULL, NULL, array('p2', 'p3'));
-Assert::false( $acl->isAllowed(NULL, NULL, 'p2') );
-Assert::false( $acl->isAllowed(NULL, NULL, 'p3') );
+Assert::false($acl->isAllowed(NULL, NULL, 'p1'));
+$acl->deny(NULL, NULL, ['p2', 'p3']);
+Assert::false($acl->isAllowed(NULL, NULL, 'p2'));
+Assert::false($acl->isAllowed(NULL, NULL, 'p3'));
diff --git a/tests/Security/Permission.RemoveDefaultAllow.phpt b/tests/Security/Permission.RemoveDefaultAllow.phpt
index 5745c4dc..975f04ab 100644
--- a/tests/Security/Permission.RemoveDefaultAllow.phpt
+++ b/tests/Security/Permission.RemoveDefaultAllow.phpt
@@ -4,8 +4,8 @@
* Test: Nette\Security\Permission Ensures that removing the default allow rule results in default deny rule being assigned.
*/
-use Nette\Security\Permission,
- Tester\Assert;
+use Nette\Security\Permission;
+use Tester\Assert;
require __DIR__ . '/../bootstrap.php';
@@ -13,6 +13,6 @@ require __DIR__ . '/../bootstrap.php';
$acl = new Permission;
$acl->allow();
-Assert::true( $acl->isAllowed() );
+Assert::true($acl->isAllowed());
$acl->removeAllow();
-Assert::false( $acl->isAllowed() );
+Assert::false($acl->isAllowed());
diff --git a/tests/Security/Permission.RemoveDefaultAllowNonExistent.phpt b/tests/Security/Permission.RemoveDefaultAllowNonExistent.phpt
index 21d0617d..72f58318 100644
--- a/tests/Security/Permission.RemoveDefaultAllowNonExistent.phpt
+++ b/tests/Security/Permission.RemoveDefaultAllowNonExistent.phpt
@@ -4,8 +4,8 @@
* Test: Nette\Security\Permission Ensures that removing non-existent default allow rule does nothing.
*/
-use Nette\Security\Permission,
- Tester\Assert;
+use Nette\Security\Permission;
+use Tester\Assert;
require __DIR__ . '/../bootstrap.php';
@@ -13,4 +13,4 @@ require __DIR__ . '/../bootstrap.php';
$acl = new Permission;
$acl->removeAllow();
-Assert::false( $acl->isAllowed() );
+Assert::false($acl->isAllowed());
diff --git a/tests/Security/Permission.RemoveDefaultDeny.phpt b/tests/Security/Permission.RemoveDefaultDeny.phpt
index 4a031214..291150b0 100644
--- a/tests/Security/Permission.RemoveDefaultDeny.phpt
+++ b/tests/Security/Permission.RemoveDefaultDeny.phpt
@@ -4,14 +4,14 @@
* Test: Nette\Security\Permission Ensures that removing the default deny rule results in default deny rule.
*/
-use Nette\Security\Permission,
- Tester\Assert;
+use Nette\Security\Permission;
+use Tester\Assert;
require __DIR__ . '/../bootstrap.php';
$acl = new Permission;
-Assert::false( $acl->isAllowed() );
+Assert::false($acl->isAllowed());
$acl->removeDeny();
-Assert::false( $acl->isAllowed() );
+Assert::false($acl->isAllowed());
diff --git a/tests/Security/Permission.RemoveDefaultDenyAssert.phpt b/tests/Security/Permission.RemoveDefaultDenyAssert.phpt
index b8ecd180..4fd7fe45 100644
--- a/tests/Security/Permission.RemoveDefaultDenyAssert.phpt
+++ b/tests/Security/Permission.RemoveDefaultDenyAssert.phpt
@@ -4,8 +4,8 @@
* Test: Nette\Security\Permission Ensures that removing the default deny rule results in assertion method being removed.
*/
-use Nette\Security\Permission,
- Tester\Assert;
+use Nette\Security\Permission;
+use Tester\Assert;
require __DIR__ . '/../bootstrap.php';
@@ -19,6 +19,6 @@ function falseAssertion()
$acl = new Permission;
$acl->deny(NULL, NULL, NULL, 'falseAssertion');
-Assert::true( $acl->isAllowed() );
+Assert::true($acl->isAllowed());
$acl->removeDeny();
-Assert::false( $acl->isAllowed() );
+Assert::false($acl->isAllowed());
diff --git a/tests/Security/Permission.RemoveDefaultDenyNonExistent.phpt b/tests/Security/Permission.RemoveDefaultDenyNonExistent.phpt
index 713d464a..76e88fcd 100644
--- a/tests/Security/Permission.RemoveDefaultDenyNonExistent.phpt
+++ b/tests/Security/Permission.RemoveDefaultDenyNonExistent.phpt
@@ -4,8 +4,8 @@
* Test: Nette\Security\Permission Ensures that removing non-existent default deny rule does nothing.
*/
-use Nette\Security\Permission,
- Tester\Assert;
+use Nette\Security\Permission;
+use Tester\Assert;
require __DIR__ . '/../bootstrap.php';
@@ -14,4 +14,4 @@ require __DIR__ . '/../bootstrap.php';
$acl = new Permission;
$acl->allow();
$acl->removeDeny();
-Assert::true( $acl->isAllowed() );
+Assert::true($acl->isAllowed());
diff --git a/tests/Security/Permission.RemovingRoleAfterItWasAllowedAccessToAllResources.phpt b/tests/Security/Permission.RemovingRoleAfterItWasAllowedAccessToAllResources.phpt
index d3ce326a..e5b5c1d4 100644
--- a/tests/Security/Permission.RemovingRoleAfterItWasAllowedAccessToAllResources.phpt
+++ b/tests/Security/Permission.RemovingRoleAfterItWasAllowedAccessToAllResources.phpt
@@ -5,8 +5,8 @@
* raise undefined index error.
*/
-use Nette\Security\Permission,
- Tester\Assert;
+use Nette\Security\Permission;
+use Tester\Assert;
require __DIR__ . '/../bootstrap.php';
@@ -24,4 +24,4 @@ $acl->allow(NULL,'Test','xxx');
$acl->removeRole('test0');
// Check after fix
-Assert::false( $acl->hasRole('test0') );
+Assert::false($acl->hasRole('test0'));
diff --git a/tests/Security/Permission.ResourceAddAndGetOne.phpt b/tests/Security/Permission.ResourceAddAndGetOne.phpt
index c34b6d93..92106ca6 100644
--- a/tests/Security/Permission.ResourceAddAndGetOne.phpt
+++ b/tests/Security/Permission.ResourceAddAndGetOne.phpt
@@ -4,18 +4,18 @@
* Test: Nette\Security\Permission Ensures that basic addition and retrieval of a single Resource works.
*/
-use Nette\Security\Permission,
- Tester\Assert;
+use Nette\Security\Permission;
+use Tester\Assert;
require __DIR__ . '/../bootstrap.php';
$acl = new Permission;
-Assert::false( $acl->hasResource('area') );
+Assert::false($acl->hasResource('area'));
$acl->addResource('area');
-Assert::true( $acl->hasResource('area') );
+Assert::true($acl->hasResource('area'));
$acl->removeResource('area');
-Assert::false( $acl->hasResource('area') );
+Assert::false($acl->hasResource('area'));
diff --git a/tests/Security/Permission.ResourceAddInheritsNonExistent.phpt b/tests/Security/Permission.ResourceAddInheritsNonExistent.phpt
index 1d599129..07db81eb 100644
--- a/tests/Security/Permission.ResourceAddInheritsNonExistent.phpt
+++ b/tests/Security/Permission.ResourceAddInheritsNonExistent.phpt
@@ -4,14 +4,14 @@
* Test: Nette\Security\Permission Ensures that an exception is thrown when a non-existent Resource is specified as a parent upon Resource addition.
*/
-use Nette\Security\Permission,
- Tester\Assert;
+use Nette\Security\Permission;
+use Tester\Assert;
require __DIR__ . '/../bootstrap.php';
$acl = new Permission;
-Assert::exception(function() use ($acl) {
+Assert::exception(function () use ($acl) {
$acl->addResource('area', 'nonexistent');
-}, 'Nette\InvalidStateException', "Resource 'nonexistent' does not exist.");
+}, Nette\InvalidStateException::class, "Resource 'nonexistent' does not exist.");
diff --git a/tests/Security/Permission.ResourceDuplicate.phpt b/tests/Security/Permission.ResourceDuplicate.phpt
index ea92f2e1..72359557 100644
--- a/tests/Security/Permission.ResourceDuplicate.phpt
+++ b/tests/Security/Permission.ResourceDuplicate.phpt
@@ -4,15 +4,15 @@
* Test: Nette\Security\Permission Ensures that the same Resource cannot be added more than once.
*/
-use Nette\Security\Permission,
- Tester\Assert;
+use Nette\Security\Permission;
+use Tester\Assert;
require __DIR__ . '/../bootstrap.php';
-Assert::exception(function() {
+Assert::exception(function () {
$acl = new Permission;
$acl->addResource('area');
$acl->addResource('area');
-}, 'Nette\InvalidStateException', "Resource 'area' already exists in the list.");
+}, Nette\InvalidStateException::class, "Resource 'area' already exists in the list.");
diff --git a/tests/Security/Permission.ResourceInherits.phpt b/tests/Security/Permission.ResourceInherits.phpt
index 46f12a8c..ff3c431d 100644
--- a/tests/Security/Permission.ResourceInherits.phpt
+++ b/tests/Security/Permission.ResourceInherits.phpt
@@ -4,8 +4,8 @@
* Test: Nette\Security\Permission Tests basic Resource inheritance.
*/
-use Nette\Security\Permission,
- Tester\Assert;
+use Nette\Security\Permission;
+use Tester\Assert;
require __DIR__ . '/../bootstrap.php';
@@ -16,14 +16,14 @@ $acl->addResource('city');
$acl->addResource('building', 'city');
$acl->addResource('room', 'building');
-Assert::same( array('city', 'building', 'room'), $acl->getResources() );
-Assert::true( $acl->resourceInheritsFrom('building', 'city', TRUE) );
-Assert::true( $acl->resourceInheritsFrom('room', 'building', TRUE) );
-Assert::true( $acl->resourceInheritsFrom('room', 'city') );
-Assert::false( $acl->resourceInheritsFrom('room', 'city', TRUE) );
-Assert::false( $acl->resourceInheritsFrom('city', 'building') );
-Assert::false( $acl->resourceInheritsFrom('building', 'room') );
-Assert::false( $acl->resourceInheritsFrom('city', 'room') );
+Assert::same(['city', 'building', 'room'], $acl->getResources());
+Assert::true($acl->resourceInheritsFrom('building', 'city', TRUE));
+Assert::true($acl->resourceInheritsFrom('room', 'building', TRUE));
+Assert::true($acl->resourceInheritsFrom('room', 'city'));
+Assert::false($acl->resourceInheritsFrom('room', 'city', TRUE));
+Assert::false($acl->resourceInheritsFrom('city', 'building'));
+Assert::false($acl->resourceInheritsFrom('building', 'room'));
+Assert::false($acl->resourceInheritsFrom('city', 'room'));
$acl->removeResource('building');
-Assert::false( $acl->hasResource('room') );
+Assert::false($acl->hasResource('room'));
diff --git a/tests/Security/Permission.ResourceInheritsNonExistent.phpt b/tests/Security/Permission.ResourceInheritsNonExistent.phpt
index 1ae3545b..b37cc5a1 100644
--- a/tests/Security/Permission.ResourceInheritsNonExistent.phpt
+++ b/tests/Security/Permission.ResourceInheritsNonExistent.phpt
@@ -4,8 +4,8 @@
* Test: Nette\Security\Permission Ensures that an exception is thrown when a non-existent Resource is specified to each parameter of inherits().
*/
-use Nette\Security\Permission,
- Tester\Assert;
+use Nette\Security\Permission;
+use Tester\Assert;
require __DIR__ . '/../bootstrap.php';
@@ -13,10 +13,10 @@ require __DIR__ . '/../bootstrap.php';
$acl = new Permission;
$acl->addResource('area');
-Assert::exception(function() use ($acl) {
+Assert::exception(function () use ($acl) {
$acl->resourceInheritsFrom('nonexistent', 'area');
-}, 'Nette\InvalidStateException', "Resource 'nonexistent' does not exist.");
+}, Nette\InvalidStateException::class, "Resource 'nonexistent' does not exist.");
-Assert::exception(function() use ($acl) {
+Assert::exception(function () use ($acl) {
$acl->resourceInheritsFrom('area', 'nonexistent');
-}, 'Nette\InvalidStateException', "Resource 'nonexistent' does not exist.");
+}, Nette\InvalidStateException::class, "Resource 'nonexistent' does not exist.");
diff --git a/tests/Security/Permission.ResourceRemoveAll.phpt b/tests/Security/Permission.ResourceRemoveAll.phpt
index 16401b61..15578931 100644
--- a/tests/Security/Permission.ResourceRemoveAll.phpt
+++ b/tests/Security/Permission.ResourceRemoveAll.phpt
@@ -4,8 +4,8 @@
* Test: Nette\Security\Permission Ensures that removal of all Resources works.
*/
-use Nette\Security\Permission,
- Tester\Assert;
+use Nette\Security\Permission;
+use Tester\Assert;
require __DIR__ . '/../bootstrap.php';
@@ -14,4 +14,4 @@ require __DIR__ . '/../bootstrap.php';
$acl = new Permission;
$acl->addResource('area');
$acl->removeAllResources();
-Assert::false( $acl->hasResource('area') );
+Assert::false($acl->hasResource('area'));
diff --git a/tests/Security/Permission.ResourceRemoveOneNonExistent.phpt b/tests/Security/Permission.ResourceRemoveOneNonExistent.phpt
index 2819116a..2bdeb8aa 100644
--- a/tests/Security/Permission.ResourceRemoveOneNonExistent.phpt
+++ b/tests/Security/Permission.ResourceRemoveOneNonExistent.phpt
@@ -4,14 +4,14 @@
* Test: Nette\Security\Permission Ensures that an exception is thrown when a non-existent Resource is specified for removal.
*/
-use Nette\Security\Permission,
- Tester\Assert;
+use Nette\Security\Permission;
+use Tester\Assert;
require __DIR__ . '/../bootstrap.php';
$acl = new Permission;
-Assert::exception(function() use ($acl) {
+Assert::exception(function () use ($acl) {
$acl->removeResource('nonexistent');
-}, 'Nette\InvalidStateException', "Resource 'nonexistent' does not exist.");
+}, Nette\InvalidStateException::class, "Resource 'nonexistent' does not exist.");
diff --git a/tests/Security/Permission.RoleDefaultAllowRuleWithPrivilegeDenyRule.phpt b/tests/Security/Permission.RoleDefaultAllowRuleWithPrivilegeDenyRule.phpt
index c655c63d..7658cdb4 100644
--- a/tests/Security/Permission.RoleDefaultAllowRuleWithPrivilegeDenyRule.phpt
+++ b/tests/Security/Permission.RoleDefaultAllowRuleWithPrivilegeDenyRule.phpt
@@ -5,8 +5,8 @@
* rule on the entire ACL.
*/
-use Nette\Security\Permission,
- Tester\Assert;
+use Nette\Security\Permission;
+use Tester\Assert;
require __DIR__ . '/../bootstrap.php';
@@ -17,5 +17,5 @@ $acl->addRole('guest');
$acl->addRole('staff', 'guest');
$acl->deny();
$acl->allow('staff');
-$acl->deny('staff', NULL, array('privilege1', 'privilege2'));
-Assert::false( $acl->isAllowed('staff', NULL, 'privilege1') );
+$acl->deny('staff', NULL, ['privilege1', 'privilege2']);
+Assert::false($acl->isAllowed('staff', NULL, 'privilege1'));
diff --git a/tests/Security/Permission.RoleDefaultAllowRuleWithResourceDenyRule.phpt b/tests/Security/Permission.RoleDefaultAllowRuleWithResourceDenyRule.phpt
index ccfa447f..f28e715b 100644
--- a/tests/Security/Permission.RoleDefaultAllowRuleWithResourceDenyRule.phpt
+++ b/tests/Security/Permission.RoleDefaultAllowRuleWithResourceDenyRule.phpt
@@ -2,11 +2,11 @@
/**
* Test: Nette\Security\Permission Ensures that for a particular Role, a deny rule on a specific Resource is honored before an allow rule
-* on the entire ACL.
+ * on the entire ACL.
*/
-use Nette\Security\Permission,
- Tester\Assert;
+use Nette\Security\Permission;
+use Tester\Assert;
require __DIR__ . '/../bootstrap.php';
@@ -19,5 +19,5 @@ $acl->addResource('area1');
$acl->addResource('area2');
$acl->deny();
$acl->allow('staff');
-$acl->deny('staff', array('area1', 'area2'));
-Assert::false( $acl->isAllowed('staff', 'area1') );
+$acl->deny('staff', ['area1', 'area2']);
+Assert::false($acl->isAllowed('staff', 'area1'));
diff --git a/tests/Security/Permission.RoleDefaultRuleSet.phpt b/tests/Security/Permission.RoleDefaultRuleSet.phpt
index bc84c751..05fe4234 100644
--- a/tests/Security/Permission.RoleDefaultRuleSet.phpt
+++ b/tests/Security/Permission.RoleDefaultRuleSet.phpt
@@ -4,8 +4,8 @@
* Test: Nette\Security\Permission Ensures that ACL-wide rules (all Resources and privileges) work properly for a particular Role.
*/
-use Nette\Security\Permission,
- Tester\Assert;
+use Nette\Security\Permission;
+use Tester\Assert;
require __DIR__ . '/../bootstrap.php';
@@ -14,6 +14,6 @@ require __DIR__ . '/../bootstrap.php';
$acl = new Permission;
$acl->addRole('guest');
$acl->allow('guest');
-Assert::true( $acl->isAllowed('guest') );
+Assert::true($acl->isAllowed('guest'));
$acl->deny('guest');
-Assert::false( $acl->isAllowed('guest') );
+Assert::false($acl->isAllowed('guest'));
diff --git a/tests/Security/Permission.RoleDefaultRuleSetPrivilege.phpt b/tests/Security/Permission.RoleDefaultRuleSetPrivilege.phpt
index fc1c39e5..2e49c9e1 100644
--- a/tests/Security/Permission.RoleDefaultRuleSetPrivilege.phpt
+++ b/tests/Security/Permission.RoleDefaultRuleSetPrivilege.phpt
@@ -4,8 +4,8 @@
* Test: Nette\Security\Permission Ensures that ACL-wide rules apply to privileges for a particular Role.
*/
-use Nette\Security\Permission,
- Tester\Assert;
+use Nette\Security\Permission;
+use Tester\Assert;
require __DIR__ . '/../bootstrap.php';
@@ -14,6 +14,6 @@ require __DIR__ . '/../bootstrap.php';
$acl = new Permission;
$acl->addRole('guest');
$acl->allow('guest');
-Assert::true( $acl->isAllowed('guest', NULL, 'somePrivilege') );
+Assert::true($acl->isAllowed('guest', NULL, 'somePrivilege'));
$acl->deny('guest');
-Assert::false( $acl->isAllowed('guest', NULL, 'somePrivilege') );
+Assert::false($acl->isAllowed('guest', NULL, 'somePrivilege'));
diff --git a/tests/Security/Permission.RolePrivilegeAllow.phpt b/tests/Security/Permission.RolePrivilegeAllow.phpt
index a1602693..61bcc179 100644
--- a/tests/Security/Permission.RolePrivilegeAllow.phpt
+++ b/tests/Security/Permission.RolePrivilegeAllow.phpt
@@ -4,8 +4,8 @@
* Test: Nette\Security\Permission Ensures that a privilege allowed for a particular Role upon all Resources works properly.
*/
-use Nette\Security\Permission,
- Tester\Assert;
+use Nette\Security\Permission;
+use Tester\Assert;
require __DIR__ . '/../bootstrap.php';
@@ -14,4 +14,4 @@ require __DIR__ . '/../bootstrap.php';
$acl = new Permission;
$acl->addRole('guest');
$acl->allow('guest', NULL, 'somePrivilege');
-Assert::true( $acl->isAllowed('guest', NULL, 'somePrivilege') );
+Assert::true($acl->isAllowed('guest', NULL, 'somePrivilege'));
diff --git a/tests/Security/Permission.RolePrivilegeAssert.phpt b/tests/Security/Permission.RolePrivilegeAssert.phpt
index 0751f135..0b31e0f2 100644
--- a/tests/Security/Permission.RolePrivilegeAssert.phpt
+++ b/tests/Security/Permission.RolePrivilegeAssert.phpt
@@ -4,8 +4,8 @@
* Test: Nette\Security\Permission Ensures that assertions on privileges work properly for a particular Role.
*/
-use Nette\Security\Permission,
- Tester\Assert;
+use Nette\Security\Permission;
+use Tester\Assert;
require __DIR__ . '/../bootstrap.php';
@@ -25,6 +25,6 @@ function trueAssertion()
$acl = new Permission;
$acl->addRole('guest');
$acl->allow('guest', NULL, 'somePrivilege', 'trueAssertion');
-Assert::true( $acl->isAllowed('guest', NULL, 'somePrivilege') );
+Assert::true($acl->isAllowed('guest', NULL, 'somePrivilege'));
$acl->allow('guest', NULL, 'somePrivilege', 'falseAssertion');
-Assert::false( $acl->isAllowed('guest', NULL, 'somePrivilege') );
+Assert::false($acl->isAllowed('guest', NULL, 'somePrivilege'));
diff --git a/tests/Security/Permission.RolePrivilegeDeny.phpt b/tests/Security/Permission.RolePrivilegeDeny.phpt
index 06a91395..03988147 100644
--- a/tests/Security/Permission.RolePrivilegeDeny.phpt
+++ b/tests/Security/Permission.RolePrivilegeDeny.phpt
@@ -4,8 +4,8 @@
* Test: Nette\Security\Permission Ensures that a privilege denied for a particular Role upon all Resources works properly.
*/
-use Nette\Security\Permission,
- Tester\Assert;
+use Nette\Security\Permission;
+use Tester\Assert;
require __DIR__ . '/../bootstrap.php';
@@ -15,4 +15,4 @@ $acl = new Permission;
$acl->addRole('guest');
$acl->allow('guest');
$acl->deny('guest', NULL, 'somePrivilege');
-Assert::false( $acl->isAllowed('guest', NULL, 'somePrivilege') );
+Assert::false($acl->isAllowed('guest', NULL, 'somePrivilege'));
diff --git a/tests/Security/Permission.RolePrivileges.phpt b/tests/Security/Permission.RolePrivileges.phpt
index 04538715..0dca08a1 100644
--- a/tests/Security/Permission.RolePrivileges.phpt
+++ b/tests/Security/Permission.RolePrivileges.phpt
@@ -4,8 +4,8 @@
* Test: Nette\Security\Permission Ensures that multiple privileges work properly for a particular Role.
*/
-use Nette\Security\Permission,
- Tester\Assert;
+use Nette\Security\Permission;
+use Tester\Assert;
require __DIR__ . '/../bootstrap.php';
@@ -13,13 +13,13 @@ require __DIR__ . '/../bootstrap.php';
$acl = new Permission;
$acl->addRole('guest');
-$acl->allow('guest', NULL, array('p1', 'p2', 'p3'));
-Assert::true( $acl->isAllowed('guest', NULL, 'p1') );
-Assert::true( $acl->isAllowed('guest', NULL, 'p2') );
-Assert::true( $acl->isAllowed('guest', NULL, 'p3') );
-Assert::false( $acl->isAllowed('guest', NULL, 'p4') );
+$acl->allow('guest', NULL, ['p1', 'p2', 'p3']);
+Assert::true($acl->isAllowed('guest', NULL, 'p1'));
+Assert::true($acl->isAllowed('guest', NULL, 'p2'));
+Assert::true($acl->isAllowed('guest', NULL, 'p3'));
+Assert::false($acl->isAllowed('guest', NULL, 'p4'));
$acl->deny('guest', NULL, 'p1');
-Assert::false( $acl->isAllowed('guest', NULL, 'p1') );
-$acl->deny('guest', NULL, array('p2', 'p3'));
-Assert::false( $acl->isAllowed('guest', NULL, 'p2') );
-Assert::false( $acl->isAllowed('guest', NULL, 'p3') );
+Assert::false($acl->isAllowed('guest', NULL, 'p1'));
+$acl->deny('guest', NULL, ['p2', 'p3']);
+Assert::false($acl->isAllowed('guest', NULL, 'p2'));
+Assert::false($acl->isAllowed('guest', NULL, 'p3'));
diff --git a/tests/Security/Permission.RoleRegistryAddAndGetOne.phpt b/tests/Security/Permission.RoleRegistryAddAndGetOne.phpt
index c7617fc5..82f5f03a 100644
--- a/tests/Security/Permission.RoleRegistryAddAndGetOne.phpt
+++ b/tests/Security/Permission.RoleRegistryAddAndGetOne.phpt
@@ -4,18 +4,18 @@
* Test: Nette\Security\Permission Ensures that basic addition and retrieval of a single Role works.
*/
-use Nette\Security\Permission,
- Tester\Assert;
+use Nette\Security\Permission;
+use Tester\Assert;
require __DIR__ . '/../bootstrap.php';
$acl = new Permission;
-Assert::false( $acl->hasRole('guest') );
+Assert::false($acl->hasRole('guest'));
$acl->addRole('guest');
-Assert::true( $acl->hasRole('guest') );
+Assert::true($acl->hasRole('guest'));
$acl->removeRole('guest');
-Assert::false( $acl->hasRole('guest') );
+Assert::false($acl->hasRole('guest'));
diff --git a/tests/Security/Permission.RoleRegistryAddInheritsNonExistent.phpt b/tests/Security/Permission.RoleRegistryAddInheritsNonExistent.phpt
index 928a54e0..b49637ce 100644
--- a/tests/Security/Permission.RoleRegistryAddInheritsNonExistent.phpt
+++ b/tests/Security/Permission.RoleRegistryAddInheritsNonExistent.phpt
@@ -4,14 +4,14 @@
* Test: Nette\Security\Permission Ensures that an exception is thrown when a non-existent Role is specified as a parent upon Role addition.
*/
-use Nette\Security\Permission,
- Tester\Assert;
+use Nette\Security\Permission;
+use Tester\Assert;
require __DIR__ . '/../bootstrap.php';
$acl = new Permission;
-Assert::exception(function() use ($acl) {
+Assert::exception(function () use ($acl) {
$acl->addRole('guest', 'nonexistent');
-}, 'Nette\InvalidStateException', "Role 'nonexistent' does not exist.");
+}, Nette\InvalidStateException::class, "Role 'nonexistent' does not exist.");
diff --git a/tests/Security/Permission.RoleRegistryDuplicate.phpt b/tests/Security/Permission.RoleRegistryDuplicate.phpt
index 97adde8c..f569239c 100644
--- a/tests/Security/Permission.RoleRegistryDuplicate.phpt
+++ b/tests/Security/Permission.RoleRegistryDuplicate.phpt
@@ -4,15 +4,15 @@
* Test: Nette\Security\Permission Ensures that the same Role cannot be registered more than once to the registry.
*/
-use Nette\Security\Permission,
- Tester\Assert;
+use Nette\Security\Permission;
+use Tester\Assert;
require __DIR__ . '/../bootstrap.php';
$acl = new Permission;
-Assert::exception(function() use ($acl) {
+Assert::exception(function () use ($acl) {
$acl->addRole('guest');
$acl->addRole('guest');
-}, 'Nette\InvalidStateException', "Role 'guest' already exists in the list.");
+}, Nette\InvalidStateException::class, "Role 'guest' already exists in the list.");
diff --git a/tests/Security/Permission.RoleRegistryInherits.phpt b/tests/Security/Permission.RoleRegistryInherits.phpt
index bd2866d3..1e2ae6c7 100644
--- a/tests/Security/Permission.RoleRegistryInherits.phpt
+++ b/tests/Security/Permission.RoleRegistryInherits.phpt
@@ -4,8 +4,8 @@
* Test: Nette\Security\Permission Tests basic Role inheritance.
*/
-use Nette\Security\Permission,
- Tester\Assert;
+use Nette\Security\Permission;
+use Tester\Assert;
require __DIR__ . '/../bootstrap.php';
@@ -15,20 +15,20 @@ $acl = new Permission;
$acl->addRole('guest');
$acl->addRole('member', 'guest');
$acl->addRole('editor', 'member');
-Assert::same( array('guest', 'member', 'editor'), $acl->getRoles() );
-Assert::same( array(), $acl->getRoleParents('guest') );
-Assert::same( array('guest'), $acl->getRoleParents('member') );
-Assert::same( array('member'), $acl->getRoleParents('editor') );
+Assert::same(['guest', 'member', 'editor'], $acl->getRoles());
+Assert::same([], $acl->getRoleParents('guest'));
+Assert::same(['guest'], $acl->getRoleParents('member'));
+Assert::same(['member'], $acl->getRoleParents('editor'));
-Assert::true( $acl->roleInheritsFrom('member', 'guest', TRUE) );
-Assert::true( $acl->roleInheritsFrom('editor', 'member', TRUE) );
-Assert::true( $acl->roleInheritsFrom('editor', 'guest') );
-Assert::false( $acl->roleInheritsFrom('editor', 'guest', TRUE) );
-Assert::false( $acl->roleInheritsFrom('guest', 'member') );
-Assert::false( $acl->roleInheritsFrom('member', 'editor') );
-Assert::false( $acl->roleInheritsFrom('guest', 'editor') );
+Assert::true($acl->roleInheritsFrom('member', 'guest', TRUE));
+Assert::true($acl->roleInheritsFrom('editor', 'member', TRUE));
+Assert::true($acl->roleInheritsFrom('editor', 'guest'));
+Assert::false($acl->roleInheritsFrom('editor', 'guest', TRUE));
+Assert::false($acl->roleInheritsFrom('guest', 'member'));
+Assert::false($acl->roleInheritsFrom('member', 'editor'));
+Assert::false($acl->roleInheritsFrom('guest', 'editor'));
$acl->removeRole('member');
-Assert::same( array(), $acl->getRoleParents('editor') );
-Assert::false( $acl->roleInheritsFrom('editor', 'guest') );
+Assert::same([], $acl->getRoleParents('editor'));
+Assert::false($acl->roleInheritsFrom('editor', 'guest'));
diff --git a/tests/Security/Permission.RoleRegistryInheritsMultiple.phpt b/tests/Security/Permission.RoleRegistryInheritsMultiple.phpt
index 2d64ffc1..c4e8a407 100644
--- a/tests/Security/Permission.RoleRegistryInheritsMultiple.phpt
+++ b/tests/Security/Permission.RoleRegistryInheritsMultiple.phpt
@@ -4,8 +4,8 @@
* Test: Nette\Security\Permission Tests basic Role multiple inheritance.
*/
-use Nette\Security\Permission,
- Tester\Assert;
+use Nette\Security\Permission;
+use Tester\Assert;
require __DIR__ . '/../bootstrap.php';
@@ -14,17 +14,17 @@ require __DIR__ . '/../bootstrap.php';
$acl = new Permission;
$acl->addRole('parent1');
$acl->addRole('parent2');
-$acl->addRole('child', array('parent1', 'parent2'));
+$acl->addRole('child', ['parent1', 'parent2']);
-Assert::same( array(
+Assert::same([
'parent1',
'parent2',
-), $acl->getRoleParents('child') );
+], $acl->getRoleParents('child'));
-Assert::true( $acl->roleInheritsFrom('child', 'parent1') );
-Assert::true( $acl->roleInheritsFrom('child', 'parent2') );
+Assert::true($acl->roleInheritsFrom('child', 'parent1'));
+Assert::true($acl->roleInheritsFrom('child', 'parent2'));
$acl->removeRole('parent1');
-Assert::same( array('parent2'), $acl->getRoleParents('child') );
-Assert::true( $acl->roleInheritsFrom('child', 'parent2') );
+Assert::same(['parent2'], $acl->getRoleParents('child'));
+Assert::true($acl->roleInheritsFrom('child', 'parent2'));
diff --git a/tests/Security/Permission.RoleRegistryInheritsNonExistent.phpt b/tests/Security/Permission.RoleRegistryInheritsNonExistent.phpt
index 462f980c..3365ce1f 100644
--- a/tests/Security/Permission.RoleRegistryInheritsNonExistent.phpt
+++ b/tests/Security/Permission.RoleRegistryInheritsNonExistent.phpt
@@ -4,8 +4,8 @@
* Test: Nette\Security\Permission Ensures that an exception is thrown when a non-existent Role is specified to each parameter of inherits().
*/
-use Nette\Security\Permission,
- Tester\Assert;
+use Nette\Security\Permission;
+use Tester\Assert;
require __DIR__ . '/../bootstrap.php';
@@ -13,10 +13,10 @@ require __DIR__ . '/../bootstrap.php';
$acl = new Permission;
$acl->addRole('guest');
-Assert::exception(function() use ($acl) {
+Assert::exception(function () use ($acl) {
$acl->roleInheritsFrom('nonexistent', 'guest');
-}, 'Nette\InvalidStateException', "Role 'nonexistent' does not exist.");
+}, Nette\InvalidStateException::class, "Role 'nonexistent' does not exist.");
-Assert::exception(function() use ($acl) {
+Assert::exception(function () use ($acl) {
$acl->roleInheritsFrom('guest', 'nonexistent');
-}, 'Nette\InvalidStateException', "Role 'nonexistent' does not exist.");
+}, Nette\InvalidStateException::class, "Role 'nonexistent' does not exist.");
diff --git a/tests/Security/Permission.RoleRegistryRemoveAll.phpt b/tests/Security/Permission.RoleRegistryRemoveAll.phpt
index 9fbc25af..d7334f94 100644
--- a/tests/Security/Permission.RoleRegistryRemoveAll.phpt
+++ b/tests/Security/Permission.RoleRegistryRemoveAll.phpt
@@ -4,8 +4,8 @@
* Test: Nette\Security\Permission Ensures that removal of all Roles works.
*/
-use Nette\Security\Permission,
- Tester\Assert;
+use Nette\Security\Permission;
+use Tester\Assert;
require __DIR__ . '/../bootstrap.php';
@@ -14,4 +14,4 @@ require __DIR__ . '/../bootstrap.php';
$acl = new Permission;
$acl->addRole('guest');
$acl->removeAllRoles();
-Assert::false( $acl->hasRole('guest') );
+Assert::false($acl->hasRole('guest'));
diff --git a/tests/Security/Permission.RoleRegistryRemoveOneNonExistent.phpt b/tests/Security/Permission.RoleRegistryRemoveOneNonExistent.phpt
index a232ba27..db037840 100644
--- a/tests/Security/Permission.RoleRegistryRemoveOneNonExistent.phpt
+++ b/tests/Security/Permission.RoleRegistryRemoveOneNonExistent.phpt
@@ -4,14 +4,14 @@
* Test: Nette\Security\Permission Ensures that an exception is thrown when a non-existent Role is specified for removal.
*/
-use Nette\Security\Permission,
- Tester\Assert;
+use Nette\Security\Permission;
+use Tester\Assert;
require __DIR__ . '/../bootstrap.php';
$acl = new Permission;
-Assert::exception(function() use ($acl) {
+Assert::exception(function () use ($acl) {
$acl->removeRole('nonexistent');
-}, 'Nette\InvalidStateException', "Role 'nonexistent' does not exist.");
+}, Nette\InvalidStateException::class, "Role 'nonexistent' does not exist.");
diff --git a/tests/Security/Permission.RuleRoleRemove.phpt b/tests/Security/Permission.RuleRoleRemove.phpt
index 26ecb1cd..c170ed2a 100644
--- a/tests/Security/Permission.RuleRoleRemove.phpt
+++ b/tests/Security/Permission.RuleRoleRemove.phpt
@@ -4,8 +4,8 @@
* Test: Nette\Security\Permission Ensures that removal of a Role results in its rules being removed.
*/
-use Nette\Security\Permission,
- Tester\Assert;
+use Nette\Security\Permission;
+use Tester\Assert;
require __DIR__ . '/../bootstrap.php';
@@ -14,11 +14,11 @@ require __DIR__ . '/../bootstrap.php';
$acl = new Permission;
$acl->addRole('guest');
$acl->allow('guest');
-Assert::true( $acl->isAllowed('guest') );
+Assert::true($acl->isAllowed('guest'));
$acl->removeRole('guest');
-Assert::exception(function() use ($acl) {
+Assert::exception(function () use ($acl) {
$acl->isAllowed('guest');
-}, 'Nette\InvalidStateException', "Role 'guest' does not exist.");
+}, Nette\InvalidStateException::class, "Role 'guest' does not exist.");
$acl->addRole('guest');
-Assert::false( $acl->isAllowed('guest') );
+Assert::false($acl->isAllowed('guest'));
diff --git a/tests/Security/Permission.RuleRoleRemoveAll.phpt b/tests/Security/Permission.RuleRoleRemoveAll.phpt
index 00719d58..b30a8bf9 100644
--- a/tests/Security/Permission.RuleRoleRemoveAll.phpt
+++ b/tests/Security/Permission.RuleRoleRemoveAll.phpt
@@ -4,8 +4,8 @@
* Test: Nette\Security\Permission Ensures that removal of all Roles results in Role-specific rules being removed.
*/
-use Nette\Security\Permission,
- Tester\Assert;
+use Nette\Security\Permission;
+use Tester\Assert;
require __DIR__ . '/../bootstrap.php';
@@ -14,11 +14,11 @@ require __DIR__ . '/../bootstrap.php';
$acl = new Permission;
$acl->addRole('guest');
$acl->allow('guest');
-Assert::true( $acl->isAllowed('guest') );
+Assert::true($acl->isAllowed('guest'));
$acl->removeAllRoles();
-Assert::exception(function() use ($acl) {
+Assert::exception(function () use ($acl) {
$acl->isAllowed('guest');
-}, 'Nette\InvalidStateException', "Role 'guest' does not exist.");
+}, Nette\InvalidStateException::class, "Role 'guest' does not exist.");
$acl->addRole('guest');
-Assert::false( $acl->isAllowed('guest') );
+Assert::false($acl->isAllowed('guest'));
diff --git a/tests/Security/Permission.RulesRemove.phpt b/tests/Security/Permission.RulesRemove.phpt
index 91910a01..d5119200 100644
--- a/tests/Security/Permission.RulesRemove.phpt
+++ b/tests/Security/Permission.RulesRemove.phpt
@@ -4,18 +4,18 @@
* Test: Nette\Security\Permission Ensure that basic rule removal works.
*/
-use Nette\Security\Permission,
- Tester\Assert;
+use Nette\Security\Permission;
+use Tester\Assert;
require __DIR__ . '/../bootstrap.php';
$acl = new Permission;
-$acl->allow(NULL, NULL, array('privilege1', 'privilege2'));
-Assert::false( $acl->isAllowed() );
-Assert::true( $acl->isAllowed(NULL, NULL, 'privilege1') );
-Assert::true( $acl->isAllowed(NULL, NULL, 'privilege2') );
+$acl->allow(NULL, NULL, ['privilege1', 'privilege2']);
+Assert::false($acl->isAllowed());
+Assert::true($acl->isAllowed(NULL, NULL, 'privilege1'));
+Assert::true($acl->isAllowed(NULL, NULL, 'privilege2'));
$acl->removeAllow(NULL, NULL, 'privilege1');
-Assert::false( $acl->isAllowed(NULL, NULL, 'privilege1') );
-Assert::true( $acl->isAllowed(NULL, NULL, 'privilege2') );
+Assert::false($acl->isAllowed(NULL, NULL, 'privilege1'));
+Assert::true($acl->isAllowed(NULL, NULL, 'privilege2'));
diff --git a/tests/Security/Permission.RulesResourceRemove.phpt b/tests/Security/Permission.RulesResourceRemove.phpt
index 078ded22..1e9b7c28 100644
--- a/tests/Security/Permission.RulesResourceRemove.phpt
+++ b/tests/Security/Permission.RulesResourceRemove.phpt
@@ -4,8 +4,8 @@
* Test: Nette\Security\Permission Ensures that removal of a Resource results in its rules being removed.
*/
-use Nette\Security\Permission,
- Tester\Assert;
+use Nette\Security\Permission;
+use Tester\Assert;
require __DIR__ . '/../bootstrap.php';
@@ -14,11 +14,11 @@ require __DIR__ . '/../bootstrap.php';
$acl = new Permission;
$acl->addResource('area');
$acl->allow(NULL, 'area');
-Assert::true( $acl->isAllowed(NULL, 'area') );
+Assert::true($acl->isAllowed(NULL, 'area'));
$acl->removeResource('area');
-Assert::exception(function() use ($acl) {
+Assert::exception(function () use ($acl) {
$acl->isAllowed(NULL, 'area');
-}, 'Nette\InvalidStateException', "Resource 'area' does not exist.");
+}, Nette\InvalidStateException::class, "Resource 'area' does not exist.");
$acl->addResource('area');
-Assert::false( $acl->isAllowed(NULL, 'area') );
+Assert::false($acl->isAllowed(NULL, 'area'));
diff --git a/tests/Security/Permission.RulesResourceRemoveAll.phpt b/tests/Security/Permission.RulesResourceRemoveAll.phpt
index c11b4c6b..7afc8741 100644
--- a/tests/Security/Permission.RulesResourceRemoveAll.phpt
+++ b/tests/Security/Permission.RulesResourceRemoveAll.phpt
@@ -4,8 +4,8 @@
* Test: Nette\Security\Permission Ensures that removal of all Resources results in Resource-specific rules being removed.
*/
-use Nette\Security\Permission,
- Tester\Assert;
+use Nette\Security\Permission;
+use Tester\Assert;
require __DIR__ . '/../bootstrap.php';
@@ -14,11 +14,11 @@ require __DIR__ . '/../bootstrap.php';
$acl = new Permission;
$acl->addResource('area');
$acl->allow(NULL, 'area');
-Assert::true( $acl->isAllowed(NULL, 'area') );
+Assert::true($acl->isAllowed(NULL, 'area'));
$acl->removeAllResources();
-Assert::exception(function() use ($acl) {
+Assert::exception(function () use ($acl) {
$acl->isAllowed(NULL, 'area');
-}, 'Nette\InvalidStateException', "Resource 'area' does not exist.");
+}, Nette\InvalidStateException::class, "Resource 'area' does not exist.");
$acl->addResource('area');
-Assert::false( $acl->isAllowed(NULL, 'area') );
+Assert::false($acl->isAllowed(NULL, 'area'));
diff --git a/tests/Security/SimpleAuthenticator.Roles.phpt b/tests/Security/SimpleAuthenticator.Roles.phpt
index 4ce3174a..19108993 100644
--- a/tests/Security/SimpleAuthenticator.Roles.phpt
+++ b/tests/Security/SimpleAuthenticator.Roles.phpt
@@ -4,32 +4,32 @@
* Test: Nette\Security\SimpleAuthenticator and roles
*/
-use Nette\Security\SimpleAuthenticator,
- Tester\Assert;
+use Nette\Security\SimpleAuthenticator;
+use Tester\Assert;
require __DIR__ . '/../bootstrap.php';
-$users = array(
- 'john' => 'john123',
+$users = [
+ 'john' => 'john123',
'admin' => 'admin123',
- 'user' => 'user123',
-);
-$usersRoles = array(
- 'admin' => array('admin', 'user'),
- 'user' => 'user',
-);
-$expectedRoles = array(
- 'admin' => array('admin', 'user'),
- 'user' => array('user'),
- 'john' => array(),
-);
+ 'user' => 'user123',
+];
+$usersRoles = [
+ 'admin' => ['admin', 'user'],
+ 'user' => 'user',
+];
+$expectedRoles = [
+ 'admin' => ['admin', 'user'],
+ 'user' => ['user'],
+ 'john' => [],
+];
$authenticator = new SimpleAuthenticator($users, $usersRoles);
foreach ($users as $username => $password) {
- $identity = $authenticator->authenticate(array($username, $password));
+ $identity = $authenticator->authenticate([$username, $password]);
Assert::equal($username, $identity->getId());
Assert::equal($expectedRoles[$username], $identity->getRoles());
}
diff --git a/tests/Security/SimpleAuthenticator.phpt b/tests/Security/SimpleAuthenticator.phpt
index 94c7e86a..1dd22669 100644
--- a/tests/Security/SimpleAuthenticator.phpt
+++ b/tests/Security/SimpleAuthenticator.phpt
@@ -4,32 +4,32 @@
* Test: Nette\Security\SimpleAuthenticator
*/
-use Nette\Security\SimpleAuthenticator,
- Tester\Assert;
+use Nette\Security\SimpleAuthenticator;
+use Tester\Assert;
require __DIR__ . '/../bootstrap.php';
-$users = array(
+$users = [
'john' => 'password123!',
'admin' => 'admin',
-);
+];
$authenticator = new SimpleAuthenticator($users);
-$identity = $authenticator->authenticate(array('john', 'password123!'));
-Assert::type( 'Nette\Security\IIdentity', $identity );
+$identity = $authenticator->authenticate(['john', 'password123!']);
+Assert::type(Nette\Security\IIdentity::class, $identity);
Assert::equal('john', $identity->getId());
-$identity = $authenticator->authenticate(array('admin', 'admin'));
-Assert::type( 'Nette\Security\IIdentity', $identity );
+$identity = $authenticator->authenticate(['admin', 'admin']);
+Assert::type(Nette\Security\IIdentity::class, $identity);
Assert::equal('admin', $identity->getId());
-Assert::exception(function() use ($authenticator) {
- $authenticator->authenticate(array('admin', 'wrong password'));
-}, 'Nette\Security\AuthenticationException', 'Invalid password.');
+Assert::exception(function () use ($authenticator) {
+ $authenticator->authenticate(['admin', 'wrong password']);
+}, Nette\Security\AuthenticationException::class, 'Invalid password.');
-Assert::exception(function() use ($authenticator) {
- $authenticator->authenticate(array('nobody', 'password'));
-}, 'Nette\Security\AuthenticationException', "User 'nobody' not found.");
+Assert::exception(function () use ($authenticator) {
+ $authenticator->authenticate(['nobody', 'password']);
+}, Nette\Security\AuthenticationException::class, "User 'nobody' not found.");
diff --git a/tests/Security/User.authentication.phpt b/tests/Security/User.authentication.phpt
index d945a0d9..5f10132a 100644
--- a/tests/Security/User.authentication.phpt
+++ b/tests/Security/User.authentication.phpt
@@ -4,16 +4,16 @@
* Test: Nette\Security\User authentication.
*/
-use Nette\Security\IAuthenticator,
- Nette\Security\Identity,
- Tester\Assert;
+use Nette\Security\IAuthenticator;
+use Nette\Security\Identity;
+use Tester\Assert;
require __DIR__ . '/../bootstrap.php';
require __DIR__ . '/MockUserStorage.php';
// Setup environment
-$_COOKIE = array();
+$_COOKIE = [];
ob_start();
@@ -43,10 +43,10 @@ class Authenticator implements IAuthenticator
$user = new Nette\Security\User(new MockUserStorage);
-$counter = (object) array(
+$counter = (object) [
'login' => 0,
'logout' => 0,
-);
+];
$user->onLoggedIn[] = function () use ($counter) {
$counter->login++;
@@ -57,65 +57,65 @@ $user->onLoggedOut[] = function () use ($counter) {
};
-Assert::false( $user->isLoggedIn() );
-Assert::null( $user->getIdentity() );
-Assert::null( $user->getId() );
+Assert::false($user->isLoggedIn());
+Assert::null($user->getIdentity());
+Assert::null($user->getId());
// authenticate
-Assert::exception(function() use ($user) {
+Assert::exception(function () use ($user) {
// login without handler
$user->login('jane', '');
-}, 'Nette\InvalidStateException', 'Authenticator has not been set.');
+}, Nette\InvalidStateException::class, 'Authenticator has not been set.');
$handler = new Authenticator;
$user->setAuthenticator($handler);
-Assert::exception(function() use ($user) {
+Assert::exception(function () use ($user) {
// login as jane
$user->login('jane', '');
-}, 'Nette\Security\AuthenticationException', 'Unknown user');
+}, Nette\Security\AuthenticationException::class, 'Unknown user');
-Assert::exception(function() use ($user) {
+Assert::exception(function () use ($user) {
// login as john
$user->login('john', '');
-}, 'Nette\Security\AuthenticationException', 'Password not match');
+}, Nette\Security\AuthenticationException::class, 'Password not match');
// login as john#2
$user->login('john', 'xxx');
-Assert::same( 1, $counter->login );
-Assert::true( $user->isLoggedIn() );
-Assert::equal( new Identity('John Doe', 'admin'), $user->getIdentity() );
-Assert::same( 'John Doe', $user->getId() );
+Assert::same(1, $counter->login);
+Assert::true($user->isLoggedIn());
+Assert::equal(new Identity('John Doe', 'admin'), $user->getIdentity());
+Assert::same('John Doe', $user->getId());
// login as john#3
$user->logout(TRUE);
-Assert::same( 1, $counter->logout );
-$user->login( new Identity('John Doe', 'admin') );
-Assert::same( 2, $counter->login );
-Assert::true( $user->isLoggedIn() );
-Assert::equal( new Identity('John Doe', 'admin'), $user->getIdentity() );
+Assert::same(1, $counter->logout);
+$user->login(new Identity('John Doe', 'admin'));
+Assert::same(2, $counter->login);
+Assert::true($user->isLoggedIn());
+Assert::equal(new Identity('John Doe', 'admin'), $user->getIdentity());
// log out
// logging out...
$user->logout(FALSE);
-Assert::same( 2, $counter->logout );
+Assert::same(2, $counter->logout);
-Assert::false( $user->isLoggedIn() );
-Assert::equal( new Identity('John Doe', 'admin'), $user->getIdentity() );
+Assert::false($user->isLoggedIn());
+Assert::equal(new Identity('John Doe', 'admin'), $user->getIdentity());
// logging out and clearing identity...
$user->logout(TRUE);
-Assert::same( 2, $counter->logout ); // not logged in -> logout event not triggered
+Assert::same(2, $counter->logout); // not logged in -> logout event not triggered
-Assert::false( $user->isLoggedIn() );
-Assert::null( $user->getIdentity() );
+Assert::false($user->isLoggedIn());
+Assert::null($user->getIdentity());
// namespace
// login as john#2?
$user->login('john', 'xxx');
-Assert::same( 3, $counter->login );
-Assert::true( $user->isLoggedIn() );
+Assert::same(3, $counter->login);
+Assert::true($user->isLoggedIn());
diff --git a/tests/Security/User.authorization.phpt b/tests/Security/User.authorization.phpt
index ecc91371..3a6920bb 100644
--- a/tests/Security/User.authorization.phpt
+++ b/tests/Security/User.authorization.phpt
@@ -4,10 +4,10 @@
* Test: Nette\Security\User authorization.
*/
-use Nette\Security\IAuthenticator,
- Nette\Security\Identity,
- Nette\Security\IAuthorizator,
- Tester\Assert;
+use Nette\Security\IAuthenticator;
+use Nette\Security\Identity;
+use Nette\Security\IAuthorizator;
+use Tester\Assert;
require __DIR__ . '/../bootstrap.php';
@@ -15,7 +15,7 @@ require __DIR__ . '/MockUserStorage.php';
// Setup environment
-$_COOKIE = array();
+$_COOKIE = [];
ob_start();
@@ -36,7 +36,7 @@ class Authenticator implements IAuthenticator
throw new Nette\Security\AuthenticationException('Password not match', self::INVALID_CREDENTIAL);
} else {
- return new Identity('John Doe', array('admin'));
+ return new Identity('John Doe', ['admin']);
}
}
@@ -62,12 +62,12 @@ class Authorizator implements IAuthorizator
$user = new Nette\Security\User(new MockUserStorage);
// guest
-Assert::false( $user->isLoggedIn() );
+Assert::false($user->isLoggedIn());
-Assert::same( array('guest'), $user->getRoles() );
-Assert::false( $user->isInRole('admin') );
-Assert::true( $user->isInRole('guest') );
+Assert::same(['guest'], $user->getRoles());
+Assert::false($user->isInRole('admin'));
+Assert::true($user->isInRole('guest'));
// authenticated
@@ -77,26 +77,26 @@ $user->setAuthenticator($handler);
// login as john
$user->login('john', 'xxx');
-Assert::true( $user->isLoggedIn() );
-Assert::same( array('admin'), $user->getRoles() );
-Assert::true( $user->isInRole('admin') );
-Assert::false( $user->isInRole('guest') );
+Assert::true($user->isLoggedIn());
+Assert::same(['admin'], $user->getRoles());
+Assert::true($user->isInRole('admin'));
+Assert::false($user->isInRole('guest'));
// authorization
-Assert::exception(function() use ($user) {
+Assert::exception(function () use ($user) {
$user->isAllowed('delete_file');
-}, 'Nette\InvalidStateException', 'Authorizator has not been set.');
+}, Nette\InvalidStateException::class, 'Authorizator has not been set.');
$handler = new Authorizator;
$user->setAuthorizator($handler);
-Assert::true( $user->isAllowed('delete_file') );
-Assert::false( $user->isAllowed('sleep_with_jany') );
+Assert::true($user->isAllowed('delete_file'));
+Assert::false($user->isAllowed('sleep_with_jany'));
// log out
// logging out...
$user->logout(FALSE);
-Assert::false( $user->isAllowed('delete_file') );
+Assert::false($user->isAllowed('delete_file'));
diff --git a/tests/bootstrap.php b/tests/bootstrap.php
index 85f7726f..e333db3d 100644
--- a/tests/bootstrap.php
+++ b/tests/bootstrap.php
@@ -4,7 +4,7 @@
// invoked through the command: ../vendor/bin/tester .
if (@!include __DIR__ . '/../vendor/autoload.php') {
- echo 'Install Nette Tester using `composer update --dev`';
+ echo 'Install Nette Tester using `composer install`';
exit(1);
}