Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

funcional test

  • Loading branch information...
commit fe9424abee186ebc0c1568b283ae9bc8dd6b7cc0 1 parent e0d3d35
@FabioBatSilva authored
View
29 tests/Doctrine/Tests/Common/Annotations/AbstractReaderTest.php
@@ -350,6 +350,35 @@ public function testInvalidAnnotationButIgnored()
$this->assertCount(0, $reader->getPropertyAnnotations($class->getProperty('foo')));
}
+ public function testAnnotationEnumeratorException()
+ {
+ $reader = $this->getReader();
+ $class = new \ReflectionClass('Doctrine\Tests\Common\Annotations\Fixtures\ClassWithAnnotationEnum');
+
+ $this->assertCount(1, $bar = $reader->getMethodAnnotations($class->getMethod('bar')));
+ $this->assertCount(1, $foo = $reader->getPropertyAnnotations($class->getProperty('foo')));
+
+ $this->assertInstanceOf('Doctrine\Tests\Common\Annotations\Fixtures\AnnotationEnum', $bar[0]);
+ $this->assertInstanceOf('Doctrine\Tests\Common\Annotations\Fixtures\AnnotationEnum', $foo[0]);
+
+ try {
+ $reader->getPropertyAnnotations($class->getProperty('invalidProperty'));
+ $this->fail();
+ } catch (\Doctrine\Common\Annotations\AnnotationException $exc) {
+ $this->assertEquals('[Enum Error] Attribute "value" of @Doctrine\Tests\Common\Annotations\Fixtures\AnnotationEnum declared on property Doctrine\Tests\Common\Annotations\Fixtures\ClassWithAnnotationEnum::$invalidProperty accept only [ONE, TWO, THREE], but got FOUR.', $exc->getMessage());
+ }
+
+ try {
+ $reader->getMethodAnnotations($class->getMethod('invalidMethod'));
+ $this->fail();
+ } catch (\Doctrine\Common\Annotations\AnnotationException $exc) {
+ $this->assertEquals('[Enum Error] Attribute "value" of @Doctrine\Tests\Common\Annotations\Fixtures\AnnotationEnum declared on method Doctrine\Tests\Common\Annotations\Fixtures\ClassWithAnnotationEnum::invalidMethod() accept only [ONE, TWO, THREE], but got 5.', $exc->getMessage());
+ }
+ }
+
+ /**
+ * @return AnnotationReader
+ */
abstract protected function getReader();
}
View
6 tests/Doctrine/Tests/Common/Annotations/Fixtures/ClassWithAnnotationEnum.php
@@ -7,12 +7,12 @@
class ClassWithAnnotationEnum
{
/**
- * AnnotationEnum(AnnotationEnum::ONE)
+ * @AnnotationEnum(AnnotationEnum::ONE)
*/
public $foo;
/**
- * AnnotationEnum("TOW")
+ * @AnnotationEnum("TWO")
*/
public function bar(){}
@@ -23,7 +23,7 @@ public function bar(){}
public $invalidProperty;
/**
- * @AnnotationEnum({"ONE"})
+ * @AnnotationEnum(5)
*/
public function invalidMethod(){}
}
Please sign in to comment.
Something went wrong with that request. Please try again.