public function testNoSrcContext() { $e = $this->getTestException(1); ExceptionCaster::$srcContext = -1; $expectedDump = <<<'EODUMP' Exception { #message: "foo" #code: 0 #file: "%sExceptionCasterTest.php" #line: 23 -trace: { %d. %sExceptionCasterTest.php: 23 %d. %sExceptionCasterTest.php: %d %A EODUMP; $this->assertDumpMatchesFormat($expectedDump, $e); }
public static function castReflectionGenerator(\ReflectionGenerator $c, array $a, Stub $stub, $isNested) { $prefix = Caster::PREFIX_VIRTUAL; if ($c->getThis()) { $a[$prefix . 'this'] = new CutStub($c->getThis()); } $x = $c->getFunction(); $frame = array('class' => isset($x->class) ? $x->class : null, 'type' => isset($x->class) ? $x->isStatic() ? '::' : '->' : null, 'function' => $x->name, 'file' => $c->getExecutingFile(), 'line' => $c->getExecutingLine()); if ($trace = $c->getTrace(DEBUG_BACKTRACE_IGNORE_ARGS)) { $x = new \ReflectionGenerator($c->getExecutingGenerator()); array_unshift($trace, array('function' => 'yield', 'file' => $x->getExecutingFile(), 'line' => $x->getExecutingLine() - 1)); $trace[] = $frame; $a[$prefix . 'trace'] = new TraceStub($trace, false, 0, -1, -1); } else { $x = new FrameStub($frame, false, true); $x = ExceptionCaster::castFrameStub($x, array(), $x, true); $a[$prefix . 'executing'] = new EnumStub(array($frame['class'] . $frame['type'] . $frame['function'] . '()' => $x[$prefix . 'src'])); } return $a; }
public function testHtmlDump() { $e = $this->getTestException(1); ExceptionCaster::$srcContext = -1; $cloner = new VarCloner(); $cloner->setMaxItems(1); $dumper = new HtmlDumper(); $dumper->setDumpHeader('<foo></foo>'); $dumper->setDumpBoundaries('<bar>', '</bar>'); $dump = $dumper->dump($cloner->cloneVar($e)->withRefHandles(false), true); $expectedDump = <<<'EODUMP' <foo></foo><bar><span class=sf-dump-note>Exception</span> {<samp> #<span class=sf-dump-protected title="Protected property">message</span>: "<span class=sf-dump-str title="3 characters">foo</span>" #<span class=sf-dump-protected title="Protected property">code</span>: <span class=sf-dump-num>0</span> #<span class=sf-dump-protected title="Protected property">file</span>: "<span class=sf-dump-str title="%sExceptionCasterTest.php %d characters"><span class=sf-dump-ellipsis>%sTests</span>%eCaster%eExceptionCasterTest.php</span>" #<span class=sf-dump-protected title="Protected property">line</span>: <span class=sf-dump-num>25</span> -<span class=sf-dump-private title="Private property defined in class: `Exception`">trace</span>: {<samp> <span class=sf-dump-meta title="%sExceptionCasterTest.php Stack level %d."><span class=sf-dump-ellipsis>%sVarDumper%eTests</span>%eCaster%eExceptionCasterTest.php</span>: <span class=sf-dump-num>25</span> …12 </samp>} </samp>} </bar> EODUMP; $this->assertStringMatchesFormat($expectedDump, $dump); }