Ejemplo n.º 1
0
 /**
  * test making memory use markers.
  *
  * @return void
  **/
 function testMemorySettingAndGetting()
 {
     $result = DebugKitDebugger::setMemoryPoint('test marker');
     $this->assertTrue($result);
     $result = DebugKitDebugger::getMemoryPoints(true);
     $this->assertEqual(count($result), 1);
     $this->assertTrue(isset($result['test marker']));
     $this->assertTrue(is_numeric($result['test marker']));
     $result = DebugKitDebugger::getMemoryPoints();
     $this->assertTrue(empty($result));
     DebugKitDebugger::setMemoryPoint('test marker');
     DebugKitDebugger::setMemoryPoint('test marker');
     $result = DebugKitDebugger::getMemoryPoints();
     $this->assertEqual(count($result), 2);
     $this->assertTrue(isset($result['test marker']));
     $this->assertTrue(isset($result['test marker #2']));
 }
/**
 * Test Before Render callback
 *
 * @return void
 **/
	public function testBeforeRender() {
		$this->_loadController(array(
			'panels' => array('test', 'session'),
		));
		$MockPanel = $this->getMock('DebugPanel');
		$MockPanel->expects($this->once())->method('beforeRender');
		$this->Controller->Toolbar->panels['test'] = $MockPanel;
		$this->Controller->Toolbar->beforeRender($this->Controller);

		$this->assertTrue(isset($this->Controller->viewVars['debugToolbarPanels']));
		$vars = $this->Controller->viewVars['debugToolbarPanels'];

		$expected = array(
			'plugin' => 'debug_kit',
			'elementName' => 'session_panel',
			'content' => $this->Controller->Toolbar->Session->read(),
			'disableTimer' => true,
			'title' => ''
		);
		$this->assertEqual($expected, $vars['session']);

		$memory = DebugKitDebugger::getMemoryPoints();
		$this->assertTrue(isset($memory['Controller render start']));
	}
 /**
  * Test Before Render callback
  *
  * @return void
  **/
 function testBeforeRender()
 {
     $this->Controller->components = array('DebugKit.Toolbar' => array('panels' => array('MockDebug', 'session')));
     $this->Controller->Component->init($this->Controller);
     $this->Controller->Component->initialize($this->Controller);
     $this->Controller->Toolbar->panels['MockDebug']->expectOnce('beforeRender');
     $this->Controller->Toolbar->beforeRender($this->Controller);
     $this->assertTrue(isset($this->Controller->viewVars['debugToolbarPanels']));
     $vars = $this->Controller->viewVars['debugToolbarPanels'];
     $expected = array('plugin' => 'debug_kit', 'elementName' => 'session_panel', 'content' => $this->Controller->Toolbar->Session->read(), 'disableTimer' => true, 'title' => '');
     $this->assertEqual($expected, $vars['session']);
     $memory = DebugKitDebugger::getMemoryPoints();
     $this->assertTrue(isset($memory['Controller render start']));
 }
 /**
  * test rendering and ensure that timers are being set.
  *
  * @access public
  * @return void
  */
 function testRenderTimers()
 {
     $this->Controller->viewPath = 'posts';
     $this->Controller->action = 'index';
     $this->Controller->params = array('action' => 'index', 'controller' => 'posts', 'plugin' => null, 'url' => array('url' => 'posts/index'), 'base' => null, 'here' => '/posts/index');
     $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']));
 }
Ejemplo n.º 5
0
 /**
  * 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']));
 }