mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
ae6c6d0a36
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@129 3807eeeb-6ff5-0310-8944-8be069107fe0
72 lines
No EOL
1.8 KiB
PHP
72 lines
No EOL
1.8 KiB
PHP
<?PHP
|
|
|
|
uses ('test', 'router');
|
|
|
|
class RouterTest extends TestCase {
|
|
var $abc;
|
|
|
|
// constructor of the test suite
|
|
function ControllerTest($name) {
|
|
$this->TestCase($name);
|
|
}
|
|
|
|
// called before the test functions will be executed
|
|
// this function is defined in PHPUnit_TestCase and overwritten
|
|
// here
|
|
function setUp() {
|
|
$this->abc = new Router ();
|
|
}
|
|
|
|
// called after the test functions are executed
|
|
// this function is defined in PHPUnit_TestCase and overwritten
|
|
// here
|
|
function tearDown() {
|
|
unset($this->abc);
|
|
}
|
|
|
|
|
|
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->abc->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('pass'=>array('bar', 'baz'), 'controller'=>'Foo', 'action'=>'dodo'),
|
|
'/one/two/three/' => array('controller'=>'one', 'action'=>'two', 'pass'=>array('three')),
|
|
'/foo' => array('controller'=>'foo','action'=>null),
|
|
'???' => array()
|
|
);
|
|
|
|
foreach ($tests as $test=>$expected) {
|
|
$this->asEq($this->abc->parse($test), $expected);
|
|
}
|
|
}
|
|
|
|
|
|
/*
|
|
function test () {
|
|
$result = $this->abc->();
|
|
$expected = '';
|
|
$this->assertEquals($result, $expected);
|
|
}
|
|
*/
|
|
}
|
|
|
|
?>
|