Skip to content

Commit

Permalink
Fixing failing tests caused by strtolower() in AuthComponent.
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Jul 10, 2010
1 parent eeda60b commit 5d2c48f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
8 changes: 4 additions & 4 deletions cake/libs/controller/components/auth.php
Expand Up @@ -302,7 +302,7 @@ public function startup(&$controller) {
}

$methods = array_flip($controller->methods);
$action = strtolower($controller->request->params['action']);
$action = $controller->request->params['action'];
$isMissingAction = (
$controller->scaffold === false &&
!isset($methods[$action])
Expand All @@ -326,7 +326,7 @@ public function startup(&$controller) {
$url = Router::normalize($url);
$loginAction = Router::normalize($this->loginAction);

$allowedActions = array_map('strtolower', $this->allowedActions);
$allowedActions = $this->allowedActions;
$isAllowed = (
$this->allowedActions == array('*') ||
in_array($action, $allowedActions)
Expand Down Expand Up @@ -601,7 +601,7 @@ public function allow() {
if (isset($args[0]) && is_array($args[0])) {
$args = $args[0];
}
$this->allowedActions = array_merge($this->allowedActions, array_map('strtolower', $args));
$this->allowedActions = array_merge($this->allowedActions, $args);
}
}

Expand All @@ -621,7 +621,7 @@ public function deny() {
$args = $args[0];
}
foreach ($args as $arg) {
$i = array_search(strtolower($arg), $this->allowedActions);
$i = array_search($arg, $this->allowedActions);
if (is_int($i)) {
unset($this->allowedActions[$i]);
}
Expand Down
9 changes: 3 additions & 6 deletions cake/tests/cases/libs/controller/components/auth.test.php
Expand Up @@ -833,22 +833,19 @@ function testAllowDenyAll() {
$this->Controller->Auth->initialize($this->Controller);

$this->Controller->Auth->allow('*');
$this->Controller->Auth->deny('add', 'camelcase');
$this->Controller->Auth->deny('add', 'camelCase');

$this->Controller->request['action'] = 'delete';
$this->assertTrue($this->Controller->Auth->startup($this->Controller));

$this->Controller->request['action'] = 'add';
$this->assertFalse($this->Controller->Auth->startup($this->Controller));

$this->Controller->request['action'] = 'Add';
$this->assertFalse($this->Controller->Auth->startup($this->Controller));

$this->Controller->request['action'] = 'camelCase';
$this->assertFalse($this->Controller->Auth->startup($this->Controller));

$this->Controller->Auth->allow('*');
$this->Controller->Auth->deny(array('add', 'camelcase'));
$this->Controller->Auth->deny(array('add', 'camelCase'));

$this->Controller->request['action'] = 'camelCase';
$this->assertFalse($this->Controller->Auth->startup($this->Controller));
Expand Down Expand Up @@ -948,7 +945,7 @@ function testAllowedActionsSetWithAllowMethod() {
$this->Controller->request->query['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'));
$this->assertEqual($this->Controller->Auth->allowedActions, array('action_name', 'anotherAction'));
}

/**
Expand Down

0 comments on commit 5d2c48f

Please sign in to comment.