Skip to content

Commit

Permalink
Converting remaining array syntax to the short syntax.
Browse files Browse the repository at this point in the history
  • Loading branch information
renan committed Apr 7, 2014
1 parent dd9f502 commit 89a8a07
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 29 deletions.
12 changes: 6 additions & 6 deletions src/Controller/Component/Auth/FormAuthenticate.php
Expand Up @@ -25,11 +25,11 @@
* data. Can be used by configuring AuthComponent to use it via the AuthComponent::$authenticate config.
*
* {{{
* $this->Auth->authenticate = array(
* 'Form' => array(
* 'scope' => array('Users.active' => 1)
* )
* )
* $this->Auth->authenticate = [
* 'Form' => [
* 'scope' => ['Users.active' => 1]
* ]
* ]
* }}}
*
* When configuring FormAuthenticate you can pass in config to which fields, model and additional conditions
Expand All @@ -47,7 +47,7 @@ class FormAuthenticate extends BaseAuthenticate {
* @return boolean False if the fields have not been supplied. True if they exist.
*/
protected function _checkFields(Request $request, array $fields) {
foreach (array($fields['username'], $fields['password']) as $field) {
foreach ([$fields['username'], $fields['password']] as $field) {
$value = $request->data($field);
if (empty($value) || !is_string($value)) {
return false;
Expand Down
46 changes: 23 additions & 23 deletions tests/TestCase/Controller/Component/Auth/FormAuthenticateTest.php
Expand Up @@ -38,7 +38,7 @@ class FormAuthenticateTest extends TestCase {
*
* @var array
*/
public $fixtures = array('core.user', 'core.auth_user');
public $fixtures = ['core.user', 'core.auth_user'];

/**
* setup
Expand All @@ -48,9 +48,9 @@ class FormAuthenticateTest extends TestCase {
public function setUp() {
parent::setUp();
$this->Collection = $this->getMock('Cake\Controller\ComponentRegistry');
$this->auth = new FormAuthenticate($this->Collection, array(
$this->auth = new FormAuthenticate($this->Collection, [
'userModel' => 'Users'
));
]);
$password = Security::hash('password', 'blowfish', false);
$Users = TableRegistry::get('Users');
$Users->updateAll(['password' => $password], []);
Expand All @@ -63,12 +63,12 @@ public function setUp() {
* @return void
*/
public function testConstructor() {
$object = new FormAuthenticate($this->Collection, array(
$object = new FormAuthenticate($this->Collection, [
'userModel' => 'AuthUsers',
'fields' => array('username' => 'user', 'password' => 'password')
));
'fields' => ['username' => 'user', 'password' => 'password']
]);
$this->assertEquals('AuthUsers', $object->config('userModel'));
$this->assertEquals(array('username' => 'user', 'password' => 'password'), $object->config('fields'));
$this->assertEquals(['username' => 'user', 'password' => 'password'], $object->config('fields'));
}

/**
Expand Down Expand Up @@ -133,13 +133,13 @@ public function testAuthenticatePasswordIsEmptyString() {

$this->auth = $this->getMock(
'Cake\Controller\Component\Auth\FormAuthenticate',
array('_checkFields'),
array(
['_checkFields'],
[
$this->Collection,
array(
[
'userModel' => 'Users'
)
)
]
]
);

// Simulate that check for ensuring password is not empty is missing.
Expand Down Expand Up @@ -196,12 +196,12 @@ public function testAuthenticateSuccess() {
'password' => 'password'
];
$result = $this->auth->authenticate($request, $this->response);
$expected = array(
$expected = [
'id' => 1,
'username' => 'mariano',
'created' => new \DateTime('2007-03-17 01:16:23'),
'updated' => new \DateTime('2007-03-17 01:18:31')
);
];
$this->assertEquals($expected, $result);
}

Expand Down Expand Up @@ -245,12 +245,12 @@ public function testPluginModel() {
];

$result = $this->auth->authenticate($request, $this->response);
$expected = array(
$expected = [
'id' => 1,
'username' => 'gwoo',
'created' => new \DateTime('2007-03-17 01:16:23'),
'updated' => new \DateTime('2007-03-17 01:18:31')
);
];
$this->assertEquals($expected, $result);
Plugin::unload();
}
Expand All @@ -273,8 +273,8 @@ public function testPasswordHasherSettings() {
$hash = Security::hash('mypass', 'md5', true);
$User = TableRegistry::get('Users');
$User->updateAll(
array('password' => $hash),
array('username' => 'mariano')
['password' => $hash],
['username' => 'mariano']
);

$request = new Request('posts/index');
Expand All @@ -284,18 +284,18 @@ public function testPasswordHasherSettings() {
];

$result = $this->auth->authenticate($request, $this->response);
$expected = array(
$expected = [
'id' => 1,
'username' => 'mariano',
'created' => new \DateTime('2007-03-17 01:16:23'),
'updated' => new \DateTime('2007-03-17 01:18:31')
);
];
$this->assertEquals($expected, $result);

$this->auth = new FormAuthenticate($this->Collection, array(
'fields' => array('username' => 'username', 'password' => 'password'),
$this->auth = new FormAuthenticate($this->Collection, [
'fields' => ['username' => 'username', 'password' => 'password'],
'userModel' => 'Users'
));
]);
$this->auth->config('passwordHasher', [
'className' => 'Simple',
'hashType' => 'sha1'
Expand Down

0 comments on commit 89a8a07

Please sign in to comment.