mirror of
https://github.com/filp/whoops.git
synced 2026-09-17 21:26:34 +00:00
Add a test for not registered on shutdown
This commit is contained in:
@@ -12,7 +12,10 @@ use InvalidArgumentException;
|
||||
use Mockery as m;
|
||||
use RuntimeException;
|
||||
use Whoops\Handler\Handler;
|
||||
use Whoops\Handler\HandlerInterface;
|
||||
use Whoops\Handler\PrettyPageHandler;
|
||||
use Whoops\Exception\Frame;
|
||||
use Whoops\Util\SystemFacade;
|
||||
|
||||
class RunTest extends TestCase
|
||||
{
|
||||
@@ -571,4 +574,36 @@ class RunTest extends TestCase
|
||||
$this->assertEmpty($run->getFrameFilters());
|
||||
$this->assertInstanceOf("Whoops\\RunInterface", $run);
|
||||
}
|
||||
|
||||
public function testShutdownHandlerDoesNotRunIfUnregistered()
|
||||
{
|
||||
$system = m::mock('Whoops\Util\SystemFacade');
|
||||
|
||||
$run = new Run($system);
|
||||
$run->writeToOutput(false);
|
||||
$run->allowQuit(false);
|
||||
|
||||
$fatalError = [
|
||||
'type' => E_ERROR,
|
||||
'message' => 'Simulated fatal error for shutdown',
|
||||
'file' => 'somefile.php',
|
||||
'line' => 10,
|
||||
];
|
||||
$system->shouldReceive('getLastError')->andReturn($fatalError)->byDefault();
|
||||
|
||||
$mockHandler = m::mock('Whoops\Handler\HandlerInterface');
|
||||
$mockHandler->shouldNotReceive('handle');
|
||||
$mockHandler->shouldNotReceive('setRun');
|
||||
$mockHandler->shouldNotReceive('setInspector');
|
||||
$mockHandler->shouldNotReceive('setException');
|
||||
$run->pushHandler($mockHandler);
|
||||
|
||||
$run->unregister();
|
||||
|
||||
ob_start();
|
||||
$run->handleShutdown();
|
||||
$output = ob_get_clean();
|
||||
|
||||
$this->assertEquals('', $output, "Output buffer should be empty.");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user