Add Inspector::getExceptionName & re-structure tests

This commit is contained in:
filp
2013-03-12 13:14:12 +00:00
parent 20ca8ccca4
commit 652ff42c98
4 changed files with 33 additions and 12 deletions
+8
View File
@@ -31,6 +31,14 @@ class Inspector
return $this->exception;
}
/**
* @return string
*/
public function getExceptionName()
{
return get_class($this->exception);
}
/**
* Returns an iterator for the inspected exception's
* frames.
+13 -2
View File
@@ -21,13 +21,24 @@ class InspectorTest extends TestCase
return new Inspector($exception);
}
/**
* @covers Damnit\Exception\Inspector::getExceptionName
*/
public function testReturnsCorrectExceptionName()
{
$exception = $this->getException();
$inspector = $this->getInspectorInstance($exception);
$this->assertEquals(get_class($exception), $inspector->getExceptionName());
}
/**
* @covers Damnit\Exception\Inspector::__construct
* @covers Damnit\Exception\Inspector::getException
*/
public function testExceptionIsStoredAndReturned()
{
$exception = new RuntimeException;
$exception = $this->getException();
$inspector = $this->getInspectorInstance($exception);
$this->assertSame($exception, $inspector->getException());
@@ -38,7 +49,7 @@ class InspectorTest extends TestCase
*/
public function testGetFramesReturnsIterator()
{
$exception = new RuntimeException;
$exception = $this->getException();
$inspector = $this->getInspectorInstance($exception);
$this->assertInstanceOf('Damnit\\Exception\\FrameIterator', $inspector->getFrames());
-9
View File
@@ -30,15 +30,6 @@ class RunTest extends TestCase
return m::mock('Damnit\\Handler\\Handler');
}
/**
* @param string $message
* @return Exception
*/
protected function getException($message = null)
{
return m::mock('Exception', array($message));
}
/**
* @covers Damnit\Run::clearHandlers
*/
+12 -1
View File
@@ -5,5 +5,16 @@
*/
namespace Damnit;
use \Mockery as m;
class TestCase extends \PHPUnit_Framework_TestCase {}
class TestCase extends \PHPUnit_Framework_TestCase
{
/**
* @param string $message
* @return Exception
*/
protected function getException($message = null)
{
return m::mock('Exception', array($message));
}
}