本文整理汇总了PHP中Cake\Routing\Router::reload方法的典型用法代码示例。如果您正苦于以下问题:PHP Router::reload方法的具体用法?PHP Router::reload怎么用?PHP Router::reload使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cake\Routing\Router
的用法示例。
在下文中一共展示了Router::reload方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUp
/**
* @return void
*/
public function setUp()
{
parent::setUp();
Router::reload();
$View = new View(null);
$this->Common = new CommonHelper($View);
}
示例2: testBuildResetWithPlugin
/**
* @return void
*/
public function testBuildResetWithPlugin()
{
Router::connect('/:controller/:action/*');
$result = $this->Url->buildReset(['controller' => 'foobar', 'action' => 'test']);
$expected = '/foobar/test';
$this->assertSame($expected, $result);
$this->Url->request->here = '/admin/foo/bar/baz/test';
$this->Url->request->params['prefix'] = 'admin';
$this->Url->request->params['plugin'] = 'Foo';
Router::reload();
Router::connect('/:controller/:action/*');
Router::plugin('Foo', function ($routes) {
$routes->fallbacks();
});
Router::prefix('admin', function ($routes) {
$routes->plugin('Foo', function ($routes) {
$routes->fallbacks();
});
});
Plugin::routes();
Router::pushRequest($this->Url->request);
$result = $this->Url->build(['controller' => 'bar', 'action' => 'baz', 'x']);
$expected = '/admin/foo/bar/baz/x';
$this->assertSame($expected, $result);
$result = $this->Url->buildReset(['controller' => 'bar', 'action' => 'baz', 'x']);
$expected = '/bar/baz/x';
$this->assertSame($expected, $result);
}
示例3: testQueryStringAndCustomTime
/**
* test setting parameters in beforeDispatch method
*
* @return void
*/
public function testQueryStringAndCustomTime()
{
$folder = CACHE . 'views' . DS;
$file = $folder . 'posts-home-coffee-life-sleep-sissies-coffee-life-sleep-sissies.html';
$content = '<!--cachetime:' . (time() + WEEK) . ';ext:html-->Foo bar';
file_put_contents($file, $content);
Router::reload();
Router::connect('/', ['controller' => 'Pages', 'action' => 'display', 'home']);
Router::connect('/pages/*', ['controller' => 'Pages', 'action' => 'display']);
Router::connect('/:controller/:action/*');
$_GET = ['coffee' => 'life', 'sleep' => 'sissies'];
$filter = new CacheFilter();
$request = new Request('posts/home/?coffee=life&sleep=sissies');
$response = new Response();
$event = new Event(__CLASS__, $this, compact('request', 'response'));
$filter->beforeDispatch($event);
$result = $response->body();
$expected = '<!--created:';
$this->assertTextStartsWith($expected, $result);
$expected = '-->Foo bar';
$this->assertTextEndsWith($expected, $result);
$result = $response->type();
$expected = 'text/html';
$this->assertEquals($expected, $result);
$result = $response->header();
$this->assertNotEmpty($result['Expires']);
// + 1 week
unlink($file);
}
示例4: testResetLink
/**
* Tests
*
* @return void
*/
public function testResetLink()
{
Router::connect('/:controller/:action/*');
$result = $this->Html->resetLink('Foo', ['controller' => 'foobar', 'action' => 'test']);
$expected = '<a href="/foobar/test">Foo</a>';
$this->assertEquals($expected, $result);
$this->Html->request->here = '/admin/foobar/test';
$this->Html->request->params['admin'] = true;
$this->Html->request->params['prefix'] = 'admin';
Router::reload();
Router::connect('/:controller/:action/*');
Router::prefix('admin', function ($routes) {
$routes->connect('/:controller/:action/*');
});
$result = $this->Html->link('Foo', ['prefix' => 'admin', 'controller' => 'foobar', 'action' => 'test']);
$expected = '<a href="/admin/foobar/test">Foo</a>';
$this->assertEquals($expected, $result);
$result = $this->Html->link('Foo', ['controller' => 'foobar', 'action' => 'test']);
$expected = '<a href="/admin/foobar/test">Foo</a>';
//debug($result);
//$this->assertEquals($expected, $result);
$result = $this->Html->resetLink('Foo', ['controller' => 'foobar', 'action' => 'test']);
$expected = '<a href="/foobar/test">Foo</a>';
$this->assertEquals($expected, $result);
}
示例5: setUp
/**
* setUp method
*
* @return void
*/
public function setUp()
{
parent::setUp();
Router::reload();
Router::connect('/:controller', ['action' => 'index']);
Router::connect('/:controller/:action/*');
}
示例6: _loadRoutes
/**
* Loads routes and resets if the test case dictates it should
*
* @return void
*/
protected function _loadRoutes()
{
parent::_loadRoutes();
if (!$this->loadRoutes) {
Router::reload();
}
}
示例7: setUp
/**
* @return void
*/
public function setUp()
{
parent::setUp();
Router::reload();
$View = new View(null);
$this->Flash = new FlashHelper($View);
}
示例8: setUp
/**
* setUp method
*
* @return void
*/
public function setUp()
{
parent::setUp();
Router::reload();
$this->View = new View();
$this->Helper = new Helper($this->View);
$this->Helper->request = new Request();
}
示例9: setUp
public function setUp()
{
parent::setUp();
Router::reload();
Configure::write('App.namespace', 'Spekkoek\\Test\\TestApp');
$this->dispatcher = new ActionDispatcher();
$this->dispatcher->addFilter(new ControllerFactoryFilter());
}
示例10: setUp
/**
* reset environment.
*
* @return void
*/
public function setUp()
{
parent::setUp();
Configure::write('App.namespace', 'TestApp');
Plugin::load(array('TestPlugin', 'TestPluginTwo'));
$this->Case = $this->getMockForAbstractClass('Cake\\TestSuite\\ControllerTestCase');
Router::reload();
TableRegistry::clear();
}
示例11: setUp
/**
* setup
*
* @return void
*/
public function setUp()
{
parent::setUp();
Configure::write('Routing.prefixes', []);
Router::reload();
$this->Acl = $this->getMockBuilder('Acl\\Controller\\Component\\AclComponent')->disableOriginalConstructor()->getMock();
$this->Components = $this->getMockBuilder('Cake\\Controller\\ComponentRegistry')->getMock();
$this->auth = new CrudAuthorize($this->Components);
}
示例12: setUp
/**
* setup
*
* @return void
*/
public function setUp()
{
parent::setUp();
Configure::write('Routing.prefixes', array());
Router::reload();
$this->Acl = $this->getMock('Acl\\Controller\\Component\\AclComponent', array(), array(), '', false);
$this->Components = $this->getMock('Cake\\Controller\\ComponentRegistry');
$this->auth = new CrudAuthorize($this->Components);
}
示例13: setUp
/**
* setUp method
*
* @return void
*/
public function setUp()
{
parent::setUp();
Router::reload();
$this->View = new View();
$this->Helper = new UrlHelper($this->View);
$this->Helper->request = new Request();
Configure::write('App.namespace', 'TestApp');
Plugin::load(['TestTheme']);
}
示例14: testGetRelationLink
/**
* Test initial setup
*
* @return void
*/
public function testGetRelationLink()
{
$userId = '481fc6d0-b920-43e0-a40d-6d1740cf8562';
$articlesId = '99dbcad7-21d5-4dd1-b193-e00543c0224c';
$article = $this->Articles->newEntity(['title' => 'title', 'content' => 'content']);
$fieldValue = 123;
Router::reload();
$relationLink = $this->Articles->getRelationLink('foobar', $fieldValue);
$this->assertEquals($fieldValue, $relationLink);
}
示例15: setUp
/**
* setup create a request object to get out of router later.
*
* @return void
*/
public function setUp()
{
parent::setUp();
Router::reload();
$request = new Request();
$request->base = '';
Router::setRequestInfo($request);
Configure::write('debug', true);
$this->_logger = $this->getMock('Psr\\Log\\LoggerInterface');
Log::reset();
Log::config('error_test', ['engine' => $this->_logger]);
}