mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
da79dff7d7
- Dispatcher sets a Controller::here variable with the real URL used to access the page, so that tag generators can that use an url (linkTo and formTag for example) use the real url, not guess it from the controller and action names which often fails - Log class works more reliably and a LogError() shortcut function was added - Nstring class added, to store string-related functions (there are just four yet, including a random password generator and an string-to-array splitter - SimpleTest library (with Rephlux) included in /vendors; I've tweaked SimpleScorer::inCli() function, because it didn't work on my setup, it should work everywhere now (it checks for empty REQUEST_METHOD, which should only be empty in CLI) git-svn-id: https://svn.cakephp.org/repo/trunk/cake@248 3807eeeb-6ff5-0310-8944-8be069107fe0
71 lines
No EOL
1.7 KiB
PHP
71 lines
No EOL
1.7 KiB
PHP
<?PHP
|
|
|
|
uses ('router');
|
|
|
|
class RouterTest extends UnitTestCase
|
|
{
|
|
var $router;
|
|
|
|
// constructor of the test suite
|
|
function RouterTest()
|
|
{
|
|
$this->UnitTestCase('Router test');
|
|
}
|
|
|
|
// called before the test functions will be executed
|
|
// this function is defined in PHPUnit_TestCase and overwritten
|
|
// here
|
|
function setUp()
|
|
{
|
|
$this->router = new Router();
|
|
}
|
|
|
|
// called after the test functions are executed
|
|
// this function is defined in PHPUnit_TestCase and overwritten
|
|
// here
|
|
function tearDown()
|
|
{
|
|
unset($this->router);
|
|
}
|
|
|
|
|
|
function _testConnect()
|
|
{
|
|
$tests = array(
|
|
'/' => array('controller'=>'Foo', 'action'=>'bar'),
|
|
'/foo/baz' => array('controller'=>'Foo', 'action'=>'baz'),
|
|
'/foo/*' => array('controller'=>'Foo', 'action'=>'dodo'),
|
|
'/foobar' => array('controller'=>'Foobar', 'action'=>'bar'),
|
|
);
|
|
|
|
foreach ($tests as $route=>$data)
|
|
$this->router->connect ($route, $data);
|
|
}
|
|
|
|
|
|
function testParse ()
|
|
{
|
|
|
|
$this->_testConnect();
|
|
|
|
$tests = array(
|
|
'' => array('controller'=>'Foo', 'action'=>'bar'),
|
|
'/' => array('controller'=>'Foo', 'action'=>'bar'),
|
|
'/foo/baz/' => array('controller'=>'Foo', 'action'=>'baz'),
|
|
'/foo/foo+bar' => array('pass'=>array('foo+bar'), 'controller'=>'Foo', 'action'=>'dodo'),
|
|
'/foobar/' => array('controller'=>'Foobar', 'action'=>'bar'),
|
|
'/foo/bar/baz' => array('controller'=>'Foo', 'action'=>'dodo', 'pass'=>array('bar', 'baz')),
|
|
'/one/two/three/' => array('controller'=>'one', 'action'=>'two', 'pass'=>array('three')),
|
|
'/ruburb' => array('controller'=>'ruburb','action'=>null),
|
|
'???' => array()
|
|
);
|
|
|
|
foreach ($tests as $test=>$expected)
|
|
{
|
|
$tested = $this->router->parse($test);
|
|
$this->assertEqual($tested, $expected);
|
|
}
|
|
}
|
|
}
|
|
|
|
?>
|