it("returns a custom backtrace string", function () { $backtrace = Debugger::trace(['trace' => debug_backtrace()]); expect($backtrace)->toBeA('string'); $backtrace = explode("\n", $backtrace); expect(empty($backtrace))->toBe(false); }); it("returns a backtrace of an Exception", function () { $backtrace = Debugger::trace(['trace' => new Exception('World Destruction Error!')]); expect($backtrace)->toBeA('string'); $backtrace = explode("\n", $backtrace); expect(empty($backtrace))->toBe(false); }); it("returns a trace from eval'd code", function () { $trace = debug_backtrace(); $trace[1]['file'] = "eval()'d code"; $backtrace = Debugger::trace(['trace' => $trace]); expect($backtrace)->toBeA('string'); $trace = current(explode("\n", $backtrace)); expect($trace)->toMatch('~kahlan[/|\\\\]src[/|\\\\]Specification.php~'); }); describe("::_line()", function () { beforeEach(function () { $this->debugger = Stub::classname(['extends' => 'Kahlan\\Analysis\\Debugger', 'methods' => ['::line']]); Stub::on($this->debugger)->method('::line', function ($trace) { return static::_line($trace); }); }); it("returns `null` with non-existing files", function () { $debugger = $this->debugger; $trace = ['file' => DS . 'some' . DS . 'none' . DS . 'existant' . DS . 'path' . DS . 'file.php', 'line' => null]; expect($debugger::line($trace))->toBe(null);
/** * Prints focused report to STDOUT * * @param array $report A report array. */ protected function _reportFocused($report) { if (!($backtraces = $report['focuses'])) { return; } $this->write("Focus Mode Detected in the following files:\n", 'b;yellow;'); foreach ($backtraces as $backtrace) { $this->write(Debugger::trace(['trace' => $backtrace, 'depth' => 1]), 'n;yellow'); $this->write("\n"); } $this->write("exit(-1)\n\n", 'red'); }