Skip to content

Commit

Permalink
Merge pull request #18 from Oefenweb/use-short-array-syntax
Browse files Browse the repository at this point in the history
Use short array syntax
  • Loading branch information
tersmitten committed Mar 9, 2016
2 parents 9217e66 + 553f39a commit cad5edf
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 23 deletions.
4 changes: 2 additions & 2 deletions Controller/TestProviderController.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ public function authenticate() {
$auth = UniLoginUtil::calculateFingerprint($timestamp, $user);

if ($applicationId === Configure::read('UniLogin.testProvider.applicationId')) {
$query = array(
$query = [
'user' => $user,
'timestamp' => $timestamp,
'auth' => $auth
);
];
$redirectUrl .= '?' . http_build_query($query);
}

Expand Down
2 changes: 1 addition & 1 deletion Controller/UniLoginAppController.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class UniLoginAppController extends AppController {
*
* @var array
*/
public $uses = array();
public $uses = [];

/**
* Before action logic.
Expand Down
12 changes: 6 additions & 6 deletions Controller/UniLoginController.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class UniLoginController extends UniLoginAppController {
*
* @var array
*/
public $uses = array();
public $uses = [];

/**
* Starts the Uni-Login login process (by redirecting the user to the authentication provider).
Expand All @@ -21,21 +21,21 @@ class UniLoginController extends UniLoginAppController {
*/
public function login() {
// Default callback url
$url = array('action' => 'callback');
$url = ['action' => 'callback'];
$returnUrl = $this->request->query('returnUrl');
if ($returnUrl) {
$url['?'] = array(
$url['?'] = [
'returnUrl' => Router::url($returnUrl)
);
];
}

$url = Router::url($url, true);

$query = array(
$query = [
'path' => UniLoginUtil::encodeUrl($url),
'auth' => UniLoginUtil::calculateUrlFingerprint($url),
'id' => Configure::read('UniLogin.provider.applicationId')
);
];

$redirectUrl = Configure::read('UniLogin.provider.url');
$redirectUrl .= '?' . http_build_query($query);
Expand Down
28 changes: 14 additions & 14 deletions Test/Case/Controller/TestProviderControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@ public function tearDown() {
public function testAuthenticateDefaultUrl() {
$defaultRedirectUrl = 'http://www.example.com/redirectUrl';

$this->testAction('/uni_login/test_provider/authenticate', array(
'data' => array(
$this->testAction('/uni_login/test_provider/authenticate', [
'data' => [
'id' => 'myApplicationId'
),
],
'method' => 'get'
));
]);

$this->assertContains($defaultRedirectUrl, $this->headers['Location']);
$this->assertContains('user=', $this->headers['Location']);
Expand All @@ -69,9 +69,9 @@ public function testAuthenticateDefaultUrl() {
public function testAuthenticateDefaultUrlWithoutApplicationId() {
$defaultRedirectUrl = 'http://www.example.com/redirectUrl';

$this->testAction('/uni_login/test_provider/authenticate', array(
$this->testAction('/uni_login/test_provider/authenticate', [
'method' => 'get'
));
]);

$this->assertContains($defaultRedirectUrl, $this->headers['Location']);
$this->assertNotContains('user=', $this->headers['Location']);
Expand All @@ -88,14 +88,14 @@ public function testAuthenticateRedirectUrlParameter() {
$url = 'http://www.mydomain.com';
$path = UniLoginUtil::encodeUrl($url);
$auth = UniLoginUtil::calculateUrlFingerprint($url);
$this->testAction('/uni_login/test_provider/authenticate', array(
'data' => array(
$this->testAction('/uni_login/test_provider/authenticate', [
'data' => [
'id' => 'myApplicationId',
'path' => $path,
'auth' => $auth
),
],
'method' => 'get'
));
]);

$this->assertContains($url, $this->headers['Location']);
$this->assertContains('user=', $this->headers['Location']);
Expand All @@ -112,13 +112,13 @@ public function testAuthenticateRedirectUrlParameterWithoutApplicationId() {
$url = 'http://www.mydomain.com';
$path = UniLoginUtil::encodeUrl($url);
$auth = UniLoginUtil::calculateUrlFingerprint($url);
$this->testAction('/uni_login/test_provider/authenticate', array(
'data' => array(
$this->testAction('/uni_login/test_provider/authenticate', [
'data' => [
'path' => $path,
'auth' => $auth
),
],
'method' => 'get'
));
]);

$this->assertContains($url, $this->headers['Location']);
$this->assertNotContains('user=', $this->headers['Location']);
Expand Down

0 comments on commit cad5edf

Please sign in to comment.