2016-10-09 13:15:24 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace PhpParser\ErrorHandler;
|
|
|
|
|
|
|
|
use PhpParser\Error;
|
2017-04-27 18:14:07 +02:00
|
|
|
use PHPUnit\Framework\TestCase;
|
2016-10-09 13:15:24 +02:00
|
|
|
|
2017-04-27 18:14:07 +02:00
|
|
|
class CollectingTest extends TestCase
|
|
|
|
{
|
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
|
|
|
}
|