DocParserIgnoredClassesTest.php in Drupal 9
File
core/tests/Drupal/Tests/Component/Annotation/DocParserIgnoredClassesTest.php
View source
<?php
namespace Drupal\Tests\Component\Annotation;
use Drupal\Component\Annotation\Doctrine\DocParser;
use PHPUnit\Framework\TestCase;
class DocParserIgnoredClassesTest extends TestCase {
public function testIgnoredAnnotationSkippedBeforeReflection() {
$annotation = 'neverReflectThis';
$parser = new DocParser();
$parser
->setIgnoredAnnotationNames([
$annotation => TRUE,
]);
$parser
->addNamespace('\\Arbitrary\\Namespace');
$autoloader = function ($class_name) use ($annotation) {
$name_array = explode('\\', $class_name);
$name = array_pop($name_array);
if ($name == $annotation) {
$this
->fail('Attempted to autoload an ignored annotation: ' . $name);
}
};
spl_autoload_register($autoloader, TRUE, TRUE);
$this
->assertEmpty($parser
->parse('@neverReflectThis'));
spl_autoload_unregister($autoloader);
}
}