2017-11-02 18:56:01 +01:00
|
|
|
<?php declare(strict_types=1);
|
2016-10-09 13:15:24 +02:00
|
|
|
|
|
|
|
namespace PhpParser\ErrorHandler;
|
|
|
|
|
|
|
|
use PhpParser\Error;
|
|
|
|
|
2019-01-19 11:18:00 +01:00
|
|
|
class CollectingTest extends \PHPUnit\Framework\TestCase
|
2017-04-27 18:14:07 +02:00
|
|
|
{
|
2016-10-09 13:15:24 +02:00
|
|
|
public function testHandleError() {
|
|
|
|
$errorHandler = new Collecting();
|
|
|
|
$this->assertFalse($errorHandler->hasErrors());
|
|
|
|
$this->assertEmpty($errorHandler->getErrors());
|
|
|
|
|
|
|
|
$errorHandler->handleError($e1 = new Error('Test 1'));
|
|
|
|
$errorHandler->handleError($e2 = new Error('Test 2'));
|
|
|
|
$this->assertTrue($errorHandler->hasErrors());
|
|
|
|
$this->assertSame([$e1, $e2], $errorHandler->getErrors());
|
|
|
|
|
|
|
|
$errorHandler->clearErrors();
|
|
|
|
$this->assertFalse($errorHandler->hasErrors());
|
|
|
|
$this->assertEmpty($errorHandler->getErrors());
|
|
|
|
}
|
2017-04-27 18:14:07 +02:00
|
|
|
}
|