mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Adding tests for AuthComponent::action().
Adding plugin support for AuthComponent in actions mode. Refs #33
This commit is contained in:
parent
c94698500b
commit
4a6412fb27
2 changed files with 33 additions and 3 deletions
|
@ -772,10 +772,11 @@ class AuthComponent extends Object {
|
|||
* @return boolean ACO node path
|
||||
* @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(
|
||||
array(':controller', ':action'),
|
||||
array(Inflector::camelize($this->params['controller']), $this->params['action']),
|
||||
array(':controller', ':action', ':plugin/'),
|
||||
array(Inflector::camelize($this->params['controller']), $this->params['action'], $plugin),
|
||||
$this->actionPath . $action
|
||||
);
|
||||
}
|
||||
|
|
|
@ -824,6 +824,35 @@ class AuthTest extends CakeTestCase {
|
|||
$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.
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue