function DocParserTest::testAnnotationWithRequiredAttributesWithoutContructor
Same name in other branches
- 8.9.x core/tests/Drupal/Tests/Component/Annotation/Doctrine/DocParserTest.php \Drupal\Tests\Component\Annotation\Doctrine\DocParserTest::testAnnotationWithRequiredAttributesWithoutContructor()
- 10 core/tests/Drupal/Tests/Component/Annotation/Doctrine/DocParserTest.php \Drupal\Tests\Component\Annotation\Doctrine\DocParserTest::testAnnotationWithRequiredAttributesWithoutContructor()
- 11.x core/tests/Drupal/Tests/Component/Annotation/Doctrine/DocParserTest.php \Drupal\Tests\Component\Annotation\Doctrine\DocParserTest::testAnnotationWithRequiredAttributesWithoutContructor()
File
-
core/
tests/ Drupal/ Tests/ Component/ Annotation/ Doctrine/ DocParserTest.php, line 675
Class
- DocParserTest
- @coversDefaultClass \Drupal\Component\Annotation\Doctrine\DocParser
Namespace
Drupal\Tests\Component\Annotation\DoctrineCode
public function testAnnotationWithRequiredAttributesWithoutContructor() {
$parser = $this->createTestParser();
$context = 'property SomeClassName::invalidProperty.';
$parser->setTarget(Target::TARGET_PROPERTY);
$docblock = '@Drupal\\Tests\\Component\\Annotation\\Doctrine\\Fixtures\\AnnotationWithRequiredAttributesWithoutContructor("Some Value", annot = @Drupal\\Tests\\Component\\Annotation\\Doctrine\\Fixtures\\AnnotationTargetAnnotation)';
$result = $parser->parse($docblock);
$this->assertCount(1, $result);
$this->assertInstanceOf('Drupal\\Tests\\Component\\Annotation\\Doctrine\\Fixtures\\AnnotationWithRequiredAttributesWithoutContructor', $result[0]);
$this->assertEquals("Some Value", $result[0]->value);
$this->assertInstanceOf('Drupal\\Tests\\Component\\Annotation\\Doctrine\\Fixtures\\AnnotationTargetAnnotation', $result[0]->annot);
$docblock = '@Drupal\\Tests\\Component\\Annotation\\Doctrine\\Fixtures\\AnnotationWithRequiredAttributesWithoutContructor("Some Value")';
try {
$result = $parser->parse($docblock, $context);
$this->fail();
} catch (\Doctrine\Common\Annotations\AnnotationException $exc) {
$this->assertStringContainsString('Attribute "annot" of @Drupal\\Tests\\Component\\Annotation\\Doctrine\\Fixtures\\AnnotationWithRequiredAttributesWithoutContructor declared on property SomeClassName::invalidProperty. expects a(n) Drupal\\Tests\\Component\\Annotation\\Doctrine\\Fixtures\\AnnotationTargetAnnotation. This value should not be null.', $exc->getMessage());
}
$docblock = '@Drupal\\Tests\\Component\\Annotation\\Doctrine\\Fixtures\\AnnotationWithRequiredAttributesWithoutContructor(annot = @Drupal\\Tests\\Component\\Annotation\\Doctrine\\Fixtures\\AnnotationTargetAnnotation)';
try {
$result = $parser->parse($docblock, $context);
$this->fail();
} catch (\Doctrine\Common\Annotations\AnnotationException $exc) {
$this->assertStringContainsString('Attribute "value" of @Drupal\\Tests\\Component\\Annotation\\Doctrine\\Fixtures\\AnnotationWithRequiredAttributesWithoutContructor declared on property SomeClassName::invalidProperty. expects a(n) string. This value should not be null.', $exc->getMessage());
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.