/** * Test splicing in paths. * * @return void */ public function testAddPaths() { $request = new CakeRequest('some/path'); $request->webroot = '/some/path/going/here/'; $result = $request->addPaths(array('random' => '/something', 'webroot' => '/', 'here' => '/', 'base' => '/base_dir')); $this->assertSame($result, $request, 'Method did not return itself. %s'); $this->assertEquals('/', $request->webroot); $this->assertEquals('/base_dir', $request->base); $this->assertEquals('/', $request->here); $this->assertFalse(isset($request->random)); }
/** * Test afterlayout element rendering * * @return void */ public function testAfterLayout() { $this->Controller->viewPath = 'Posts'; $request = new CakeRequest('/posts/index'); $request->addParams(Router::parse($request->url)); $request->addPaths(array('webroot' => '/', 'base' => '/', 'here' => '/posts/index')); $this->Controller->setRequest($request); $this->Controller->layout = 'default'; $this->Controller->uses = null; $this->Controller->components = array('DebugKit.Toolbar'); $this->Controller->constructClasses(); $this->Controller->Components->trigger('startup', array($this->Controller)); $this->Controller->Components->trigger('beforeRender', array($this->Controller)); $result = $this->Controller->render(); $this->assertNotRegExp('/debug-toolbar/', (string) $result); $result = $this->firecake->sentHeaders; $this->assertTrue(is_array($result)); }
/** * test injection of javascript * * @return void **/ public function testJavascriptInjection() { $this->Controller->viewPath = 'posts'; $this->Controller->uses = null; $request = new CakeRequest('/posts/index'); $request->addParams(Router::parse($request->url)); $request->addPaths(array('webroot' => '/', 'base' => '/', 'here' => '/posts/index')); $this->Controller->setRequest($request); $this->Controller->helpers = array('Js', 'Html', 'Session'); $this->Controller->components = array('DebugKit.Toolbar'); $this->Controller->layout = 'default'; $this->Controller->constructClasses(); $this->Controller->Components->trigger('startup', array($this->Controller)); $this->Controller->Components->trigger('beforeRender', array($this->Controller)); $result = $this->Controller->render(); $result = str_replace(array("\n", "\r"), '', $result); $this->assertPattern('#<script\\s*type="text/javascript"\\s*src="/debug_kit/js/js_debug_toolbar.js(:?\\?\\d*?)?"\\s*>\\s?</script>#', $result); }
/** * test rendering and ensure that timers are being set. * * @return void */ public function testRenderTimers() { $request = new CakeRequest('/posts/index'); $request->addParams(Router::parse($request->url)); $request->addPaths(array('webroot' => '/', 'base' => '/', 'here' => '/posts/index')); $this->Controller->setRequest($request); $this->Controller->viewPath = 'posts'; $this->Controller->layout = 'default'; $View = new DebugView($this->Controller, false); $View->render('index'); $result = DebugKitDebugger::getTimers(); $this->assertEqual(count($result), 4); $this->assertTrue(isset($result['viewRender'])); $this->assertTrue(isset($result['render_default.ctp'])); $this->assertTrue(isset($result['render_index.ctp'])); $result = DebugKitDebugger::getMemoryPoints(); $this->assertTrue(isset($result['View render complete'])); }