mirror of
https://github.com/danog/PHP-Parser.git
synced 2024-12-02 17:28:27 +01:00
f99a96e0a2
Add ErrorHandler interface, as well as ErrorHandler\Throwing and ErrorHandler\Collecting. The error handler is passed to Parser::parse(). This supersedes the throwOnError option. NameResolver now accepts an ErrorHandler in the ctor.
22 lines
724 B
PHP
22 lines
724 B
PHP
<?php
|
|
|
|
namespace PhpParser\ErrorHandler;
|
|
|
|
use PhpParser\Error;
|
|
|
|
class CollectingTest extends \PHPUnit_Framework_TestCase {
|
|
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());
|
|
}
|
|
} |