mirror of
https://github.com/filp/whoops.git
synced 2026-09-04 22:48:11 +00:00
Fix typo and add tests
This commit is contained in:
+5
-4
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user