reload() public static method

Reloads default Router settings. Resets all class variables and removes all connected routes.
public static reload ( ) : void
return void
Exemplo n.º 1
0
 public function setUp()
 {
     parent::setUp();
     Configure::write('Routing.prefixes', ['admin']);
     Router::reload();
     $this->Html = new HtmlExtHelper(new View(null));
 }
Exemplo n.º 2
0
 public function testIs()
 {
     $result = Reveal::is('App.online');
     $expected = !in_array(gethostbyname('google.com'), array('google.com', false));
     $this->assertEqual($result, $expected);
     $result = Reveal::is('DebugKit.loaded');
     $expected = CakePlugin::loaded('DebugKit');
     $this->assertEqual($result, $expected);
     $result = Reveal::is(array('OR' => array('DebugKit.enabled', 'DebugKit.automated')));
     $expected = Configure::read('debug') || Configure::read('DebugKit.forceEnable') || Configure::read('DebugKit.autoRun');
     $this->assertEqual($result, $expected);
     $_GET['debug'] = 'true';
     $this->assertTrue(Reveal::is('DebugKit.requested'));
     $result = Reveal::is('DebugKit.loaded', array('OR' => array('DebugKit.enabled', array('AND' => array('DebugKit.automated', 'DebugKit.requested')))));
     $expected = CakePlugin::loaded('DebugKit') || Configure::read('debug') || Configure::read('DebugKit.forceEnable') || Configure::read('DebugKit.autoRun') && isset($_GET['debug']) && 'true' == $_GET['debug'];
     $this->assertEqual($result, $expected);
     $this->assertEqual(Reveal::is('DebugKit.running'), $expected);
     $request = new CakeRequest();
     Router::setRequestInfo($request->addParams(array('controller' => 'pages', 'action' => 'display', 'pass' => array('home'))));
     $result = Reveal::is('Page.front');
     $this->assertTrue($result);
     Router::reload();
     $request = new CakeRequest();
     Router::setRequestInfo($request->addParams(array('prefix' => 'admin', 'admin' => true)));
     $result = Reveal::is('Page.prefixed');
     $this->assertTrue($result);
     Router::reload();
     $request = new CakeRequest();
     Router::setRequestInfo($request->addParams(array('controller' => 'users', 'action' => 'login')));
     $result = Reveal::is('Page.login');
     $this->assertTrue($result);
     $this->assertTrue(Reveal::is('Page.test'));
 }
Exemplo n.º 3
0
 /**
  * 指定されたURLに対応しRouterパース済のCakeRequestのインスタンスを返す
  *
  * @param string $url URL
  * @return CakeRequest
  */
 protected function _getRequest($url)
 {
     Router::reload();
     $request = new CakeRequest($url);
     // コンソールからのテストの場合、requestのパラメーターが想定外のものとなってしまうので調整
     if (isConsole()) {
         $baseUrl = Configure::read('App.baseUrl');
         if ($request->url === false) {
             $request->here = $baseUrl . '/';
         } elseif (preg_match('/^' . preg_quote($request->webroot, '/') . '/', $request->here)) {
             $request->here = $baseUrl . '/' . preg_replace('/^' . preg_quote($request->webroot, '/') . '/', '', $request->here);
         }
         if ($baseUrl) {
             if (preg_match('/^\\//', $baseUrl)) {
                 $request->base = $baseUrl;
             } else {
                 $request->base = '/' . $baseUrl;
             }
             $request->webroot = $baseUrl;
         } else {
             $request->base = '';
             $request->webroot = '/';
         }
     }
     Router::setRequestInfo($request);
     $params = Router::parse($request->url);
     $request->addParams($params);
     return $request;
 }
