Skip to content

Commit

Permalink
Fixing parameter ordering error of array_map in AuthComponent::allow(…
Browse files Browse the repository at this point in the history
…). Adding test.
  • Loading branch information
jperras committed Sep 21, 2009
1 parent 42017e9 commit 2b0d137
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion cake/libs/controller/components/auth.php
Expand Up @@ -600,7 +600,7 @@ function allow() {
if (isset($args[0]) && is_array($args[0])) { if (isset($args[0]) && is_array($args[0])) {
$args = $args[0]; $args = $args[0];
} }
$this->allowedActions = array_merge($this->allowedActions, array_map($args, 'strtolower')); $this->allowedActions = array_merge($this->allowedActions, array_map('strtolower', $args));
} }
} }


Expand Down
13 changes: 12 additions & 1 deletion cake/tests/cases/libs/controller/components/auth.test.php
Expand Up @@ -844,7 +844,7 @@ function testActionMethod() {


$result = $this->Controller->Auth->action(':controller'); $result = $this->Controller->Auth->action(':controller');
$this->assertEqual($result, 'ROOT/AuthTest'); $this->assertEqual($result, 'ROOT/AuthTest');

$this->Controller->params['plugin'] = 'test_plugin'; $this->Controller->params['plugin'] = 'test_plugin';
$this->Controller->params['controller'] = 'auth_test'; $this->Controller->params['controller'] = 'auth_test';
$this->Controller->params['action'] = 'add'; $this->Controller->params['action'] = 'add';
Expand Down Expand Up @@ -899,6 +899,17 @@ function testAllowedActionsWithCamelCaseMethods() {
$this->Controller->Auth->allowedActions = array('delete', 'add'); $this->Controller->Auth->allowedActions = array('delete', 'add');
$result = $this->Controller->Auth->startup($this->Controller); $result = $this->Controller->Auth->startup($this->Controller);
$this->assertFalse($result, 'startup() should return false, as action is not allowed. %s'); $this->assertFalse($result, 'startup() should return false, as action is not allowed. %s');

}

function testAllowedActionsSetWithAllowMethod() {
$url = '/auth_test/action_name';
$this->Controller->params = Router::parse($url);
$this->Controller->params['url']['url'] = Router::normalize($url);
$this->Controller->Auth->initialize($this->Controller);
$this->Controller->Auth->allow('action_name', 'anotherAction');
$this->assertEqual($this->Controller->Auth->allowedActions, array('action_name', 'anotheraction'));

} }


/** /**
Expand Down

0 comments on commit 2b0d137

Please sign in to comment.