Adding tests for AuthComponent::action().

Adding plugin support for AuthComponent in actions mode.  Refs #33
This commit is contained in:
mark_story 2009-09-14 00:29:33 -04:00
parent c94698500b
commit 4a6412fb27
2 changed files with 33 additions and 3 deletions

View file

@ -772,10 +772,11 @@ class AuthComponent extends Object {
* @return boolean ACO node path * @return boolean ACO node path
* @access public * @access public
*/ */
function action($action = ':controller/:action') { function action($action = ':plugin/:controller/:action') {
$plugin = empty($this->params['plugin']) ? null : Inflector::camelize($this->params['plugin']) . '/';
return str_replace( return str_replace(
array(':controller', ':action'), array(':controller', ':action', ':plugin/'),
array(Inflector::camelize($this->params['controller']), $this->params['action']), array(Inflector::camelize($this->params['controller']), $this->params['action'], $plugin),
$this->actionPath . $action $this->actionPath . $action
); );
} }

View file

@ -824,6 +824,35 @@ class AuthTest extends CakeTestCase {
$this->assertFalse($this->Controller->Auth->startup($this->Controller)); $this->assertFalse($this->Controller->Auth->startup($this->Controller));
} }
/**
* test the action() method
*
* @return void
**/
function testActionMethod() {
$this->Controller->params['controller'] = 'auth_test';
$this->Controller->params['action'] = 'add';
$this->Controller->Auth->initialize($this->Controller);
$this->Controller->Auth->actionPath = 'ROOT/';
$result = $this->Controller->Auth->action();
$this->assertEqual($result, 'ROOT/AuthTest/add');
$result = $this->Controller->Auth->action(':controller');
$this->assertEqual($result, 'ROOT/AuthTest');
$result = $this->Controller->Auth->action(':controller');
$this->assertEqual($result, 'ROOT/AuthTest');
$this->Controller->params['plugin'] = 'test_plugin';
$this->Controller->params['controller'] = 'auth_test';
$this->Controller->params['action'] = 'add';
$this->Controller->Auth->initialize($this->Controller);
$result = $this->Controller->Auth->action();
$this->assertEqual($result, 'ROOT/TestPlugin/AuthTest/add');
}
/** /**
* test that deny() converts camel case inputs to lowercase. * test that deny() converts camel case inputs to lowercase.
* *