mirror of
https://github.com/filp/whoops.git
synced 2026-09-12 02:36:20 +00:00
Add FramesIterator & tests
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
/**
|
||||
* Damnit - php errors for cool kids
|
||||
* @author Filipe Dobreira <http://github.com/filp>
|
||||
*/
|
||||
|
||||
namespace Damnit\Exception;
|
||||
use \ArrayIterator;
|
||||
|
||||
/**
|
||||
* @todo might be removed soon-ish
|
||||
*/
|
||||
class FrameIterator extends ArrayIterator {}
|
||||
@@ -5,13 +5,9 @@
|
||||
*/
|
||||
|
||||
namespace Damnit\Exception;
|
||||
use Damnit\Exception\FrameIterator;
|
||||
use \Exception;
|
||||
|
||||
/**
|
||||
* The Inspector is able to lazily inspect an
|
||||
* exception, and gather information about its
|
||||
* related components.
|
||||
*/
|
||||
class Inspector
|
||||
{
|
||||
/**
|
||||
@@ -34,4 +30,15 @@ class Inspector
|
||||
{
|
||||
return $this->exception;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an iterator for the inspected exception's
|
||||
* frames.
|
||||
* @return DamnIt\Exception\FrameIterator
|
||||
*/
|
||||
public function getFrames()
|
||||
{
|
||||
$iterator = new FrameIterator($this->exception->getTrace());
|
||||
return $iterator;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,8 +22,8 @@ class InspectorTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers DamnIt\Exception\Inspector::__construct
|
||||
* @covers DamnIt\Exception\Inspector::getException
|
||||
* @covers Damnit\Exception\Inspector::__construct
|
||||
* @covers Damnit\Exception\Inspector::getException
|
||||
*/
|
||||
public function testExceptionIsStoredAndReturned()
|
||||
{
|
||||
@@ -32,4 +32,15 @@ class InspectorTest extends TestCase
|
||||
|
||||
$this->assertSame($exception, $inspector->getException());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Damnit\Exception\Inspector::getFrames
|
||||
*/
|
||||
public function testGetFramesReturnsIterator()
|
||||
{
|
||||
$exception = new RuntimeException;
|
||||
$inspector = $this->getInspectorInstance($exception);
|
||||
|
||||
$this->assertInstanceOf('Damnit\\Exception\\FrameIterator', $inspector->getFrames());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user