mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-19 02:56:15 +00:00
adding additional case for Router::normalize() and Controller::referer() to show #5157 is invalid
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@7463 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
0b8d7027ec
commit
074ede4639
2 changed files with 23 additions and 11 deletions
|
@ -263,16 +263,18 @@ class ControllerTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
function testPersistent() {
|
||||
Configure::write('Cache.disable', false);
|
||||
$Controller =& new Controller();
|
||||
$Controller->modelClass = 'ControllerPost';
|
||||
$Controller->persistModel = true;
|
||||
$Controller->constructClasses();
|
||||
$this->assertTrue(file_exists(CACHE . 'persistent' . DS .'controllerpost.php'));
|
||||
$this->assertTrue(is_a($Controller->ControllerPost, 'ControllerPost'));
|
||||
unlink(CACHE . 'persistent' . DS . 'controllerpost.php');
|
||||
unlink(CACHE . 'persistent' . DS . 'controllerpostregistry.php');
|
||||
@unlink(CACHE . 'persistent' . DS . 'controllerpost.php');
|
||||
@unlink(CACHE . 'persistent' . DS . 'controllerpostregistry.php');
|
||||
|
||||
unset($Controller);
|
||||
Configure::write('Cache.disable', true);
|
||||
}
|
||||
/**
|
||||
* testPaginate method
|
||||
|
@ -628,6 +630,13 @@ class ControllerTest extends CakeTestCase {
|
|||
$result = $Controller->referer(null, false);
|
||||
$expected = '/some/path';
|
||||
$this->assertIdentical($result, $expected);
|
||||
|
||||
$Controller->webroot = '/recipe/';
|
||||
|
||||
$_SERVER['HTTP_REFERER'] = FULL_BASE_URL.$Controller->webroot.'recipes/add';
|
||||
$result = $Controller->referer();
|
||||
$expected = '/recipes/add';
|
||||
$this->assertIdentical($result, $expected);
|
||||
}
|
||||
/**
|
||||
* testSetAction method
|
||||
|
|
|
@ -255,6 +255,9 @@ class RouterTest extends CakeTestCase {
|
|||
|
||||
$result = Router::normalize('/users/login/scope://foo');
|
||||
$this->assertEqual($result, '/users/login/scope:/foo');
|
||||
|
||||
$result = Router::normalize('/recipe/recipes/add');
|
||||
$this->assertEqual($result, '/recipe/recipes/add');
|
||||
}
|
||||
/**
|
||||
* testUrlGeneration method
|
||||
|
@ -1375,36 +1378,36 @@ class RouterTest extends CakeTestCase {
|
|||
$result = Router::prefixes();
|
||||
$expected = array('admin');
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
|
||||
Router::reload();
|
||||
|
||||
|
||||
$prefixParams = array('prefix' => 'members', 'members' => true);
|
||||
Router::connect('/members/:controller', $prefixParams);
|
||||
Router::connect('/members/:controller/:action', $prefixParams);
|
||||
Router::connect('/members/:controller/:action/*', $prefixParams);
|
||||
|
||||
|
||||
Router::setRequestInfo(array(
|
||||
array('controller' => 'controller', 'action' => 'index', 'form' => array(), 'url' => array(), 'plugin' => null),
|
||||
array('base' => '/base', 'here' => '/', 'webroot' => '/', 'passedArgs' => array(), 'argSeparator' => ':', 'namedArgs' => array())
|
||||
));
|
||||
|
||||
|
||||
$result = Router::parse('/members/posts/index');
|
||||
$expected = array('pass' => array(), 'named' => array(), 'prefix' => 'members', 'plugin' => null, 'controller' => 'posts', 'action' => 'index', 'members' => true);
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
|
||||
$result = Router::url(array('members' => true, 'controller' => 'posts', 'action' =>'index', 'page' => 2));
|
||||
$expected = '/base/members/posts/index/page:2';
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
|
||||
$result = Router::url(array('members' => true, 'controller' => 'users', 'action' => 'add'));
|
||||
$expected = '/base/members/users/add';
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
|
||||
$result = Router::parse('/posts/index');
|
||||
$expected = array('pass' => array(), 'named' => array(), 'plugin' => null, 'controller' => 'posts', 'action' => 'index');
|
||||
$this->assertEqual($result, $expected);
|
||||
$this->assertEqual($result, $expected);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Tests URL generation with flags and prefixes in and out of context
|
||||
*
|
||||
|
|
Loading…
Add table
Reference in a new issue