예제 #1
0
 /**
  * Test that :key elements are urldecoded
  *
  * @return void
  */
 public function testParseUrlDecodeElements()
 {
     $route = new Cakeroute('/:controller/:slug', array('action' => 'view'));
     $route->compile();
     $result = $route->parse('/posts/%E2%88%82%E2%88%82');
     $this->assertEquals('posts', $result['controller']);
     $this->assertEquals('view', $result['action']);
     $this->assertEquals('∂∂', $result['slug']);
     $result = $route->parse('/posts/∂∂');
     $this->assertEquals('posts', $result['controller']);
     $this->assertEquals('view', $result['action']);
     $this->assertEquals('∂∂', $result['slug']);
 }
예제 #2
0
/**
 * test the parse method of CakeRoute.
 *
 * @return void
 */
	public function testParse() {
		$route = new CakeRoute(
			'/:controller/:action/:id',
			array('controller' => 'testing4', 'id' => null),
			array('id' => Router::ID)
		);
		$route->compile();
		$result = $route->parse('/posts/view/1');
		$this->assertEqual($result['controller'], 'posts');
		$this->assertEqual($result['action'], 'view');
		$this->assertEqual($result['id'], '1');

		$route = new Cakeroute(
			'/admin/:controller',
			array('prefix' => 'admin', 'admin' => 1, 'action' => 'index')
		);
		$route->compile();
		$result = $route->parse('/admin/');
		$this->assertFalse($result);

		$result = $route->parse('/admin/posts');
		$this->assertEqual($result['controller'], 'posts');
		$this->assertEqual($result['action'], 'index');
	}