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