Subversion Repositories SmartDukaan

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
12345 anikendra 1
<?php
2
/**
3
 * CakeRequest Test case file.
4
 *
5
 * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
6
 * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
7
 *
8
 * Licensed under The MIT License
9
 * For full copyright and license information, please see the LICENSE.txt
10
 * Redistributions of files must retain the above copyright notice.
11
 *
12
 * @copyright     Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
13
 * @link          http://cakephp.org CakePHP(tm) Project
14
 * @package       Cake.Test.Case.Routing.Route
15
 * @since         CakePHP(tm) v 2.0
16
 * @license       http://www.opensource.org/licenses/mit-license.php MIT License
17
 */
18
 
19
App::uses('PluginShortRoute', 'Routing/Route');
20
App::uses('Router', 'Routing');
21
 
22
/**
23
 * test case for PluginShortRoute
24
 *
25
 * @package       Cake.Test.Case.Routing.Route
26
 */
27
class PluginShortRouteTest extends CakeTestCase {
28
 
29
/**
30
 * setUp method
31
 *
32
 * @return void
33
 */
34
	public function setUp() {
35
		parent::setUp();
36
		Configure::write('Routing', array('admin' => null, 'prefixes' => array()));
37
		Router::reload();
38
	}
39
 
40
/**
41
 * test the parsing of routes.
42
 *
43
 * @return void
44
 */
45
	public function testParsing() {
46
		$route = new PluginShortRoute('/:plugin', array('action' => 'index'), array('plugin' => 'foo|bar'));
47
 
48
		$result = $route->parse('/foo');
49
		$this->assertEquals('foo', $result['plugin']);
50
		$this->assertEquals('foo', $result['controller']);
51
		$this->assertEquals('index', $result['action']);
52
 
53
		$result = $route->parse('/wrong');
54
		$this->assertFalse($result, 'Wrong plugin name matched %s');
55
	}
56
 
57
/**
58
 * test the reverse routing of the plugin shortcut URLs.
59
 *
60
 * @return void
61
 */
62
	public function testMatch() {
63
		$route = new PluginShortRoute('/:plugin', array('action' => 'index'), array('plugin' => 'foo|bar'));
64
 
65
		$result = $route->match(array('plugin' => 'foo', 'controller' => 'posts', 'action' => 'index'));
66
		$this->assertFalse($result, 'plugin controller mismatch was converted. %s');
67
 
68
		$result = $route->match(array('plugin' => 'foo', 'controller' => 'foo', 'action' => 'index'));
69
		$this->assertEquals('/foo', $result);
70
	}
71
}