/**
 * start a test
 *
 * @return void
 */
	public function setUp() {
		parent::setUp();
		$this->_pluginPath = App::pluginPath('AssetCompress');
		$this->_testFiles = $this->_pluginPath . 'Test' . DS . 'test_files' . DS;
		$testFile = $this->_testFiles . 'Config' . DS . 'config.ini';

		AssetConfig::clearAllCachedKeys();

		Cache::drop(AssetConfig::CACHE_CONFIG);
		Cache::config(AssetConfig::CACHE_CONFIG, array(
			'path' => TMP,
			'prefix' => 'asset_compress_test_',
			'engine' => 'File'
		));

		$controller = null;
		$request = new CakeRequest(null, false);
		$request->webroot = '';
		$view = new View($controller);
		$view->request = $request;
		$this->Helper = new AssetCompressHelper($view, array('noconfig' => true));
		$Config = AssetConfig::buildFromIniFile($testFile);
		$this->Helper->config($Config);
		$this->Helper->Html = new HtmlHelper($view);

		Router::reload();
		Configure::write('debug', 2);
	}
Exemplo n.º 5
0
 public function setUp()
 {
     parent::setUp();
     Router::reload();
     $this->View = new View();
     $this->Flash = new FlashHelper($this->View);
 }
Exemplo n.º 6
0
 /**
  * tearDown
  *
  * @return void
  */
 public function tearDown()
 {
     unset($this->BlogBaser);
     unset($this->BlogContent);
     Router::reload();
     parent::tearDown();
 }
Exemplo n.º 7
0
 /**
  * Loads routes and resets if the test case dictates it should
  *
  * @return void
  */
 protected function _loadRoutes()
 {
     parent::_loadRoutes();
     if (!$this->loadRoutes) {
         Router::reload();
     }
 }
Exemplo n.º 8
0
 function setUp()
 {
     Router::reload();
     $this->PostsController = new PostsController();
     $this->PostsController->index();
     $this->view = new View($this->PostsController);
 }
Exemplo n.º 9
0
 /**
  * tearDown
  *
  * @return void
  */
 public function tearDown()
 {
     unset($this->Toolbar, $this->Controller);
     ClassRegistry::flush();
     Router::reload();
     TestFireCake::reset();
 }
Exemplo n.º 10
0
 public function setUp()
 {
     parent::setUp();
     Router::reload();
     $View = new View(null);
     $this->Common = new CommonHelper($View);
     $this->Html = new CommonHelper($View);
 }
Exemplo n.º 11
0
 public function tearDown()
 {
     parent::tearDown();
     Configure::write('Security', $this->_initialState['Security']);
     Configure::write('Opauth', $this->_initialState['Opauth']);
     Router::reload();
     unset($this->Controller);
 }
Exemplo n.º 12
0
 /**
  * start a test
  *
  * @return void
  **/
 function startTest()
 {
     $this->_pluginPath = App::pluginPath('AssetCompress');
     $testFile = $this->_pluginPath . 'tests' . DS . 'test_files' . DS . 'config' . DS . 'config.ini';
     $this->Helper = new AssetCompressHelper(array('iniFile' => $testFile));
     $this->Helper->Html = new HtmlHelper();
     Router::reload();
     Configure::write('debug', 2);
 }
Exemplo n.º 13
0
 function setUp()
 {
     Router::reload();
     $this->Controller = new Controller();
     $this->PostsController = new ThemePostsController();
     $this->PostsController->viewPath = 'posts';
     $this->PostsController->index();
     $this->ThemeView = new ThemeView($this->PostsController);
 }
Exemplo n.º 14
0
 /**
  * Setup
  *
  * @return void
  */
 public function setUp()
 {
     Configure::write('App.linkMap', array('blogSlug' => array('preset' => array('controller' => 'blog_posts', 'action' => 'view'), 'alias' => 'BlogPost', 'fieldMap' => array('id' => '{alias}.id', 'slug' => '{alias}.slug', 'categorySlug' => 'Category.slug'), 'titleField' => 'BlogPost.title')));
     $null = null;
     $this->View = new View(null);
     $this->View->Helpers->load('Html');
     $this->Link = new LinkHelper($this->View);
     Router::reload();
     Router::connect('/article/:categorySlug/:slug-:id', array('controller' => 'blog_posts', 'action' => 'view'));
 }
