本文整理汇总了PHP中lithium\net\http\Router::reset方法的典型用法代码示例。如果您正苦于以下问题:PHP Router::reset方法的具体用法?PHP Router::reset怎么用?PHP Router::reset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lithium\net\http\Router
的用法示例。
在下文中一共展示了Router::reset方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: tearDown
public function tearDown()
{
Router::reset();
foreach ($this->_routes as $route) {
Router::connect($route);
}
}
示例2: teardown
function teardown()
{
Router::reset();
foreach ($this->_routes as $route) {
Router::connect($route);
}
unset($this->analytics);
}
示例3: testRouteLoading
/**
* Test if the routes.php file is loaded correctly and the
* routes are connected to the router.
*/
public function testRouteLoading()
{
$this->assertFalse(Router::get());
$command = new Route(array('routes_file' => $this->_config['routes_file']));
$this->assertEqual(4, count(Router::get()));
Router::reset();
$request = new Request();
$request->params['env'] = 'production';
$command = new Route(array('routes_file' => $this->_config['routes_file'], 'request' => $request));
$this->assertEqual(2, count(Router::get()));
}
示例4: setUp
public function setUp()
{
$this->_routes = Router::get();
Router::reset();
Router::connect('/{:controller}/{:action}/page/{:page:[0-9]+}');
$request = new Request();
$request->params = array('controller' => 'posts', 'action' => 'index');
$request->persist = array('controller');
$this->context = new MockRenderer(compact('request'));
$this->pagination = new Pagination(array('context' => $this->context));
}
示例5: tearDown
/**
* Clean up after the test.
*/
public function tearDown()
{
Router::reset();
foreach ($this->_routes as $scope => $routes) {
Router::scope($scope, function () use($routes) {
foreach ($routes as $route) {
Router::connect($route);
}
});
}
unset($this->html);
}
示例6: _restoreCtrlContext
protected function _restoreCtrlContext()
{
Router::reset();
foreach ($this->_context['routes'] as $scope => $routes) {
Router::scope($scope, function () use($routes) {
foreach ($routes as $route) {
Router::connect($route);
}
});
}
foreach ($this->_context['scopes'] as $scope => $attachment) {
Router::attach($scope, $attachment);
}
Router::scope($this->_context['scope']);
}
示例7: testReversingContinuations
/**
* Tests that URLs are properly generated with route continuations.
*/
public function testReversingContinuations()
{
Router::connect('/{:locale:en|de|it|jp}/{:args}', array(), array('continue' => true));
Router::connect('/{:controller}/{:action}/{:id:[0-9]+}');
Router::connect('/{:controller}/{:action}/{:args}');
$result = Router::match(array('Posts::view', 'id' => 5, 'locale' => 'de'));
$this->assertEqual($result, '/de/posts/view/5');
$result = Router::match(array('Posts::index', 'locale' => 'en', '?' => array('page' => 2)));
$this->assertEqual('/en/posts?page=2', $result);
Router::reset();
Router::connect('/{:locale:en|de|it|jp}/{:args}', array(), array('continue' => true));
Router::connect('/pages/{:args}', 'Pages::view');
$result = Router::match(array('Pages::view', 'locale' => 'en', 'args' => array('about')));
$this->assertEqual('/en/pages/about', $result);
Router::reset();
Router::connect('/admin/{:args}', array('admin' => true), array('continue' => true));
Router::connect('/login', 'Users::login');
$result = Router::match(array('Users::login', 'admin' => true));
$this->assertEqual('/admin/login', $result);
}
示例8: testRouteLoading
/**
* Test if the routes.php file is loaded correctly and the
* routes are connected to the router.
*/
public function testRouteLoading()
{
$this->assertEmpty(Router::get(null, true));
$command = new Route(array('routes' => $this->_config['routes']));
$this->assertCount(4, Router::get(null, true));
Router::reset();
$request = new Request();
$request->params['env'] = 'production';
$command = new Route(compact('request') + array('routes' => $this->_config['routes']));
$this->assertCount(2, Router::get(null, true));
}
示例9: tearDown
public function tearDown()
{
Router::reset();
}
示例10: testConfigManipulation
public function testConfigManipulation()
{
$config = MockDispatcher::config();
$expected = array('rules' => array());
$this->assertEqual($expected, $config);
MockDispatcher::config(array('rules' => array('admin' => array('action' => 'admin_{:action}'))));
Router::connect('/', array('controller' => 'test', 'action' => 'test', 'admin' => true));
MockDispatcher::run(new Request(array('url' => '/')));
$result = end(MockDispatcher::$dispatched);
$expected = array('action' => 'admin_test', 'controller' => 'Test', 'admin' => true);
$this->assertEqual($expected, $result->params);
MockDispatcher::config(array('rules' => array('action' => array('action' => function ($params) {
return Inflector::camelize(strtolower($params['action']), false);
}))));
MockDispatcher::$dispatched = array();
Router::reset();
Router::connect('/', array('controller' => 'test', 'action' => 'TeST-camelize'));
MockDispatcher::run(new Request(array('url' => '/')));
$result = end(MockDispatcher::$dispatched);
$expected = array('action' => 'testCamelize', 'controller' => 'Test');
$this->assertEqual($expected, $result->params);
MockDispatcher::config(array('rules' => function ($params) {
if (isset($params['admin'])) {
return array('special' => array('action' => 'special_{:action}'));
}
return array();
}));
MockDispatcher::$dispatched = array();
Router::reset();
Router::connect('/', array('controller' => 'test', 'action' => 'test', 'admin' => true));
Router::connect('/special', array('controller' => 'test', 'action' => 'test', 'admin' => true, 'special' => true));
MockDispatcher::run(new Request(array('url' => '/')));
$result = end(MockDispatcher::$dispatched);
$expected = array('action' => 'test', 'controller' => 'Test', 'admin' => true);
$this->assertEqual($expected, $result->params);
MockDispatcher::run(new Request(array('url' => '/special')));
$result = end(MockDispatcher::$dispatched);
$expected = array('action' => 'special_test', 'controller' => 'Test', 'admin' => true, 'special' => true);
$this->assertEqual($expected, $result->params);
}
示例11: testProcessWithRelativeAndPrefixedAttachment
public function testProcessWithRelativeAndPrefixedAttachment()
{
Router::scope('app', function () {
Router::connect('/home/welcome', array('Home::app'));
});
Router::scope('tests', function () {
Router::connect('/home/welcome', array('Home::tests'));
});
Router::connect('/home/welcome', array('Home::default'));
Router::attach('tests', array('absolute' => false, 'host' => 'tests.mysite.com', 'scheme' => 'http://', 'prefix' => '/prefix'));
Router::attach('app', array('absolute' => false, 'host' => 'app.mysite.com', 'scheme' => 'http://', 'prefix' => '/prefix'));
$request = new Request(array('url' => '/home/welcome'));
$result = Router::process($request);
$expected = array('controller' => 'Home', 'action' => 'default');
$this->assertEqual($expected, $result->params);
$this->assertIdentical(false, Router::scope());
Router::reset();
Router::scope('tests', function () {
Router::connect('/home/welcome', array('Home::tests'));
});
Router::scope('app', function () {
Router::connect('/home/welcome', array('Home::app'));
});
Router::connect('/home/welcome', array('Home::default'));
Router::attach('tests', array('absolute' => false, 'host' => 'tests.mysite.com', 'scheme' => 'http://', 'prefix' => '/prefix1'));
Router::attach('app', array('absolute' => false, 'host' => 'app.mysite.com', 'scheme' => 'http://', 'prefix' => '/prefix2'));
$request = new Request(array('url' => '/prefix1/home/welcome'));
$result = Router::process($request);
$expected = array('library' => 'tests', 'controller' => 'Home', 'action' => 'tests');
$this->assertEqual($expected, $result->params);
$this->assertEqual('tests', Router::scope());
}
示例12: testRouteMatchingWithInsertsAndDefaults
/**
* Test matching routes with insert parameters which have default values.
*/
public function testRouteMatchingWithInsertsAndDefaults()
{
Router::connect('/{:controller}/{:action}', array('action' => 'archive'));
$this->assertEqual('/posts', Router::match(array('controller' => 'posts')));
$result = Router::match(array('controller' => 'posts', 'action' => 'archive'));
$this->assertEqual('/posts/archive', $result);
Router::reset();
Router::connect('/{:controller}/{:action}', array('controller' => 'users'));
$result = Router::match(array('action' => 'view'));
$this->assertEqual('/users/view', $result);
$result = Router::match(array('controller' => 'posts', 'action' => 'view'));
$this->assertEqual('/posts/view', $result);
$ex = "No parameter match found for URL ";
$ex .= "`('controller' => 'posts', 'action' => 'view', 'id' => '2')`.";
$this->expectException($ex);
Router::match(array('controller' => 'posts', 'action' => 'view', 'id' => '2'));
}
示例13: tearDown
public function tearDown()
{
Router::reset();
MockDispatcher::reset();
}
示例14: testRouteMatchingWithInsertsAndDefaults
/**
* Test matching routes with insert parameters which have default values.
*
* @return void
*/
public function testRouteMatchingWithInsertsAndDefaults()
{
Router::connect('/{:controller}/{:action}', array('action' => 'archive'));
$this->assertEqual('/posts', Router::match(array('controller' => 'posts')));
$result = Router::match(array('controller' => 'posts', 'action' => 'archive'));
$this->assertEqual('/posts/archive', $result);
Router::reset();
Router::connect('/{:controller}/{:action}', array('controller' => 'users'));
$result = Router::match(array('action' => 'view'));
$this->assertEqual('/users/view', $result);
$result = Router::match(array('controller' => 'posts', 'action' => 'view'));
$this->assertEqual('/posts/view', $result);
$result = Router::match(array('controller' => 'posts', 'action' => 'view', 'id' => '2'));
$this->assertFalse($result);
}