Skip to content

Commit db0f04f

Browse files
committed
Add a test for not registered on shutdown
1 parent ff25251 commit db0f04f

1 file changed

Lines changed: 35 additions & 0 deletions

File tree

tests/Whoops/RunTest.php

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@
1212
use Mockery as m;
1313
use RuntimeException;
1414
use Whoops\Handler\Handler;
15+
use Whoops\Handler\HandlerInterface;
16+
use Whoops\Handler\PrettyPageHandler;
1517
use Whoops\Exception\Frame;
18+
use Whoops\Util\SystemFacade;
1619

1720
class RunTest extends TestCase
1821
{
@@ -571,4 +574,36 @@ public function testClearFrameFilters()
571574
$this->assertEmpty($run->getFrameFilters());
572575
$this->assertInstanceOf("Whoops\\RunInterface", $run);
573576
}
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+
}
574609
}

0 commit comments

Comments
 (0)