public function DocParserTest::testAnnotationWithoutConstructor in Drupal 9
Same name and namespace in other branches
- 8 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()
File
- core/
tests/ Drupal/ Tests/ Component/ Annotation/ Doctrine/ DocParserTest.php, line 194
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("Some data", $annot->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("Some Name", $annot->name);
$this
->assertEquals("Some data", $annot->data);
$docblock = <<<DOCBLOCK
/**
* @SomeAnnotationClassNameWithoutConstructor(data = "Some data")
*/
DOCBLOCK;
$result = $parser
->parse($docblock);
$this
->assertCount(1, $result);
$annot = $result[0];
$this
->assertEquals("Some data", $annot->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("Some name", $annot->name);
$this
->assertNull($annot->data);
$docblock = <<<DOCBLOCK
/**
* @SomeAnnotationClassNameWithoutConstructor("Some data")
*/
DOCBLOCK;
$result = $parser
->parse($docblock);
$this
->assertCount(1, $result);
$annot = $result[0];
$this
->assertEquals("Some data", $annot->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("Some name", $annot->name);
$this
->assertEquals("Some data", $annot->data);
$docblock = <<<DOCBLOCK
/**
* @SomeAnnotationWithConstructorWithoutParams(name = "Some name")
*/
DOCBLOCK;
$result = $parser
->parse($docblock);
$this
->assertCount(1, $result);
$annot = $result[0];
$this
->assertEquals("Some name", $annot->name);
$this
->assertEquals("Some data", $annot->data);
$docblock = <<<DOCBLOCK
/**
* @SomeAnnotationClassNameWithoutConstructorAndProperties()
*/
DOCBLOCK;
$result = $parser
->parse($docblock);
$this
->assertCount(1, $result);
$this
->assertInstanceOf(SomeAnnotationClassNameWithoutConstructorAndProperties::class, $result[0]);
}