mirror of
https://github.com/filp/whoops.git
synced 2026-09-13 03:06:20 +00:00
removeFirstHandler and removeLastHandler
This commit is contained in:
+18
-2
@@ -72,8 +72,7 @@ final class Run implements RunInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the last handler in the stack and returns it.
|
||||
* Returns null if there"s nothing else to pop.
|
||||
* See removeFirstHandler and removeLastHandler
|
||||
* @return null|HandlerInterface
|
||||
*/
|
||||
public function popHandler()
|
||||
@@ -81,6 +80,23 @@ final class Run implements RunInterface
|
||||
return array_pop($this->handlerStack);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Removes the first handler
|
||||
*/
|
||||
public function removeFirstHandler()
|
||||
{
|
||||
array_pop($this->handlerStack);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the last handler
|
||||
*/
|
||||
public function removeLastHandler()
|
||||
{
|
||||
array_shift($this->handlerStack);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array with all handlers, in the
|
||||
* order they were added to the stack.
|
||||
|
||||
@@ -141,6 +141,30 @@ class RunTest extends TestCase
|
||||
$this->assertEmpty($run->getHandlers());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Whoops\Run::removeFirstHandler
|
||||
* @covers Whoops\Run::removeLastHandler
|
||||
* @covers Whoops\Run::getHandlers
|
||||
*/
|
||||
public function testRemoveHandler()
|
||||
{
|
||||
$run = $this->getRunInstance();
|
||||
|
||||
$handlerOne = $this->getHandler();
|
||||
$handlerTwo = $this->getHandler();
|
||||
$handlerThree = $this->getHandler();
|
||||
|
||||
$run->pushHandler($handlerOne);
|
||||
$run->pushHandler($handlerTwo);
|
||||
$run->pushHandler($handlerThree);
|
||||
|
||||
$run->removeLastHandler();
|
||||
$this->assertSame($handlerTwo, $run->getHandlers()[0]);
|
||||
$run->removeFirstHandler();
|
||||
$this->assertSame($handlerTwo, $run->getHandlers()[0]);
|
||||
$this->assertCount(1, $run->getHandlers());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Whoops\Run::register
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user