public function testFormat() { $each = $this->getMock('\\r8\\iface\\Backtrace\\Formatter'); $each->expects($this->at(0))->method('prefix')->will($this->returnValue("[prefix]")); $each->expects($this->at(1))->method('event')->with($this->equalTo(2), $this->equalTo("function"), $this->equalTo(array("arg")), $this->equalTo("/example/file.php"), $this->equalTo(5050))->will($this->returnValue("[event2]")); $each->expects($this->at(2))->method('event')->with($this->equalTo(1), $this->equalTo("method"), $this->equalTo(array(1234)), $this->equalTo("/example/other.php"), $this->equalTo(1000))->will($this->returnValue("[event1]")); $each->expects($this->at(3))->method('main')->with($this->equalTo(0), $this->equalTo("/example/main.php"))->will($this->returnValue("[main]")); $each->expects($this->at(4))->method('suffix')->will($this->returnValue("[suffix]")); $format = new \r8\Backtrace\Formatter($each); $backtrace = new \r8\Backtrace(); $backtrace->pushEvent($this->getMockEvent("function", array("arg"), "/example/file.php", 5050)); $backtrace->pushEvent($this->getMockEvent("method", array(1234), "/example/other.php", 1000)); $backtrace->pushEvent($this->getMockMain("/example/main.php")); $this->assertSame("[prefix][event2][event1][main][suffix]", $format->format($backtrace)); }
public function testPopEvent() { $backtrace = new \r8\Backtrace(); $events = array($this->getMockEvent(), $this->getMockEvent(), $this->getMockEvent()); $backtrace->pushEvent($events[0]); $backtrace->pushEvent($events[1]); $backtrace->pushEvent($events[2]); $this->assertSame(3, $backtrace->count()); $this->assertSame($backtrace, $backtrace->popEvent()); $this->assertSame(array($events[1], $events[2]), $backtrace->getEvents()); }