public function testInvoke()
 {
     $var = 'bar';
     Debug::dump($var);
     $system = System::init([], true);
     $view = $this->getMock(View::CLASS, ['render']);
     $services = new Services();
     $services->set('System', $system);
     $services->set('View', $view);
     $this->setServices($services);
     $html = '<body></body>';
     $stream = Stream::make($html);
     $response = new Response(200, $stream, ['Content-Type' => ['text/html']]);
     $event = new SystemEvent();
     $event->setResult(SystemEvent::FINISH, $response);
     $model = new ViewModel();
     $listener = new InjectDumpListener();
     $listener->setModel($model);
     $view->expects($this->once())->method('render')->with($this->identicalTo($model))->will($this->returnValue('foo'));
     $listener($event);
     $this->assertTrue(isset($model['dumps']));
     $this->assertSame($model['dumps'], Debug::getDumpInstances());
     $injected = $event->getResult(SystemEvent::FINISH);
     $this->assertInstanceOf(Response::CLASS, $injected);
     $body = $injected->getBody();
     $this->assertSame('<body>foo</body>', (string) $body);
 }
Exemplo n.º 2
0
 public function testGetDumpInstances()
 {
     Debug::dump($this);
     $line = __LINE__ - 1;
     $instances = Debug::getDumpInstances();
     $this->assertInternalType('array', $instances);
     $this->assertSame(1, count($instances));
     $this->assertInstanceOf(Dump::CLASS, $instances[0]);
     $dump = $instances[0];
     $this->assertSame($dump->getLine(), $line);
     $this->assertSame($dump->getFile(), __FILE__);
 }