Exemplo n.º 15
0
 /**
  * startTest method
  *
  * @return void
  * @access public
  */
 public function startTest()
 {
     Router::reload();
     $this->Controller = new Controller();
     $this->View = new View($this->Controller);
     $this->Controller->here = $this->View->here = '/';
     $this->Controller->params = $this->View->params = array('base' => '/', 'here' => '/', 'webroot' => '/', 'passedArgs' => array(), 'namedArgs' => array());
     $this->Menu = new TestMenuHelper();
     $this->Menu->Html = new HtmlHelper();
 }
Exemplo n.º 16
0
 function setUp()
 {
     ClassRegistry::flush();
     Router::reload();
     $null = null;
     $this->View = new View($null);
     $this->Helper = new Helper();
     $this->Cleaner = new CleanerHelper();
     $this->Cleaner->Javascript = new JavascriptHelper();
 }
 /**
  * setup create a request object to get out of router later.
  *
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     App::build(array('View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS)), App::RESET);
     Router::reload();
     $request = new CakeRequest(null, false);
     $request->base = '';
     Router::setRequestInfo($request);
     Configure::write('debug', 2);
 }
 /**
  * setup
  *
  * @return void
  **/
 function setup()
 {
     parent::setup();
     $this->_pluginPath = dirname(dirname(dirname(dirname(dirname(__FILE__)))));
     $controller = new Controller();
     $view = new View($controller);
     $view->set('basePath', $this->_pluginPath);
     $this->ApiDoc = new ApiDocHelper($view);
     Router::reload();
     Router::parse('/');
 }
Exemplo n.º 19
0
 function setUp()
 {
     ClassRegistry::flush();
     Router::reload();
     $null = null;
     $this->View = new View($null);
     $this->Helper = new Helper();
     ClassRegistry::addObject('HelperTestPost', new HelperTestPost());
     ClassRegistry::addObject('HelperTestComment', new HelperTestComment());
     ClassRegistry::addObject('HelperTestTag', new HelperTestTag());
 }
