Fix typo and add tests

This commit is contained in:
filp
2013-04-24 16:54:10 +01:00
parent 0cef7df735
commit 69a01d955b
2 changed files with 38 additions and 5 deletions
+5 -4
View File
@@ -149,14 +149,15 @@ class Run
return $this->sendOutput;
}
return $this->sendOutput = (bool) $exit;
return $this->sendOutput = (bool) $send;
}
/**
* Handles an exception, ultimately generating a Whoops error
* page.
*
* @param Exception $exception
* @param Exception $exception
* @return string Output generated by handlers
*/
public function handleException(Exception $exception)
{
@@ -201,9 +202,9 @@ class Run
// the caller.
if($this->writeToOutput()) {
echo $output;
} else {
return $output;
}
return $output;
}
}
+33 -1
View File
@@ -23,7 +23,7 @@ class RunTest extends TestCase
{
return m::mock('Exception', array($message));
}
/**
* @return Whoops\Handler\Handler
*/
@@ -275,4 +275,36 @@ class RunTest extends TestCase
error_reporting($oldLevel);
}
/**
* @covers Whoops\Run::handleException
* @covers Whoops\Run::writeToOutput
*/
public function testOutputIsSent()
{
$run = $this->getRunInstance();
$run->pushHandler(function() {
echo "hello there";
});
ob_start();
$run->handleException(new RuntimeException);
$this->assertEquals("hello there", ob_get_clean());
}
/**
* @covers Whoops\Run::handleException
* @covers Whoops\Run::writeToOutput
*/
public function testOutputIsNotSent()
{
$run = $this->getRunInstance();
$run->writeToOutput(false);
$run->pushHandler(function() {
echo "hello there";
});
ob_start();
$this->assertEquals("hello there", $run->handleException(new RuntimeException));
$this->assertEquals("", ob_get_clean());
}
}