CollectingTest.php 724 B

12345678910111213141516171819202122
  1. <?php
  2. namespace PhpParser\ErrorHandler;
  3. use PhpParser\Error;
  4. class CollectingTest extends \PHPUnit_Framework_TestCase {
  5. public function testHandleError() {
  6. $errorHandler = new Collecting();
  7. $this->assertFalse($errorHandler->hasErrors());
  8. $this->assertEmpty($errorHandler->getErrors());
  9. $errorHandler->handleError($e1 = new Error('Test 1'));
  10. $errorHandler->handleError($e2 = new Error('Test 2'));
  11. $this->assertTrue($errorHandler->hasErrors());
  12. $this->assertSame([$e1, $e2], $errorHandler->getErrors());
  13. $errorHandler->clearErrors();
  14. $this->assertFalse($errorHandler->hasErrors());
  15. $this->assertEmpty($errorHandler->getErrors());
  16. }
  17. }