CollectingTest.php 750 B

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