Exemplo n.º 20
0
 public function setUp()
 {
     parent::setUp();
     Configure::write('UrlCache.active', true);
     Configure::write('UrlCache.pageFiles', true);
     Configure::write('UrlCache.verbosePrefixes', true);
     Configure::write('Routing.prefixes', array('admin'));
     Router::reload();
     $this->HtmlHelper = new MyHelper(new View(new Controller(new CakeRequest('/test', false))));
     $this->HtmlHelper->beforeRender('foo');
 }
 /**
  * setup create a request object to get out of router later.
  *
  * @return void
  */
 public function setUp()
 {
     App::build(array('View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS)), true);
     Router::reload();
     $request = new CakeRequest(null, false);
     $request->base = '';
     Router::setRequestInfo($request);
     $this->_debug = Configure::read('debug');
     $this->_error = Configure::read('Error');
     Configure::write('debug', 2);
 }
Exemplo n.º 22
0
 /**
  * startTest
  *
  * @return void
  **/
 function startTest()
 {
     $this->_pluginPath = dirname(dirname(dirname(dirname(__FILE__))));
     $controller = new Controller();
     $view = new View($controller);
     $view->set('basePath', $this->_pluginPath);
     $this->ApiDoc = new ApiDocHelper();
     $this->ApiDoc->Html = new HtmlHelper();
     Router::reload();
     Router::parse('/');
 }
Exemplo n.º 23
0
 /**
  * startTest
  *
  * @return void
  * @access public
  */
 public function startTest()
 {
     ClassRegistry::flush();
     Router::reload();
     $null = null;
     $this->View = new View($null);
     ClassRegistry::removeObject('view');
     ClassRegistry::addObject('view', $this->View);
     $this->TinyMce = new TinyMceHelper();
     $this->TinyMce->Html = new HtmlHelper();
 }
Exemplo n.º 24
0
 /**
  * Setup
  *
  * @return void
  */
 public function setUp()
 {
     ClassRegistry::flush();
     Router::reload();
     $null = null;
     $this->View = new View(null);
     $this->View->Helpers->load('Time');
     $this->View->Helpers->load('Html');
     $this->View->Helpers->load('Paginator');
     $this->Table = new TableHelper($this->View);
 }
Exemplo n.º 25
0
 /**
  * setup create a request object to get out of router later.
  *
  * @return void
  */
 function setUp()
 {
     App::build(array('views' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS, TEST_CAKE_CORE_INCLUDE_PATH . 'libs' . DS . 'view' . DS)), true);
     Router::reload();
     $request = new CakeRequest(null, false);
     $request->base = '';
     Router::setRequestInfo($request);
     $this->_debug = Configure::read('debug');
     $this->_error = Configure::read('Error');
     Configure::write('debug', 2);
 }
Exemplo n.º 26
0
 /**
  * start a test
  *
  * @return void
  **/
 function startTest()
 {
     $this->_pluginPath = App::pluginPath('AssetCompress');
     $testFile = $this->_pluginPath . 'tests' . DS . 'test_files' . DS . 'config' . DS . 'config.ini';
     AssetConfig::clearAllCachedKeys();
     $this->Helper = new AssetCompressHelper(array('noconfig' => true));
     $Config = AssetConfig::buildFromIniFile($testFile);
     $this->Helper->config($Config);
     $this->Helper->Html = new HtmlHelper();
     Router::reload();
     Configure::write('debug', 2);
 }
Exemplo n.º 27
0
 /**
  * setup create a request object to get out of router later.
  *
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     App::build(array('View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS)), App::RESET);
     Router::reload();
     $request = new CakeRequest(NULL, FALSE);
     $request->base = '';
     Router::setRequestInfo($request);
     Configure::write('debug', 2);
     CakeLog::disable('stdout');
     CakeLog::disable('stderr');
 }
Exemplo n.º 28
0
 function setUp()
 {
     parent::setUp();
     Router::reload();
     Router::connect('/projects/:project_id/timelog/:action/*', array('controller' => 'timelog'), array('project_id' => '.+'));
     Router::connect('/projects/:project_id/timelog/:action/:page/:sort/:direction/*', array('controller' => 'timelog'), array('project_id' => '.+'));
     Router::connect('timelog/:action/:id/*', array('controller' => 'timelog'));
     $this->Timelog = new TimelogHelper();
     $this->Timelog->Html =& new HtmlHelper();
     $this->Controller =& new TimelogTestController();
     $this->View =& new View($this->Controller);
 }
Exemplo n.º 29
0
 function setUp()
 {
     Router::reload();
     $this->Ajax = new AjaxHelper();
     $this->Ajax->Html = new HtmlHelper();
     $this->Ajax->Form = new FormHelper();
     $this->Ajax->Javascript = new JavascriptHelper();
     $this->Ajax->Form->Html =& $this->Ajax->Html;
     $view = new View(new AjaxTestController());
     ClassRegistry::addObject('view', $view);
     ClassRegistry::addObject('PostAjaxTest', new PostAjaxTest());
 }
Exemplo n.º 30
0
 public function setUp()
 {
     ClassRegistry::flush();
     Router::reload();
     $null = null;
     $this->View = new View(null);
     $this->Helper = new Helper($this->View);
     $this->Helper = new Helper($this->View);
     $this->Cleaner = new CleanerHelper($this->View);
     $this->Cleaner->Html = new HtmlHelper($this->View);
     $this->Cleaner->Html->request = new CakeRequest(null, false);
     $this->Cleaner->Html->request->webroot = '';
 }