|
12 | 12 | use Mockery as m; |
13 | 13 | use RuntimeException; |
14 | 14 | use Whoops\Handler\Handler; |
| 15 | +use Whoops\Handler\HandlerInterface; |
| 16 | +use Whoops\Handler\PrettyPageHandler; |
15 | 17 | use Whoops\Exception\Frame; |
| 18 | +use Whoops\Util\SystemFacade; |
16 | 19 |
|
17 | 20 | class RunTest extends TestCase |
18 | 21 | { |
@@ -571,4 +574,36 @@ public function testClearFrameFilters() |
571 | 574 | $this->assertEmpty($run->getFrameFilters()); |
572 | 575 | $this->assertInstanceOf("Whoops\\RunInterface", $run); |
573 | 576 | } |
| 577 | + |
| 578 | + public function testShutdownHandlerDoesNotRunIfUnregistered() |
| 579 | + { |
| 580 | + $system = m::mock('Whoops\Util\SystemFacade'); |
| 581 | + |
| 582 | + $run = new Run($system); |
| 583 | + $run->writeToOutput(false); |
| 584 | + $run->allowQuit(false); |
| 585 | + |
| 586 | + $fatalError = [ |
| 587 | + 'type' => E_ERROR, |
| 588 | + 'message' => 'Simulated fatal error for shutdown', |
| 589 | + 'file' => 'somefile.php', |
| 590 | + 'line' => 10, |
| 591 | + ]; |
| 592 | + $system->shouldReceive('getLastError')->andReturn($fatalError)->byDefault(); |
| 593 | + |
| 594 | + $mockHandler = m::mock('Whoops\Handler\HandlerInterface'); |
| 595 | + $mockHandler->shouldNotReceive('handle'); |
| 596 | + $mockHandler->shouldNotReceive('setRun'); |
| 597 | + $mockHandler->shouldNotReceive('setInspector'); |
| 598 | + $mockHandler->shouldNotReceive('setException'); |
| 599 | + $run->pushHandler($mockHandler); |
| 600 | + |
| 601 | + $run->unregister(); |
| 602 | + |
| 603 | + ob_start(); |
| 604 | + $run->handleShutdown(); |
| 605 | + $output = ob_get_clean(); |
| 606 | + |
| 607 | + $this->assertEquals('', $output, "Output buffer should be empty."); |
| 608 | + } |
574 | 609 | } |
0 commit comments