function DocParserTest::testAnnotationWithoutConstructor
Same name in other branches
- 9 core/tests/Drupal/Tests/Component/Annotation/Doctrine/DocParserTest.php \Drupal\Tests\Component\Annotation\Doctrine\DocParserTest::testAnnotationWithoutConstructor()
- 10 core/tests/Drupal/Tests/Component/Annotation/Doctrine/DocParserTest.php \Drupal\Tests\Component\Annotation\Doctrine\DocParserTest::testAnnotationWithoutConstructor()
- 11.x core/tests/Drupal/Tests/Component/Annotation/Doctrine/DocParserTest.php \Drupal\Tests\Component\Annotation\Doctrine\DocParserTest::testAnnotationWithoutConstructor()
File
-
core/
tests/ Drupal/ Tests/ Component/ Annotation/ Doctrine/ DocParserTest.php, line 197
Class
- DocParserTest
- @coversDefaultClass \Drupal\Component\Annotation\Doctrine\DocParser
Namespace
Drupal\Tests\Component\Annotation\DoctrineCode
public function testAnnotationWithoutConstructor() {
$parser = $this->createTestParser();
$docblock = <<<DOCBLOCK
/**
* @SomeAnnotationClassNameWithoutConstructor("Some data")
*/
DOCBLOCK;
$result = $parser->parse($docblock);
$this->assertCount(1, $result);
$annot = $result[0];
$this->assertNotNull($annot);
$this->assertInstanceOf(SomeAnnotationClassNameWithoutConstructor::class, $annot);
$this->assertNull($annot->name);
$this->assertNotNull($annot->data);
$this->assertEquals($annot->data, "Some data");
$docblock = <<<DOCBLOCK
/**
* @SomeAnnotationClassNameWithoutConstructor(name="Some Name", data = "Some data")
*/
DOCBLOCK;
$result = $parser->parse($docblock);
$this->assertCount(1, $result);
$annot = $result[0];
$this->assertNotNull($annot);
$this->assertInstanceOf(SomeAnnotationClassNameWithoutConstructor::class, $annot);
$this->assertEquals($annot->name, "Some Name");
$this->assertEquals($annot->data, "Some data");
$docblock = <<<DOCBLOCK
/**
* @SomeAnnotationClassNameWithoutConstructor(data = "Some data")
*/
DOCBLOCK;
$result = $parser->parse($docblock);
$this->assertCount(1, $result);
$annot = $result[0];
$this->assertEquals($annot->data, "Some data");
$this->assertNull($annot->name);
$docblock = <<<DOCBLOCK
/**
* @SomeAnnotationClassNameWithoutConstructor(name = "Some name")
*/
DOCBLOCK;
$result = $parser->parse($docblock);
$this->assertCount(1, $result);
$annot = $result[0];
$this->assertEquals($annot->name, "Some name");
$this->assertNull($annot->data);
$docblock = <<<DOCBLOCK
/**
* @SomeAnnotationClassNameWithoutConstructor("Some data")
*/
DOCBLOCK;
$result = $parser->parse($docblock);
$this->assertCount(1, $result);
$annot = $result[0];
$this->assertEquals($annot->data, "Some data");
$this->assertNull($annot->name);
$docblock = <<<DOCBLOCK
/**
* @SomeAnnotationClassNameWithoutConstructor("Some data",name = "Some name")
*/
DOCBLOCK;
$result = $parser->parse($docblock);
$this->assertCount(1, $result);
$annot = $result[0];
$this->assertEquals($annot->name, "Some name");
$this->assertEquals($annot->data, "Some data");
$docblock = <<<DOCBLOCK
/**
* @SomeAnnotationWithConstructorWithoutParams(name = "Some name")
*/
DOCBLOCK;
$result = $parser->parse($docblock);
$this->assertCount(1, $result);
$annot = $result[0];
$this->assertEquals($annot->name, "Some name");
$this->assertEquals($annot->data, "Some data");
$docblock = <<<DOCBLOCK
/**
* @SomeAnnotationClassNameWithoutConstructorAndProperties()
*/
DOCBLOCK;
$result = $parser->parse($docblock);
$this->assertCount(1, $result);
$this->assertInstanceOf(SomeAnnotationClassNameWithoutConstructorAndProperties::class, $result[0]);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.