public function AbstractReaderTest::testAnnotations

@dataProvider getReflectionClass

File

drupal/core/vendor/doctrine/common/tests/Doctrine/Tests/Common/Annotations/AbstractReaderTest.php, line 41

Class

AbstractReaderTest

Namespace

Doctrine\Tests\Common\Annotations

Code

public function testAnnotations($class) {
  $reader = $this
    ->getReader();
  $this
    ->assertEquals(1, count($reader
    ->getClassAnnotations($class)));
  $this
    ->assertInstanceOf($annotName = 'Doctrine\\Tests\\Common\\Annotations\\DummyAnnotation', $annot = $reader
    ->getClassAnnotation($class, $annotName));
  $this
    ->assertEquals("hello", $annot->dummyValue);
  $field1Prop = $class
    ->getProperty('field1');
  $propAnnots = $reader
    ->getPropertyAnnotations($field1Prop);
  $this
    ->assertEquals(1, count($propAnnots));
  $this
    ->assertInstanceOf($annotName, $annot = $reader
    ->getPropertyAnnotation($field1Prop, $annotName));
  $this
    ->assertEquals("fieldHello", $annot->dummyValue);
  $getField1Method = $class
    ->getMethod('getField1');
  $methodAnnots = $reader
    ->getMethodAnnotations($getField1Method);
  $this
    ->assertEquals(1, count($methodAnnots));
  $this
    ->assertInstanceOf($annotName, $annot = $reader
    ->getMethodAnnotation($getField1Method, $annotName));
  $this
    ->assertEquals(array(
    1,
    2,
    "three",
  ), $annot->value);
  $field2Prop = $class
    ->getProperty('field2');
  $propAnnots = $reader
    ->getPropertyAnnotations($field2Prop);
  $this
    ->assertEquals(1, count($propAnnots));
  $this
    ->assertInstanceOf($annotName = 'Doctrine\\Tests\\Common\\Annotations\\DummyJoinTable', $joinTableAnnot = $reader
    ->getPropertyAnnotation($field2Prop, $annotName));
  $this
    ->assertEquals(1, count($joinTableAnnot->joinColumns));
  $this
    ->assertEquals(1, count($joinTableAnnot->inverseJoinColumns));
  $this
    ->assertTrue($joinTableAnnot->joinColumns[0] instanceof DummyJoinColumn);
  $this
    ->assertTrue($joinTableAnnot->inverseJoinColumns[0] instanceof DummyJoinColumn);
  $this
    ->assertEquals('col1', $joinTableAnnot->joinColumns[0]->name);
  $this
    ->assertEquals('col2', $joinTableAnnot->joinColumns[0]->referencedColumnName);
  $this
    ->assertEquals('col3', $joinTableAnnot->inverseJoinColumns[0]->name);
  $this
    ->assertEquals('col4', $joinTableAnnot->inverseJoinColumns[0]->referencedColumnName);
  $dummyAnnot = $reader
    ->getMethodAnnotation($class
    ->getMethod('getField1'), 'Doctrine\\Tests\\Common\\Annotations\\DummyAnnotation');
  $this
    ->assertEquals('', $dummyAnnot->dummyValue);
  $this
    ->assertEquals(array(
    1,
    2,
    'three',
  ), $dummyAnnot->value);
  $dummyAnnot = $reader
    ->getPropertyAnnotation($class
    ->getProperty('field1'), 'Doctrine\\Tests\\Common\\Annotations\\DummyAnnotation');
  $this
    ->assertEquals('fieldHello', $dummyAnnot->dummyValue);
  $classAnnot = $reader
    ->getClassAnnotation($class, 'Doctrine\\Tests\\Common\\Annotations\\DummyAnnotation');
  $this
    ->assertEquals('hello', $classAnnot->dummyValue);
}