Exemple #1
0
 /**
  * Test adding a format that is handled by a callback.
  *
  * @return void
  */
 public function testAddFormatCallback()
 {
     set_error_handler('Cake\\Error\\Debugger::showError');
     $this->_restoreError = true;
     Debugger::addFormat('callback', array('callback' => array($this, 'customFormat')));
     Debugger::outputAs('callback');
     ob_start();
     $foo .= '';
     $result = ob_get_clean();
     $this->assertContains('Notice: I eated an error', $result);
     $this->assertContains('DebuggerTest.php', $result);
 }
 /**
  * Test adding a format that is handled by a callback.
  *
  * @return void
  */
 public function testAddFormatCallback()
 {
     Debugger::addFormat('callback', ['callback' => [$this, 'customFormat']]);
     Debugger::outputAs('callback');
     ob_start();
     $debugger = Debugger::getInstance();
     $debugger->outputError(['error' => 'Notice', 'code' => E_NOTICE, 'level' => E_NOTICE, 'description' => 'Undefined variable $foo', 'file' => __FILE__, 'line' => __LINE__]);
     $result = ob_get_clean();
     $this->assertContains('Notice: I eated an error', $result);
     $this->assertContains('DebuggerTest.php', $result);
 }
Exemple #3
0
 /**
  * Switches output format, updates format strings.
  * Can be used to switch the active output format:
  *
  * @param string $format Format to use, including 'js' for JavaScript-enhanced HTML, 'html' for
  *    straight HTML output, or 'txt' for unformatted text.
  * @param array $strings Template strings to be used for the output format.
  * @return string
  * @deprecated 3.0.0 Use Debugger::outputAs() and Debugger::addFormat(). Will be removed
  *   in 3.0
  */
 public static function output($format = null, $strings = array())
 {
     $self = Debugger::getInstance();
     $data = null;
     if ($format === null) {
         return Debugger::outputAs();
     }
     if (!empty($strings)) {
         return Debugger::addFormat($format, $strings);
     }
     if ($format === true && !empty($self->_data)) {
         $data = $self->_data;
         $self->_data = array();
         $format = false;
     }
     Debugger::outputAs($format);
     return $data;
 }