function StaticReflectionParserTest::testAttribute

Same name and namespace in other branches
  1. 10 core/tests/Drupal/Tests/Component/Annotation/Doctrine/StaticReflectionParserTest.php \Drupal\Tests\Component\Annotation\Doctrine\StaticReflectionParserTest::testAttribute()

@testWith ["AttributeClass", "\\Attribute", true] ["AttributeClass", "attribute", true] ["AttributeClass", "Attribute", true] ["AttributeClass", "\\DoesNotExist", false] ["Nonexistent", "NonexistentAttribute", false] ["MultipleAttributes", "Attribute", true] ["MultipleAttributes", "Drupal\\Tests\\Component\\Annotation\\Doctrine\\Fixtures\\Attribute\\AttributeClass", true] ["MultipleAttributes", "DoesNotExist", false] ["FullyQualified", "Drupal\\Tests\\Component\\Annotation\\Doctrine\\Fixtures\\ExtraAttributes\\ExampleAttribute", true] ["Used", "Drupal\\Tests\\Component\\Annotation\\Doctrine\\Fixtures\\ExtraAttributes\\ExampleAttribute", true] ["UsedAs", "Drupal\\Tests\\Component\\Annotation\\Doctrine\\Fixtures\\ExtraAttributes\\ExampleAttribute", true] ["UsedAsQualified", "Drupal\\Tests\\Component\\Annotation\\Doctrine\\Fixtures\\ExtraAttributes\\ExampleAttribute", true] ["Qualified", "Drupal\\Tests\\Component\\Annotation\\Doctrine\\Fixtures\\ExtraAttributes\\ExampleAttribute", true] ["Relative", "Drupal\\Tests\\Component\\Annotation\\Doctrine\\Fixtures\\Attribute\\SubDir\\SubDirAttribute", true] ["FullyQualified", "Drupal\\Tests\\Component\\Annotation\\Doctrine\\Fixtures\\ExtraAttributes\\ExampleParentAttribute", true] ["Used", "Drupal\\Tests\\Component\\Annotation\\Doctrine\\Fixtures\\ExtraAttributes\\ExampleParentAttribute", true] ["UsedAs", "Drupal\\Tests\\Component\\Annotation\\Doctrine\\Fixtures\\ExtraAttributes\\ExampleParentAttribute", true] ["UsedAsQualified", "Drupal\\Tests\\Component\\Annotation\\Doctrine\\Fixtures\\ExtraAttributes\\ExampleParentAttribute", true] ["Qualified", "Drupal\\Tests\\Component\\Annotation\\Doctrine\\Fixtures\\ExtraAttributes\\ExampleParentAttribute", true]

File

core/tests/Drupal/Tests/Component/Annotation/Doctrine/StaticReflectionParserTest.php, line 37

Class

StaticReflectionParserTest
@coversDefaultClass <a href="/api/drupal/core%21lib%21Drupal%21Component%21Annotation%21Doctrine%21StaticReflectionParser.php/class/StaticReflectionParser/11.x" title="Parses a file for namespaces/use/class declarations." class="local">\Drupal\Component\Annotation\Doctrine\StaticReflectionParser</a>

Namespace

Drupal\Tests\Component\Annotation\Doctrine

Code

public function testAttribute(string $class, string $attribute_class, bool $expected) {
    $finder = MockFileFinder::create(__DIR__ . '/Fixtures/Attribute/' . $class . '.php');
    $parser = new StaticReflectionParser('\\Drupal\\Tests\\Component\\Annotation\\Doctrine\\Fixtures\\Attribute\\' . $class, $finder);
    $this->assertSame($expected, $parser->hasClassAttribute($attribute_class), "'{$class}' has attribute that is a '{$attribute_class}'");
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.