diff --git a/lib/Doctrine/Common/Annotations/DocParser.php b/lib/Doctrine/Common/Annotations/DocParser.php index f8329ca11..c07586e20 100644 --- a/lib/Doctrine/Common/Annotations/DocParser.php +++ b/lib/Doctrine/Common/Annotations/DocParser.php @@ -105,7 +105,7 @@ final class DocParser /** * An array of default namespaces if operating in simple mode. * - * @var array + * @var string[] */ private $namespaces = array(); @@ -286,7 +286,7 @@ public function setIgnoreNotImportedAnnotations($bool) /** * Sets the default namespaces. * - * @param array $namespace + * @param string $namespace * * @return void * diff --git a/tests/Doctrine/Tests/Common/Annotations/AbstractReaderTest.php b/tests/Doctrine/Tests/Common/Annotations/AbstractReaderTest.php index cd0867aa2..b41b0ac89 100644 --- a/tests/Doctrine/Tests/Common/Annotations/AbstractReaderTest.php +++ b/tests/Doctrine/Tests/Common/Annotations/AbstractReaderTest.php @@ -2,9 +2,8 @@ namespace Doctrine\Tests\Common\Annotations; -use Doctrine\Common\Annotations\Annotation\IgnoreAnnotation; use Doctrine\Common\Annotations\Annotation; -use Doctrine\Common\Annotations\Reader; +use Doctrine\Common\Annotations\AnnotationException; use ReflectionClass, Doctrine\Common\Annotations\AnnotationReader; require_once __DIR__ . '/TopLevelAnnotation.php'; @@ -13,8 +12,7 @@ abstract class AbstractReaderTest extends \PHPUnit_Framework_TestCase { public function getReflectionClass() { - $className = 'Doctrine\Tests\Common\Annotations\DummyClass'; - return new ReflectionClass($className); + return new ReflectionClass(DummyClass::class); } public function testAnnotations() @@ -22,90 +20,90 @@ public function testAnnotations() $class = $this->getReflectionClass(); $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); + self::assertCount(1, $reader->getClassAnnotations($class)); + self::assertInstanceOf($annotName = DummyAnnotation::class, $annot = $reader->getClassAnnotation($class, $annotName)); + self::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); + self::assertCount(1, $propAnnots); + self::assertInstanceOf($annotName, $annot = $reader->getPropertyAnnotation($field1Prop, $annotName)); + self::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); + self::assertCount(1, $methodAnnots); + self::assertInstanceOf($annotName, $annot = $reader->getMethodAnnotation($getField1Method, $annotName)); + self::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); + self::assertCount(1, $propAnnots); + self::assertInstanceOf($annotName = DummyJoinTable::class, $joinTableAnnot = $reader->getPropertyAnnotation($field2Prop, $annotName)); + self::assertCount(1, $joinTableAnnot->joinColumns); + self::assertCount(1, $joinTableAnnot->inverseJoinColumns); + self::assertInstanceOf(DummyJoinColumn::class, $joinTableAnnot->joinColumns[0]); + self::assertInstanceOf(DummyJoinColumn::class, $joinTableAnnot->inverseJoinColumns[0]); + self::assertEquals('col1', $joinTableAnnot->joinColumns[0]->name); + self::assertEquals('col2', $joinTableAnnot->joinColumns[0]->referencedColumnName); + self::assertEquals('col3', $joinTableAnnot->inverseJoinColumns[0]->name); + self::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->getMethodAnnotation($class->getMethod('getField1'), DummyAnnotation::class); + self::assertEquals('', $dummyAnnot->dummyValue); + self::assertEquals(array(1, 2, 'three'), $dummyAnnot->value); - $dummyAnnot = $reader->getMethodAnnotation($class->getMethod('getField3'), 'Doctrine\Tests\Common\Annotations\DummyAnnotation'); - $this->assertEquals('\d{4}-[01]\d-[0-3]\d [0-2]\d:[0-5]\d:[0-5]\d', $dummyAnnot->value); + $dummyAnnot = $reader->getMethodAnnotation($class->getMethod('getField3'), DummyAnnotation::class); + self::assertEquals('\d{4}-[01]\d-[0-3]\d [0-2]\d:[0-5]\d:[0-5]\d', $dummyAnnot->value); - $dummyAnnot = $reader->getPropertyAnnotation($class->getProperty('field1'), 'Doctrine\Tests\Common\Annotations\DummyAnnotation'); - $this->assertEquals('fieldHello', $dummyAnnot->dummyValue); + $dummyAnnot = $reader->getPropertyAnnotation($class->getProperty('field1'), DummyAnnotation::class); + self::assertEquals('fieldHello', $dummyAnnot->dummyValue); - $classAnnot = $reader->getClassAnnotation($class, 'Doctrine\Tests\Common\Annotations\DummyAnnotation'); - $this->assertEquals('hello', $classAnnot->dummyValue); + $classAnnot = $reader->getClassAnnotation($class, DummyAnnotation::class); + self::assertEquals('hello', $classAnnot->dummyValue); } public function testAnnotationsWithValidTargets() { $reader = $this->getReader(); - $class = new ReflectionClass('Doctrine\Tests\Common\Annotations\Fixtures\ClassWithValidAnnotationTarget'); + $class = new ReflectionClass(Fixtures\ClassWithValidAnnotationTarget::class); - $this->assertEquals(1,count($reader->getClassAnnotations($class))); - $this->assertEquals(1,count($reader->getPropertyAnnotations($class->getProperty('foo')))); - $this->assertEquals(1,count($reader->getMethodAnnotations($class->getMethod('someFunction')))); - $this->assertEquals(1,count($reader->getPropertyAnnotations($class->getProperty('nested')))); + self::assertCount(1, $reader->getClassAnnotations($class)); + self::assertCount(1, $reader->getPropertyAnnotations($class->getProperty('foo'))); + self::assertCount(1, $reader->getMethodAnnotations($class->getMethod('someFunction'))); + self::assertCount(1, $reader->getPropertyAnnotations($class->getProperty('nested'))); } public function testAnnotationsWithVarType() { $reader = $this->getReader(); - $class = new ReflectionClass('Doctrine\Tests\Common\Annotations\Fixtures\ClassWithAnnotationWithVarType'); + $class = new ReflectionClass(Fixtures\ClassWithAnnotationWithVarType::class); - $this->assertEquals(1,count($fooAnnot = $reader->getPropertyAnnotations($class->getProperty('foo')))); - $this->assertEquals(1,count($barAnnot = $reader->getMethodAnnotations($class->getMethod('bar')))); + self::assertCount(1, $fooAnnot = $reader->getPropertyAnnotations($class->getProperty('foo'))); + self::assertCount(1, $barAnnot = $reader->getMethodAnnotations($class->getMethod('bar'))); - $this->assertInternalType('string', $fooAnnot[0]->string); - $this->assertInstanceOf('Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll', $barAnnot[0]->annotation); + self::assertInternalType('string', $fooAnnot[0]->string); + self::assertInstanceOf(Fixtures\AnnotationTargetAll::class, $barAnnot[0]->annotation); } public function testAtInDescription() { $reader = $this->getReader(); - $class = new ReflectionClass('Doctrine\Tests\Common\Annotations\Fixtures\ClassWithAtInDescriptionAndAnnotation'); + $class = new ReflectionClass(Fixtures\ClassWithAtInDescriptionAndAnnotation::class); - $this->assertEquals(1, count($fooAnnot = $reader->getPropertyAnnotations($class->getProperty('foo')))); - $this->assertEquals(1, count($barAnnot = $reader->getPropertyAnnotations($class->getProperty('bar')))); + self::assertCount(1, $fooAnnot = $reader->getPropertyAnnotations($class->getProperty('foo'))); + self::assertCount(1, $barAnnot = $reader->getPropertyAnnotations($class->getProperty('bar'))); - $this->assertInstanceOf('Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetPropertyMethod', $fooAnnot[0]); - $this->assertInstanceOf('Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetPropertyMethod', $barAnnot[0]); + self::assertInstanceOf(Fixtures\AnnotationTargetPropertyMethod::class, $fooAnnot[0]); + self::assertInstanceOf(Fixtures\AnnotationTargetPropertyMethod::class, $barAnnot[0]); } public function testClassWithWithDanglingComma() { $reader = $this->getReader(); - $annots = $reader->getClassAnnotations(new \ReflectionClass('Doctrine\Tests\Common\Annotations\DummyClassWithDanglingComma')); + $annots = $reader->getClassAnnotations(new \ReflectionClass(DummyClassWithDanglingComma::class)); - $this->assertCount(1, $annots); + self::assertCount(1, $annots); } /** @@ -115,14 +113,14 @@ public function testClassWithWithDanglingComma() public function testClassWithInvalidAnnotationTargetAtClassDocBlock() { $reader = $this->getReader(); - $reader->getClassAnnotations(new \ReflectionClass('Doctrine\Tests\Common\Annotations\Fixtures\ClassWithInvalidAnnotationTargetAtClass')); + $reader->getClassAnnotations(new \ReflectionClass(Fixtures\ClassWithInvalidAnnotationTargetAtClass::class)); } public function testClassWithWithInclude() { $reader = $this->getReader(); - $annots = $reader->getClassAnnotations(new \ReflectionClass('Doctrine\Tests\Common\Annotations\Fixtures\ClassWithRequire')); - $this->assertCount(1, $annots); + $annots = $reader->getClassAnnotations(new \ReflectionClass(Fixtures\ClassWithRequire::class)); + self::assertCount(1, $annots); } /** @@ -132,7 +130,7 @@ public function testClassWithWithInclude() public function testClassWithInvalidAnnotationTargetAtPropertyDocBlock() { $reader = $this->getReader(); - $reader->getPropertyAnnotations(new \ReflectionProperty('Doctrine\Tests\Common\Annotations\Fixtures\ClassWithInvalidAnnotationTargetAtProperty', 'foo')); + $reader->getPropertyAnnotations(new \ReflectionProperty(Fixtures\ClassWithInvalidAnnotationTargetAtProperty::class, 'foo')); } /** @@ -142,7 +140,7 @@ public function testClassWithInvalidAnnotationTargetAtPropertyDocBlock() public function testClassWithInvalidNestedAnnotationTargetAtPropertyDocBlock() { $reader = $this->getReader(); - $reader->getPropertyAnnotations(new \ReflectionProperty('Doctrine\Tests\Common\Annotations\Fixtures\ClassWithInvalidAnnotationTargetAtProperty', 'bar')); + $reader->getPropertyAnnotations(new \ReflectionProperty(Fixtures\ClassWithInvalidAnnotationTargetAtProperty::class, 'bar')); } /** @@ -152,7 +150,7 @@ public function testClassWithInvalidNestedAnnotationTargetAtPropertyDocBlock() public function testClassWithInvalidAnnotationTargetAtMethodDocBlock() { $reader = $this->getReader(); - $reader->getMethodAnnotations(new \ReflectionMethod('Doctrine\Tests\Common\Annotations\Fixtures\ClassWithInvalidAnnotationTargetAtMethod', 'functionName')); + $reader->getMethodAnnotations(new \ReflectionMethod(Fixtures\ClassWithInvalidAnnotationTargetAtMethod::class, 'functionName')); } /** @@ -162,7 +160,7 @@ public function testClassWithInvalidAnnotationTargetAtMethodDocBlock() public function testClassWithAnnotationWithTargetSyntaxErrorAtClassDocBlock() { $reader = $this->getReader(); - $reader->getClassAnnotations(new \ReflectionClass('Doctrine\Tests\Common\Annotations\Fixtures\ClassWithAnnotationWithTargetSyntaxError')); + $reader->getClassAnnotations(new \ReflectionClass(Fixtures\ClassWithAnnotationWithTargetSyntaxError::class)); } /** @@ -172,7 +170,7 @@ public function testClassWithAnnotationWithTargetSyntaxErrorAtClassDocBlock() public function testClassWithAnnotationWithTargetSyntaxErrorAtPropertyDocBlock() { $reader = $this->getReader(); - $reader->getPropertyAnnotations(new \ReflectionProperty('Doctrine\Tests\Common\Annotations\Fixtures\ClassWithAnnotationWithTargetSyntaxError','foo')); + $reader->getPropertyAnnotations(new \ReflectionProperty(Fixtures\ClassWithAnnotationWithTargetSyntaxError::class,'foo')); } /** @@ -182,7 +180,7 @@ public function testClassWithAnnotationWithTargetSyntaxErrorAtPropertyDocBlock() public function testClassWithAnnotationWithTargetSyntaxErrorAtMethodDocBlock() { $reader = $this->getReader(); - $reader->getMethodAnnotations(new \ReflectionMethod('Doctrine\Tests\Common\Annotations\Fixtures\ClassWithAnnotationWithTargetSyntaxError','bar')); + $reader->getMethodAnnotations(new \ReflectionMethod(Fixtures\ClassWithAnnotationWithTargetSyntaxError::class,'bar')); } /** @@ -192,19 +190,19 @@ public function testClassWithAnnotationWithTargetSyntaxErrorAtMethodDocBlock() public function testClassWithPropertyInvalidVarTypeError() { $reader = $this->getReader(); - $class = new ReflectionClass('Doctrine\Tests\Common\Annotations\Fixtures\ClassWithAnnotationWithVarType'); + $class = new ReflectionClass(Fixtures\ClassWithAnnotationWithVarType::class); $reader->getPropertyAnnotations($class->getProperty('invalidProperty')); } /** * @expectedException \Doctrine\Common\Annotations\AnnotationException - * @expectedExceptionMessage [Type Error] Attribute "annotation" of @AnnotationWithVarType declared on method Doctrine\Tests\Common\Annotations\Fixtures\ClassWithAnnotationWithVarType::invalidMethod() expects a(n) Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll, but got an instance of Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAnnotation. + * @expectedExceptionMessage [Type Error] Attribute "annotation" of @AnnotationWithVarType declared on method Doctrine\Tests\Common\Annotations\Fixtures\ClassWithAnnotationWithVarType::invalidMethod() expects a(n) \Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll, but got an instance of Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAnnotation. */ public function testClassWithMethodInvalidVarTypeError() { $reader = $this->getReader(); - $class = new ReflectionClass('Doctrine\Tests\Common\Annotations\Fixtures\ClassWithAnnotationWithVarType'); + $class = new ReflectionClass(Fixtures\ClassWithAnnotationWithVarType::class); $reader->getMethodAnnotations($class->getMethod('invalidMethod')); } @@ -216,7 +214,7 @@ public function testClassWithMethodInvalidVarTypeError() public function testClassSyntaxErrorContext() { $reader = $this->getReader(); - $reader->getClassAnnotations(new \ReflectionClass('Doctrine\Tests\Common\Annotations\DummyClassSyntaxError')); + $reader->getClassAnnotations(new \ReflectionClass(DummyClassSyntaxError::class)); } /** @@ -226,7 +224,7 @@ public function testClassSyntaxErrorContext() public function testMethodSyntaxErrorContext() { $reader = $this->getReader(); - $reader->getMethodAnnotations(new \ReflectionMethod('Doctrine\Tests\Common\Annotations\DummyClassMethodSyntaxError', 'foo')); + $reader->getMethodAnnotations(new \ReflectionMethod(DummyClassMethodSyntaxError::class, 'foo')); } /** @@ -236,7 +234,7 @@ public function testMethodSyntaxErrorContext() public function testPropertySyntaxErrorContext() { $reader = $this->getReader(); - $reader->getPropertyAnnotations(new \ReflectionProperty('Doctrine\Tests\Common\Annotations\DummyClassPropertySyntaxError', 'foo')); + $reader->getPropertyAnnotations(new \ReflectionProperty(DummyClassPropertySyntaxError::class, 'foo')); } /** @@ -245,33 +243,33 @@ public function testPropertySyntaxErrorContext() public function testMultipleAnnotationsOnSameLine() { $reader = $this->getReader(); - $annots = $reader->getPropertyAnnotations(new \ReflectionProperty('Doctrine\Tests\Common\Annotations\DummyClass2', 'id')); - $this->assertEquals(3, count($annots)); + $annots = $reader->getPropertyAnnotations(new \ReflectionProperty(DummyClass2::class, 'id')); + self::assertCount(3, $annots); } public function testNonAnnotationProblem() { $reader = $this->getReader(); - $this->assertNotNull($annot = $reader->getPropertyAnnotation(new \ReflectionProperty('Doctrine\Tests\Common\Annotations\DummyClassNonAnnotationProblem', 'foo'), $name = 'Doctrine\Tests\Common\Annotations\DummyAnnotation')); - $this->assertInstanceOf($name, $annot); + self::assertNotNull($annot = $reader->getPropertyAnnotation(new \ReflectionProperty(DummyClassNonAnnotationProblem::class, 'foo'), $name = DummyAnnotation::class)); + self::assertInstanceOf($name, $annot); } public function testIncludeIgnoreAnnotation() { $reader = $this->getReader(); - $reader->getPropertyAnnotations(new \ReflectionProperty('Doctrine\Tests\Common\Annotations\Fixtures\ClassWithIgnoreAnnotation', 'foo')); - $this->assertFalse(class_exists('Doctrine\Tests\Common\Annotations\Fixtures\IgnoreAnnotationClass', false)); + $reader->getPropertyAnnotations(new \ReflectionProperty(Fixtures\ClassWithIgnoreAnnotation::class, 'foo')); + self::assertFalse(class_exists(Fixtures\IgnoreAnnotationClass::class, false)); } public function testImportWithConcreteAnnotation() { $reader = $this->getReader(); - $property = new \ReflectionProperty('Doctrine\Tests\Common\Annotations\TestImportWithConcreteAnnotation', 'field'); + $property = new \ReflectionProperty(TestImportWithConcreteAnnotation::class, 'field'); $annotations = $reader->getPropertyAnnotations($property); - $this->assertEquals(1, count($annotations)); - $this->assertNotNull($reader->getPropertyAnnotation($property, 'Doctrine\Tests\Common\Annotations\DummyAnnotation')); + self::assertCount(1, $annotations); + self::assertNotNull($reader->getPropertyAnnotation($property, DummyAnnotation::class)); } public function testImportWithInheritance() @@ -282,12 +280,12 @@ public function testImportWithInheritance() $ref = new \ReflectionClass($class); $childAnnotations = $reader->getPropertyAnnotations($ref->getProperty('child')); - $this->assertEquals(1, count($childAnnotations)); - $this->assertInstanceOf('Doctrine\Tests\Common\Annotations\Foo\Name', reset($childAnnotations)); + self::assertCount(1, $childAnnotations); + self::assertInstanceOf(Foo\Name::class, reset($childAnnotations)); $parentAnnotations = $reader->getPropertyAnnotations($ref->getProperty('parent')); - $this->assertEquals(1, count($parentAnnotations)); - $this->assertInstanceOf('Doctrine\Tests\Common\Annotations\Bar\Name', reset($parentAnnotations)); + self::assertCount(1, $parentAnnotations); + self::assertInstanceOf(Bar\Name::class, reset($parentAnnotations)); } /** @@ -297,7 +295,7 @@ public function testImportWithInheritance() public function testImportDetectsNotImportedAnnotation() { $reader = $this->getReader(); - $reader->getPropertyAnnotations(new \ReflectionProperty('Doctrine\Tests\Common\Annotations\TestAnnotationNotImportedClass', 'field')); + $reader->getPropertyAnnotations(new \ReflectionProperty(TestAnnotationNotImportedClass::class, 'field')); } /** @@ -307,24 +305,24 @@ public function testImportDetectsNotImportedAnnotation() public function testImportDetectsNonExistentAnnotation() { $reader = $this->getReader(); - $reader->getPropertyAnnotations(new \ReflectionProperty('Doctrine\Tests\Common\Annotations\TestNonExistentAnnotationClass', 'field')); + $reader->getPropertyAnnotations(new \ReflectionProperty(TestNonExistentAnnotationClass::class, 'field')); } public function testTopLevelAnnotation() { $reader = $this->getReader(); - $annotations = $reader->getPropertyAnnotations(new \ReflectionProperty('Doctrine\Tests\Common\Annotations\TestTopLevelAnnotationClass', 'field')); + $annotations = $reader->getPropertyAnnotations(new \ReflectionProperty(TestTopLevelAnnotationClass::class, 'field')); - $this->assertEquals(1, count($annotations)); - $this->assertInstanceOf('\TopLevelAnnotation', reset($annotations)); + self::assertCount(1, $annotations); + self::assertInstanceOf(\TopLevelAnnotation::class, reset($annotations)); } public function testIgnoresAnnotationsNotPrefixedWithWhitespace() { $reader = $this->getReader(); - $annotation = $reader->getClassAnnotation(new \ReflectionClass(new TestIgnoresNonAnnotationsClass()), 'Doctrine\Tests\Common\Annotations\Name'); - $this->assertInstanceOf('Doctrine\Tests\Common\Annotations\Name', $annotation); + $annotation = $reader->getClassAnnotation(new \ReflectionClass(new TestIgnoresNonAnnotationsClass()), Name::class); + self::assertInstanceOf(Name::class, $annotation); } private static $testResetsPhpParserAfterUseRun = false; @@ -342,7 +340,7 @@ public function testResetsPhpParserAfterUse() { // If someone has already included our main test fixture this test is invalid. It's important that our require // causes this file to be parsed and compiled at a certain point. - $this->assertFalse(!self::$testResetsPhpParserAfterUseRun && class_exists('Doctrine_Tests_Common_Annotations_Fixtures_ClassNoNamespaceNoComment'), 'Test invalid if class has already been compiled'); + self::assertFalse(!self::$testResetsPhpParserAfterUseRun && class_exists(\Doctrine_Tests_Common_Annotations_Fixtures_ClassNoNamespaceNoComment::class), 'Test invalid if class has already been compiled'); self::$testResetsPhpParserAfterUseRun = true; $reader = $this->getReader(); @@ -350,11 +348,11 @@ public function testResetsPhpParserAfterUse() // First make sure the annotation cache knows about the annotations we want to use. // If we don't do this then loading of annotations into the cache will cause the parser to get out of the bad // state we want to test. - $class = new ReflectionClass('Doctrine\Tests\Common\Annotations\Fixtures\ClassWithValidAnnotationTarget'); + $class = new ReflectionClass(Fixtures\ClassWithValidAnnotationTarget::class); $reader->getClassAnnotations($class); // Now import an incredibly dull class which makes use of the same class level annotation that the previous class does. - $class = new ReflectionClass('Doctrine\Tests\Common\Annotations\Fixtures\ClassWithClassAnnotationOnly'); + $class = new ReflectionClass(Fixtures\ClassWithClassAnnotationOnly::class); $annotations = $reader->getClassAnnotations($class); // This include needs to be here since we need the PHP compiler to run over it as the next thing the PHP @@ -367,11 +365,11 @@ public function testResetsPhpParserAfterUse() // If this fails then something is quite badly wrong elsewhere. // Note that if this happens before the require it can cause other PHP files to be included, resetting the // compiler global state, and invalidating this test case. - $this->assertNotEmpty($annotations); + self::assertNotEmpty($annotations); $annotations = $reader->getClassAnnotations(new \ReflectionClass(new \Doctrine_Tests_Common_Annotations_Fixtures_ClassNoNamespaceNoComment())); // And if our workaround for this bug is OK, our class with no doc comment should not have any class annotations. - $this->assertEmpty($annotations); + self::assertEmpty($annotations); } /** @@ -381,17 +379,17 @@ public function testResetsPhpParserAfterUse() public function testErrorWhenInvalidAnnotationIsUsed() { $reader = $this->getReader(); - $ref = new \ReflectionClass('Doctrine\Tests\Common\Annotations\Fixtures\InvalidAnnotationUsageClass'); + $ref = new \ReflectionClass(Fixtures\InvalidAnnotationUsageClass::class); $reader->getClassAnnotations($ref); } public function testInvalidAnnotationUsageButIgnoredClass() { $reader = $this->getReader(); - $ref = new \ReflectionClass('Doctrine\Tests\Common\Annotations\Fixtures\InvalidAnnotationUsageButIgnoredClass'); + $ref = new \ReflectionClass(Fixtures\InvalidAnnotationUsageButIgnoredClass::class); $annots = $reader->getClassAnnotations($ref); - $this->assertEquals(2, count($annots)); + self::assertCount(2, $annots); } /** @@ -401,37 +399,37 @@ public function testInvalidAnnotationUsageButIgnoredClass() public function testInvalidAnnotationButIgnored() { $reader = $this->getReader(); - $class = new \ReflectionClass('Doctrine\Tests\Common\Annotations\Fixtures\ClassDDC1660'); + $class = new \ReflectionClass(Fixtures\ClassDDC1660::class); - $this->assertTrue(class_exists('Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Version')); - $this->assertCount(0, $reader->getClassAnnotations($class)); - $this->assertCount(0, $reader->getMethodAnnotations($class->getMethod('bar'))); - $this->assertCount(0, $reader->getPropertyAnnotations($class->getProperty('foo'))); + self::assertTrue(class_exists(Fixtures\Annotation\Version::class)); + self::assertEmpty($reader->getClassAnnotations($class)); + self::assertEmpty($reader->getMethodAnnotations($class->getMethod('bar'))); + self::assertEmpty($reader->getPropertyAnnotations($class->getProperty('foo'))); } public function testAnnotationEnumeratorException() { $reader = $this->getReader(); - $class = new \ReflectionClass('Doctrine\Tests\Common\Annotations\Fixtures\ClassWithAnnotationEnum'); + $class = new \ReflectionClass(Fixtures\ClassWithAnnotationEnum::class); - $this->assertCount(1, $bar = $reader->getMethodAnnotations($class->getMethod('bar'))); - $this->assertCount(1, $foo = $reader->getPropertyAnnotations($class->getProperty('foo'))); + self::assertCount(1, $bar = $reader->getMethodAnnotations($class->getMethod('bar'))); + self::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]); + self::assertInstanceOf(Fixtures\AnnotationEnum::class, $bar[0]); + self::assertInstanceOf(Fixtures\AnnotationEnum::class, $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()); + } catch (AnnotationException $exc) { + self::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()); + } catch (AnnotationException $exc) { + self::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()); } } @@ -441,7 +439,7 @@ public function testAnnotationEnumeratorException() public function testIgnoreFixMeAndUpperCaseToDo() { $reader = $this->getReader(); - $ref = new \ReflectionClass('Doctrine\Tests\Common\Annotations\DCOM106'); + $ref = new \ReflectionClass(DCOM106::class); $reader->getClassAnnotations($ref); } @@ -633,16 +631,20 @@ class DCOM106 namespace Doctrine\Tests\Common\Annotations\Foo; +use Doctrine\Common\Annotations\Annotation; + /** @Annotation */ -class Name extends \Doctrine\Common\Annotations\Annotation +class Name extends Annotation { public $name; } namespace Doctrine\Tests\Common\Annotations\Bar; +use Doctrine\Common\Annotations\Annotation; + /** @Annotation */ -class Name extends \Doctrine\Common\Annotations\Annotation +class Name extends Annotation { public $name; } diff --git a/tests/Doctrine/Tests/Common/Annotations/Annotation/TargetTest.php b/tests/Doctrine/Tests/Common/Annotations/Annotation/TargetTest.php index 7627f7636..20f483872 100644 --- a/tests/Doctrine/Tests/Common/Annotations/Annotation/TargetTest.php +++ b/tests/Doctrine/Tests/Common/Annotations/Annotation/TargetTest.php @@ -33,15 +33,15 @@ class TargetTest extends \PHPUnit_Framework_TestCase */ public function testValidMixedTargets() { - $target = new Target(array("value" => array("ALL"))); - $this->assertEquals(Target::TARGET_ALL, $target->targets); + $target = new Target(array('value' => array('ALL'))); + self::assertEquals(Target::TARGET_ALL, $target->targets); - $target = new Target(array("value" => array("METHOD", "METHOD"))); - $this->assertEquals(Target::TARGET_METHOD, $target->targets); - $this->assertNotEquals(Target::TARGET_PROPERTY, $target->targets); + $target = new Target(array('value' => array('METHOD', 'METHOD'))); + self::assertEquals(Target::TARGET_METHOD, $target->targets); + self::assertNotEquals(Target::TARGET_PROPERTY, $target->targets); - $target = new Target(array("value" => array("PROPERTY", "METHOD"))); - $this->assertEquals(Target::TARGET_METHOD | Target::TARGET_PROPERTY, $target->targets); + $target = new Target(array('value' => array('PROPERTY', 'METHOD'))); + self::assertEquals(Target::TARGET_METHOD | Target::TARGET_PROPERTY, $target->targets); } } diff --git a/tests/Doctrine/Tests/Common/Annotations/AnnotationReaderTest.php b/tests/Doctrine/Tests/Common/Annotations/AnnotationReaderTest.php index 00176758c..f49ed7db9 100644 --- a/tests/Doctrine/Tests/Common/Annotations/AnnotationReaderTest.php +++ b/tests/Doctrine/Tests/Common/Annotations/AnnotationReaderTest.php @@ -22,34 +22,34 @@ protected function getReader(DocParser $parser = null) public function testMethodAnnotationFromTrait() { $reader = $this->getReader(); - $ref = new \ReflectionClass('Doctrine\Tests\Common\Annotations\Fixtures\ClassUsesTrait'); + $ref = new \ReflectionClass(Fixtures\ClassUsesTrait::class); $annotations = $reader->getMethodAnnotations($ref->getMethod('someMethod')); - $this->assertInstanceOf('Doctrine\Tests\Common\Annotations\Bar\Autoload', $annotations[0]); + self::assertInstanceOf(Bar\Autoload::class, $annotations[0]); $annotations = $reader->getMethodAnnotations($ref->getMethod('traitMethod')); - $this->assertInstanceOf('Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Autoload', $annotations[0]); + self::assertInstanceOf(Fixtures\Annotation\Autoload::class, $annotations[0]); } public function testMethodAnnotationFromOverwrittenTrait() { $reader = $this->getReader(); - $ref = new \ReflectionClass('Doctrine\Tests\Common\Annotations\Fixtures\ClassOverwritesTrait'); + $ref = new \ReflectionClass(Fixtures\ClassOverwritesTrait::class); $annotations = $reader->getMethodAnnotations($ref->getMethod('traitMethod')); - $this->assertInstanceOf('Doctrine\Tests\Common\Annotations\Bar2\Autoload', $annotations[0]); + self::assertInstanceOf(Bar2\Autoload::class, $annotations[0]); } public function testPropertyAnnotationFromTrait() { $reader = $this->getReader(); - $ref = new \ReflectionClass('Doctrine\Tests\Common\Annotations\Fixtures\ClassUsesTrait'); + $ref = new \ReflectionClass(Fixtures\ClassUsesTrait::class); $annotations = $reader->getPropertyAnnotations($ref->getProperty('aProperty')); - $this->assertInstanceOf('Doctrine\Tests\Common\Annotations\Bar\Autoload', $annotations[0]); + self::assertInstanceOf(Bar\Autoload::class, $annotations[0]); $annotations = $reader->getPropertyAnnotations($ref->getProperty('traitProperty')); - $this->assertInstanceOf('Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Autoload', $annotations[0]); + self::assertInstanceOf(Fixtures\Annotation\Autoload::class, $annotations[0]); } public function testOmitNotRegisteredAnnotation() @@ -58,10 +58,10 @@ public function testOmitNotRegisteredAnnotation() $parser->setIgnoreNotImportedAnnotations(true); $reader = $this->getReader($parser); - $ref = new \ReflectionClass('Doctrine\Tests\Common\Annotations\Fixtures\ClassWithNotRegisteredAnnotationUsed'); + $ref = new \ReflectionClass(Fixtures\ClassWithNotRegisteredAnnotationUsed::class); $annotations = $reader->getMethodAnnotations($ref->getMethod('methodWithNotRegisteredAnnotation')); - $this->assertEquals(array(), $annotations); + self::assertEquals(array(), $annotations); } /** diff --git a/tests/Doctrine/Tests/Common/Annotations/AnnotationRegistryTest.php b/tests/Doctrine/Tests/Common/Annotations/AnnotationRegistryTest.php index 7ae5ed079..36db2b535 100644 --- a/tests/Doctrine/Tests/Common/Annotations/AnnotationRegistryTest.php +++ b/tests/Doctrine/Tests/Common/Annotations/AnnotationRegistryTest.php @@ -6,7 +6,7 @@ class AnnotationRegistryTest extends \PHPUnit_Framework_TestCase { - protected $class = 'Doctrine\Common\Annotations\AnnotationRegistry'; + protected $class = AnnotationRegistry::class; /** * @runInSeparateProcess @@ -18,13 +18,13 @@ public function testReset() $this->setStaticField($this->class, 'autoloadNamespaces', $data); $this->setStaticField($this->class, 'loaders', $data); - $this->assertEquals($data, $this->getStaticField($this->class, 'autoloadNamespaces')); - $this->assertEquals($data, $this->getStaticField($this->class, 'loaders')); + self::assertEquals($data, $this->getStaticField($this->class, 'autoloadNamespaces')); + self::assertEquals($data, $this->getStaticField($this->class, 'loaders')); AnnotationRegistry::reset(); - $this->assertEmpty($this->getStaticField($this->class, 'autoloadNamespaces')); - $this->assertEmpty($this->getStaticField($this->class, 'loaders')); + self::assertEmpty($this->getStaticField($this->class, 'autoloadNamespaces')); + self::assertEmpty($this->getStaticField($this->class, 'loaders')); } /** @@ -35,7 +35,7 @@ public function testRegisterAutoloadNamespaces() $this->setStaticField($this->class, 'autoloadNamespaces', array('foo' => 'bar')); AnnotationRegistry::registerAutoloadNamespaces(array('test' => 'bar')); - $this->assertEquals(array('foo' => 'bar', 'test' => 'bar'), $this->getStaticField($this->class, 'autoloadNamespaces')); + self::assertEquals(array('foo' => 'bar', 'test' => 'bar'), $this->getStaticField($this->class, 'autoloadNamespaces')); } /** diff --git a/tests/Doctrine/Tests/Common/Annotations/CachedReaderTest.php b/tests/Doctrine/Tests/Common/Annotations/CachedReaderTest.php index fa723bcbf..d558eba91 100644 --- a/tests/Doctrine/Tests/Common/Annotations/CachedReaderTest.php +++ b/tests/Doctrine/Tests/Common/Annotations/CachedReaderTest.php @@ -6,6 +6,7 @@ use Doctrine\Common\Annotations\AnnotationReader; use Doctrine\Common\Annotations\CachedReader; use Doctrine\Common\Cache\ArrayCache; +use Doctrine\Common\Cache\Cache; class CachedReaderTest extends AbstractReaderTest { @@ -16,7 +17,7 @@ public function testIgnoresStaleCache() $cache = time() - 10; touch(__DIR__.'/Fixtures/Controller.php', $cache + 10); - $this->doTestCacheStale('Doctrine\Tests\Common\Annotations\Fixtures\Controller', $cache); + $this->doTestCacheStale(Fixtures\Controller::class, $cache); } /** @@ -28,7 +29,7 @@ public function testIgnoresStaleCacheWithParentClass() touch(__DIR__.'/Fixtures/ControllerWithParentClass.php', $cache - 10); touch(__DIR__.'/Fixtures/AbstractController.php', $cache + 10); - $this->doTestCacheStale('Doctrine\Tests\Common\Annotations\Fixtures\ControllerWithParentClass', $cache); + $this->doTestCacheStale(Fixtures\ControllerWithParentClass::class, $cache); } /** @@ -40,7 +41,7 @@ public function testIgnoresStaleCacheWithTraits() touch(__DIR__.'/Fixtures/ControllerWithTrait.php', $cache - 10); touch(__DIR__.'/Fixtures/Traits/SecretRouteTrait.php', $cache + 10); - $this->doTestCacheStale('Doctrine\Tests\Common\Annotations\Fixtures\ControllerWithTrait', $cache); + $this->doTestCacheStale(Fixtures\ControllerWithTrait::class, $cache); } /** @@ -54,7 +55,7 @@ public function testIgnoresStaleCacheWithTraitsThatUseOtherTraits() touch(__DIR__ . '/Fixtures/Traits/EmptyTrait.php', $cache + 10); $this->doTestCacheStale( - 'Doctrine\Tests\Common\Annotations\Fixtures\ClassThatUsesTraitThatUsesAnotherTrait', + Fixtures\ClassThatUsesTraitThatUsesAnotherTrait::class, $cache ); } @@ -70,7 +71,7 @@ public function testIgnoresStaleCacheWithInterfacesThatExtendOtherInterfaces() touch(__DIR__ . '/Fixtures/EmptyInterface.php', $cache + 10); $this->doTestCacheStale( - 'Doctrine\Tests\Common\Annotations\Fixtures\InterfaceThatExtendsAnInterface', + Fixtures\InterfaceThatExtendsAnInterface::class, $cache ); } @@ -79,7 +80,8 @@ protected function doTestCacheStale($className, $lastCacheModification) { $cacheKey = $className; - $cache = $this->createMock('Doctrine\Common\Cache\Cache'); + /* @var $cache Cache|\PHPUnit_Framework_MockObject_MockObject */ + $cache = $this->createMock(Cache::class); $cache ->expects($this->at(0)) ->method('fetch') @@ -107,7 +109,7 @@ protected function doTestCacheStale($className, $lastCacheModification) $route = new Route(); $route->pattern = '/someprefix'; - $this->assertEquals(array($route), $reader->getClassAnnotations(new \ReflectionClass($className))); + self::assertEquals(array($route), $reader->getClassAnnotations(new \ReflectionClass($className))); } protected function getReader() diff --git a/tests/Doctrine/Tests/Common/Annotations/DocLexerTest.php b/tests/Doctrine/Tests/Common/Annotations/DocLexerTest.php index b9fe007f3..5f6db9917 100644 --- a/tests/Doctrine/Tests/Common/Annotations/DocLexerTest.php +++ b/tests/Doctrine/Tests/Common/Annotations/DocLexerTest.php @@ -10,25 +10,25 @@ public function testMarkerAnnotation() { $lexer = new DocLexer; - $lexer->setInput("@Name"); - $this->assertNull($lexer->token); - $this->assertNull($lexer->lookahead); + $lexer->setInput('@Name'); + self::assertNull($lexer->token); + self::assertNull($lexer->lookahead); - $this->assertTrue($lexer->moveNext()); - $this->assertNull($lexer->token); - $this->assertEquals('@', $lexer->lookahead['value']); + self::assertTrue($lexer->moveNext()); + self::assertNull($lexer->token); + self::assertEquals('@', $lexer->lookahead['value']); - $this->assertTrue($lexer->moveNext()); - $this->assertEquals('@', $lexer->token['value']); - $this->assertEquals('Name', $lexer->lookahead['value']); + self::assertTrue($lexer->moveNext()); + self::assertEquals('@', $lexer->token['value']); + self::assertEquals('Name', $lexer->lookahead['value']); - $this->assertFalse($lexer->moveNext()); + self::assertFalse($lexer->moveNext()); } public function testScannerTokenizesDocBlockWhitConstants() { $lexer = new DocLexer(); - $docblock = '@AnnotationWithConstants(PHP_EOL, ClassWithConstants::SOME_VALUE, ClassWithConstants::CONSTANT_, ClassWithConstants::CONST_ANT3, \Doctrine\Tests\Common\Annotations\Fixtures\IntefaceWithConstants::SOME_VALUE)'; + $docblock = '@AnnotationWithConstants(PHP_EOL, ClassWithConstants::SOME_VALUE, ClassWithConstants::CONSTANT_, ClassWithConstants::CONST_ANT3, \Doctrine\Tests\Common\Annotations\Fixtures\InterfaceWithConstants::SOME_VALUE)'; $tokens = array ( array( @@ -87,13 +87,13 @@ public function testScannerTokenizesDocBlockWhitConstants() 'type' => DocLexer::T_COMMA, ), array( - 'value' => '\\Doctrine\\Tests\\Common\\Annotations\\Fixtures\\IntefaceWithConstants::SOME_VALUE', + 'value' => '\\Doctrine\\Tests\\Common\\Annotations\\Fixtures\\InterfaceWithConstants::SOME_VALUE', 'position' => 129, 'type' => DocLexer::T_IDENTIFIER, ), array( 'value' => ')', - 'position' => 206, + 'position' => 207, 'type' => DocLexer::T_CLOSE_PARENTHESIS, ) @@ -104,12 +104,12 @@ public function testScannerTokenizesDocBlockWhitConstants() foreach ($tokens as $expected) { $lexer->moveNext(); $lookahead = $lexer->lookahead; - $this->assertEquals($expected['value'], $lookahead['value']); - $this->assertEquals($expected['type'], $lookahead['type']); - $this->assertEquals($expected['position'], $lookahead['position']); + self::assertEquals($expected['value'], $lookahead['value']); + self::assertEquals($expected['type'], $lookahead['type']); + self::assertEquals($expected['position'], $lookahead['position']); } - $this->assertFalse($lexer->moveNext()); + self::assertFalse($lexer->moveNext()); } @@ -146,12 +146,12 @@ public function testScannerTokenizesDocBlockWhitInvalidIdentifier() foreach ($tokens as $expected) { $lexer->moveNext(); $lookahead = $lexer->lookahead; - $this->assertEquals($expected['value'], $lookahead['value']); - $this->assertEquals($expected['type'], $lookahead['type']); - $this->assertEquals($expected['position'], $lookahead['position']); + self::assertEquals($expected['value'], $lookahead['value']); + self::assertEquals($expected['type'], $lookahead['type']); + self::assertEquals($expected['position'], $lookahead['position']); } - $this->assertFalse($lexer->moveNext()); + self::assertFalse($lexer->moveNext()); } /** @@ -163,7 +163,7 @@ public function testWithinDoubleQuotesVeryVeryLongStringWillNotOverflowPregSplit $lexer->setInput('"' . str_repeat('.', 20240) . '"'); - $this->assertInternalType('array', $lexer->glimpse()); + self::assertInternalType('array', $lexer->glimpse()); } /** @@ -207,11 +207,11 @@ public function testRecognizesDoubleQuotesEscapeSequence() foreach ($tokens as $expected) { $lexer->moveNext(); $lookahead = $lexer->lookahead; - $this->assertEquals($expected['value'], $lookahead['value']); - $this->assertEquals($expected['type'], $lookahead['type']); - $this->assertEquals($expected['position'], $lookahead['position']); + self::assertEquals($expected['value'], $lookahead['value']); + self::assertEquals($expected['type'], $lookahead['type']); + self::assertEquals($expected['position'], $lookahead['position']); } - $this->assertFalse($lexer->moveNext()); + self::assertFalse($lexer->moveNext()); } } diff --git a/tests/Doctrine/Tests/Common/Annotations/DocParserTest.php b/tests/Doctrine/Tests/Common/Annotations/DocParserTest.php index 632dd0794..ea067d405 100644 --- a/tests/Doctrine/Tests/Common/Annotations/DocParserTest.php +++ b/tests/Doctrine/Tests/Common/Annotations/DocParserTest.php @@ -2,12 +2,15 @@ namespace Doctrine\Tests\Common\Annotations; +use Doctrine\Common\Annotations\Annotation; +use Doctrine\Common\Annotations\AnnotationException; use Doctrine\Common\Annotations\DocParser; use Doctrine\Common\Annotations\AnnotationRegistry; use Doctrine\Common\Annotations\Annotation\Target; +use Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll; use Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithConstants; use Doctrine\Tests\Common\Annotations\Fixtures\ClassWithConstants; -use Doctrine\Tests\Common\Annotations\Fixtures\IntefaceWithConstants; +use Doctrine\Tests\Common\Annotations\Fixtures\InterfaceWithConstants; class DocParserTest extends \PHPUnit_Framework_TestCase { @@ -19,16 +22,16 @@ public function testNestedArraysWithNestedAnnotation() $result = $parser->parse('@Name(foo={1,2, {"key"=@Name}})'); $annot = $result[0]; - $this->assertTrue($annot instanceof Name); - $this->assertNull($annot->value); - $this->assertEquals(3, count($annot->foo)); - $this->assertEquals(1, $annot->foo[0]); - $this->assertEquals(2, $annot->foo[1]); - $this->assertTrue(is_array($annot->foo[2])); + self::assertInstanceOf(Name::class, $annot); + self::assertNull($annot->value); + self::assertCount(3, $annot->foo); + self::assertEquals(1, $annot->foo[0]); + self::assertEquals(2, $annot->foo[1]); + self::assertInternalType('array', $annot->foo[2]); $nestedArray = $annot->foo[2]; - $this->assertTrue(isset($nestedArray['key'])); - $this->assertTrue($nestedArray['key'] instanceof Name); + self::assertTrue(isset($nestedArray['key'])); + self::assertInstanceOf(Name::class, $nestedArray['key']); } public function testBasicAnnotations() @@ -36,48 +39,48 @@ public function testBasicAnnotations() $parser = $this->createTestParser(); // Marker annotation - $result = $parser->parse("@Name"); + $result = $parser->parse('@Name'); $annot = $result[0]; - $this->assertTrue($annot instanceof Name); - $this->assertNull($annot->value); - $this->assertNull($annot->foo); + self::assertInstanceOf(Name::class, $annot); + self::assertNull($annot->value); + self::assertNull($annot->foo); // Associative arrays $result = $parser->parse('@Name(foo={"key1" = "value1"})'); $annot = $result[0]; - $this->assertNull($annot->value); - $this->assertTrue(is_array($annot->foo)); - $this->assertTrue(isset($annot->foo['key1'])); + self::assertNull($annot->value); + self::assertInternalType('array', $annot->foo); + self::assertTrue(isset($annot->foo['key1'])); // Numerical arrays $result = $parser->parse('@Name({2="foo", 4="bar"})'); $annot = $result[0]; - $this->assertTrue(is_array($annot->value)); - $this->assertEquals('foo', $annot->value[2]); - $this->assertEquals('bar', $annot->value[4]); - $this->assertFalse(isset($annot->value[0])); - $this->assertFalse(isset($annot->value[1])); - $this->assertFalse(isset($annot->value[3])); + self::assertInternalType('array', $annot->value); + self::assertEquals('foo', $annot->value[2]); + self::assertEquals('bar', $annot->value[4]); + self::assertFalse(isset($annot->value[0])); + self::assertFalse(isset($annot->value[1])); + self::assertFalse(isset($annot->value[3])); // Multiple values $result = $parser->parse('@Name(@Name, @Name)'); $annot = $result[0]; - $this->assertTrue($annot instanceof Name); - $this->assertTrue(is_array($annot->value)); - $this->assertTrue($annot->value[0] instanceof Name); - $this->assertTrue($annot->value[1] instanceof Name); + self::assertInstanceOf(Name::class, $annot); + self::assertInternalType('array', $annot->value); + self::assertInstanceOf(Name::class, $annot->value[0]); + self::assertInstanceOf(Name::class, $annot->value[1]); // Multiple types as values $result = $parser->parse('@Name(foo="Bar", @Name, {"key1"="value1", "key2"="value2"})'); $annot = $result[0]; - $this->assertTrue($annot instanceof Name); - $this->assertTrue(is_array($annot->value)); - $this->assertTrue($annot->value[0] instanceof Name); - $this->assertTrue(is_array($annot->value[1])); - $this->assertEquals('value1', $annot->value[1]['key1']); - $this->assertEquals('value2', $annot->value[1]['key2']); + self::assertInstanceOf(Name::class, $annot); + self::assertInternalType('array', $annot->value); + self::assertInstanceOf(Name::class, $annot->value[0]); + self::assertInternalType('array', $annot->value[1]); + self::assertEquals('value1', $annot->value[1]['key1']); + self::assertEquals('value2', $annot->value[1]['key2']); // Complete docblock $docblock = <<parse($docblock); - $this->assertEquals(1, count($result)); + self::assertCount(1, $result); $annot = $result[0]; - $this->assertTrue($annot instanceof Name); - $this->assertEquals("bar", $annot->foo); - $this->assertNull($annot->value); + self::assertInstanceOf(Name::class, $annot); + self::assertEquals('bar', $annot->foo); + self::assertNull($annot->value); } public function testDefaultValueAnnotations() @@ -105,18 +108,18 @@ public function testDefaultValueAnnotations() $result = $parser->parse('@Name({"key1"="value1"})'); $annot = $result[0]; - $this->assertTrue($annot instanceof Name); - $this->assertTrue(is_array($annot->value)); - $this->assertEquals('value1', $annot->value['key1']); + self::assertInstanceOf(Name::class, $annot); + self::assertInternalType('array', $annot->value); + self::assertEquals('value1', $annot->value['key1']); // Array as first value and additional values $result = $parser->parse('@Name({"key1"="value1"}, foo="bar")'); $annot = $result[0]; - $this->assertTrue($annot instanceof Name); - $this->assertTrue(is_array($annot->value)); - $this->assertEquals('value1', $annot->value['key1']); - $this->assertEquals('bar', $annot->foo); + self::assertInstanceOf(Name::class, $annot); + self::assertInternalType('array', $annot->value); + self::assertEquals('value1', $annot->value['key1']); + self::assertEquals('bar', $annot->foo); } public function testNamespacedAnnotations() @@ -137,10 +140,10 @@ public function testNamespacedAnnotations() DOCBLOCK; $result = $parser->parse($docblock); - $this->assertEquals(1, count($result)); + self::assertCount(1, $result); $annot = $result[0]; - $this->assertTrue($annot instanceof Name); - $this->assertEquals("bar", $annot->foo); + self::assertInstanceOf(Name::class, $annot); + self::assertEquals('bar', $annot->foo); } /** @@ -165,14 +168,14 @@ public function testTypicalMethodDocBlock() DOCBLOCK; $result = $parser->parse($docblock); - $this->assertEquals(2, count($result)); - $this->assertTrue(isset($result[0])); - $this->assertTrue(isset($result[1])); + self::assertCount(2, $result); + self::assertTrue(isset($result[0])); + self::assertTrue(isset($result[1])); $annot = $result[0]; - $this->assertTrue($annot instanceof Name); - $this->assertEquals("bar", $annot->foo); + self::assertInstanceOf(Name::class, $annot); + self::assertEquals('bar', $annot->foo); $marker = $result[1]; - $this->assertTrue($marker instanceof Marker); + self::assertInstanceOf(Marker::class, $marker); } @@ -188,15 +191,14 @@ public function testAnnotationWithoutConstructor() DOCBLOCK; $result = $parser->parse($docblock); - $this->assertEquals(count($result), 1); + self::assertCount(1, $result); $annot = $result[0]; - $this->assertNotNull($annot); - $this->assertTrue($annot instanceof SomeAnnotationClassNameWithoutConstructor); + self::assertInstanceOf(SomeAnnotationClassNameWithoutConstructor::class, $annot); - $this->assertNull($annot->name); - $this->assertNotNull($annot->data); - $this->assertEquals($annot->data, "Some data"); + self::assertNull($annot->name); + self::assertNotNull($annot->data); + self::assertEquals($annot->data, 'Some data'); @@ -209,14 +211,14 @@ public function testAnnotationWithoutConstructor() $result = $parser->parse($docblock); - $this->assertEquals(count($result), 1); + self::assertCount(1, $result); $annot = $result[0]; - $this->assertNotNull($annot); - $this->assertTrue($annot instanceof SomeAnnotationClassNameWithoutConstructor); + self::assertNotNull($annot); + self::assertInstanceOf(SomeAnnotationClassNameWithoutConstructor::class, $annot); - $this->assertEquals($annot->name, "Some Name"); - $this->assertEquals($annot->data, "Some data"); + self::assertEquals($annot->name, 'Some Name'); + self::assertEquals($annot->data, 'Some data'); @@ -228,11 +230,11 @@ public function testAnnotationWithoutConstructor() DOCBLOCK; $result = $parser->parse($docblock); - $this->assertEquals(count($result), 1); + self::assertCount(1, $result); $annot = $result[0]; - $this->assertEquals($annot->data, "Some data"); - $this->assertNull($annot->name); + self::assertEquals($annot->data, 'Some data'); + self::assertNull($annot->name); $docblock = <<parse($docblock); - $this->assertEquals(count($result), 1); + self::assertCount(1, $result); $annot = $result[0]; - $this->assertEquals($annot->name, "Some name"); - $this->assertNull($annot->data); + self::assertEquals($annot->name, 'Some name'); + self::assertNull($annot->data); $docblock = <<parse($docblock); - $this->assertEquals(count($result), 1); + self::assertCount(1, $result); $annot = $result[0]; - $this->assertEquals($annot->data, "Some data"); - $this->assertNull($annot->name); + self::assertEquals($annot->data, 'Some data'); + self::assertNull($annot->name); @@ -270,11 +272,11 @@ public function testAnnotationWithoutConstructor() DOCBLOCK; $result = $parser->parse($docblock); - $this->assertEquals(count($result), 1); + self::assertCount(1, $result); $annot = $result[0]; - $this->assertEquals($annot->name, "Some name"); - $this->assertEquals($annot->data, "Some data"); + self::assertEquals($annot->name, 'Some name'); + self::assertEquals($annot->data, 'Some data'); $docblock = <<parse($docblock); - $this->assertEquals(count($result), 1); + self::assertCount(1, $result); $annot = $result[0]; - $this->assertEquals($annot->name, "Some name"); - $this->assertEquals($annot->data, "Some data"); + self::assertEquals($annot->name, 'Some name'); + self::assertEquals($annot->data, 'Some data'); $docblock = <<parse($docblock); - $this->assertEquals(count($result), 1); - $this->assertTrue($result[0] instanceof SomeAnnotationClassNameWithoutConstructorAndProperties); + self::assertCount(1, $result); + self::assertInstanceOf(SomeAnnotationClassNameWithoutConstructorAndProperties::class, $result[0]); } public function testAnnotationTarget() @@ -308,14 +310,14 @@ public function testAnnotationTarget() $parser->setImports(array( '__NAMESPACE__' => 'Doctrine\Tests\Common\Annotations\Fixtures', )); - $class = new \ReflectionClass('Doctrine\Tests\Common\Annotations\Fixtures\ClassWithValidAnnotationTarget'); + $class = new \ReflectionClass(Fixtures\ClassWithValidAnnotationTarget::class); $context = 'class ' . $class->getName(); $docComment = $class->getDocComment(); $parser->setTarget(Target::TARGET_CLASS); - $this->assertNotNull($parser->parse($docComment,$context)); + self::assertNotNull($parser->parse($docComment,$context)); $property = $class->getProperty('foo'); @@ -323,7 +325,7 @@ public function testAnnotationTarget() $context = 'property ' . $class->getName() . "::\$" . $property->getName(); $parser->setTarget(Target::TARGET_PROPERTY); - $this->assertNotNull($parser->parse($docComment,$context)); + self::assertNotNull($parser->parse($docComment,$context)); @@ -332,11 +334,11 @@ public function testAnnotationTarget() $context = 'method ' . $class->getName() . '::' . $method->getName() . '()'; $parser->setTarget(Target::TARGET_METHOD); - $this->assertNotNull($parser->parse($docComment,$context)); + self::assertNotNull($parser->parse($docComment,$context)); try { - $class = new \ReflectionClass('Doctrine\Tests\Common\Annotations\Fixtures\ClassWithInvalidAnnotationTargetAtClass'); + $class = new \ReflectionClass(Fixtures\ClassWithInvalidAnnotationTargetAtClass::class); $context = 'class ' . $class->getName(); $docComment = $class->getDocComment(); @@ -344,14 +346,14 @@ public function testAnnotationTarget() $parser->parse($docComment, $context); $this->fail(); - } catch (\Doctrine\Common\Annotations\AnnotationException $exc) { - $this->assertNotNull($exc->getMessage()); + } catch (AnnotationException $exc) { + self::assertNotNull($exc->getMessage()); } try { - $class = new \ReflectionClass('Doctrine\Tests\Common\Annotations\Fixtures\ClassWithInvalidAnnotationTargetAtMethod'); + $class = new \ReflectionClass(Fixtures\ClassWithInvalidAnnotationTargetAtMethod::class); $method = $class->getMethod('functionName'); $docComment = $method->getDocComment(); $context = 'method ' . $class->getName() . '::' . $method->getName() . '()'; @@ -360,13 +362,13 @@ public function testAnnotationTarget() $parser->parse($docComment, $context); $this->fail(); - } catch (\Doctrine\Common\Annotations\AnnotationException $exc) { - $this->assertNotNull($exc->getMessage()); + } catch (AnnotationException $exc) { + self::assertNotNull($exc->getMessage()); } try { - $class = new \ReflectionClass('Doctrine\Tests\Common\Annotations\Fixtures\ClassWithInvalidAnnotationTargetAtProperty'); + $class = new \ReflectionClass(Fixtures\ClassWithInvalidAnnotationTargetAtProperty::class); $property = $class->getProperty('foo'); $docComment = $property->getDocComment(); $context = 'property ' . $class->getName() . "::\$" . $property->getName(); @@ -375,8 +377,8 @@ public function testAnnotationTarget() $parser->parse($docComment, $context); $this->fail(); - } catch (\Doctrine\Common\Annotations\AnnotationException $exc) { - $this->assertNotNull($exc->getMessage()); + } catch (AnnotationException $exc) { + self::assertNotNull($exc->getMessage()); } } @@ -477,13 +479,13 @@ public function getAnnotationVarTypeProviderInvalid() array('string','string', '{1,2,3,4}','array'), // annotation instance - array('annotation','Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll', 'true','boolean'), - array('annotation','Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll', 'false','boolean'), - array('annotation','Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll', '12','integer'), - array('annotation','Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll', '1.2','double'), - array('annotation','Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll', '{"str"}','array'), - array('annotation','Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll', '{1,2,3,4}','array'), - array('annotation','Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll', '@Name','an instance of Doctrine\Tests\Common\Annotations\Name'), + array('annotation', AnnotationTargetAll::class, 'true','boolean'), + array('annotation', AnnotationTargetAll::class, 'false','boolean'), + array('annotation', AnnotationTargetAll::class, '12','integer'), + array('annotation', AnnotationTargetAll::class, '1.2','double'), + array('annotation', AnnotationTargetAll::class, '{"str"}','array'), + array('annotation', AnnotationTargetAll::class, '{1,2,3,4}','array'), + array('annotation', AnnotationTargetAll::class, '@Name','an instance of Doctrine\Tests\Common\Annotations\Name'), ); } @@ -505,12 +507,12 @@ public function getAnnotationVarTypeArrayProviderInvalid() array('arrayOfStrings', 'string', '{"foo","bar",1.2}', 'double'), array('arrayOfStrings', 'string', '1', 'integer'), - array('arrayOfAnnotations', 'Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll', 'true', 'boolean'), - array('arrayOfAnnotations', 'Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll', 'false', 'boolean'), - array('arrayOfAnnotations', 'Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll', '{@Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll,true}', 'boolean'), - array('arrayOfAnnotations', 'Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll', '{@Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll,true}', 'boolean'), - array('arrayOfAnnotations', 'Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll', '{@Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll,1.2}', 'double'), - array('arrayOfAnnotations', 'Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll', '{@Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll,@AnnotationExtendsAnnotationTargetAll,"str"}', 'string'), + array('arrayOfAnnotations', AnnotationTargetAll::class, 'true', 'boolean'), + array('arrayOfAnnotations', AnnotationTargetAll::class, 'false', 'boolean'), + array('arrayOfAnnotations', AnnotationTargetAll::class, '{@Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll,true}', 'boolean'), + array('arrayOfAnnotations', AnnotationTargetAll::class, '{@Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll,true}', 'boolean'), + array('arrayOfAnnotations', AnnotationTargetAll::class, '{@Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll,1.2}', 'double'), + array('arrayOfAnnotations', AnnotationTargetAll::class, '{@Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll,@AnnotationExtendsAnnotationTargetAll,"str"}', 'string'), ); } @@ -526,9 +528,9 @@ public function testAnnotationWithVarType($attribute, $value) $result = $parser->parse($docblock, $context); - $this->assertTrue(sizeof($result) === 1); - $this->assertInstanceOf('Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithVarType', $result[0]); - $this->assertNotNull($result[0]->$attribute); + self::assertCount(1, $result); + self::assertInstanceOf(Fixtures\AnnotationWithVarType::class, $result[0]); + self::assertNotNull($result[0]->$attribute); } /** @@ -544,8 +546,11 @@ public function testAnnotationWithVarTypeError($attribute,$type,$value,$given) try { $parser->parse($docblock, $context); $this->fail(); - } catch (\Doctrine\Common\Annotations\AnnotationException $exc) { - $this->assertContains("[Type Error] Attribute \"$attribute\" of @Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithVarType declared on property SomeClassName::invalidProperty. expects a(n) $type, but got $given.", $exc->getMessage()); + } catch (AnnotationException $exc) { + self::assertStringMatchesFormat( + '[Type Error] Attribute "' . $attribute . '" of @Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithVarType declared on property SomeClassName::invalidProperty. expects a(n) %A' . $type . ', but got ' . $given . '.', + $exc->getMessage() + ); } } @@ -563,8 +568,11 @@ public function testAnnotationWithVarTypeArrayError($attribute,$type,$value,$giv try { $parser->parse($docblock, $context); $this->fail(); - } catch (\Doctrine\Common\Annotations\AnnotationException $exc) { - $this->assertContains("[Type Error] Attribute \"$attribute\" of @Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithVarType declared on property SomeClassName::invalidProperty. expects either a(n) $type, or an array of {$type}s, but got $given.", $exc->getMessage()); + } catch (AnnotationException $exc) { + self::assertStringMatchesFormat( + '[Type Error] Attribute "' . $attribute . '" of @Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithVarType declared on property SomeClassName::invalidProperty. expects either a(n) %A' . $type . ', or an array of %A' . $type . 's, but got ' . $given . '.', + $exc->getMessage() + ); } } @@ -580,10 +588,10 @@ public function testAnnotationWithAttributes($attribute, $value) $result = $parser->parse($docblock, $context); - $this->assertTrue(sizeof($result) === 1); - $this->assertInstanceOf('Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithAttributes', $result[0]); - $getter = "get".ucfirst($attribute); - $this->assertNotNull($result[0]->$getter()); + self::assertCount(1, $result); + self::assertInstanceOf(Fixtures\AnnotationWithAttributes::class, $result[0]); + $getter = 'get' .ucfirst($attribute); + self::assertNotNull($result[0]->$getter()); } /** @@ -599,8 +607,8 @@ public function testAnnotationWithAttributesError($attribute,$type,$value,$given try { $parser->parse($docblock, $context); $this->fail(); - } catch (\Doctrine\Common\Annotations\AnnotationException $exc) { - $this->assertContains("[Type Error] Attribute \"$attribute\" of @Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithAttributes declared on property SomeClassName::invalidProperty. expects a(n) $type, but got $given.", $exc->getMessage()); + } catch (AnnotationException $exc) { + self::assertContains("[Type Error] Attribute \"$attribute\" of @Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithAttributes declared on property SomeClassName::invalidProperty. expects a(n) $type, but got $given.", $exc->getMessage()); } } @@ -618,8 +626,8 @@ public function testAnnotationWithAttributesWithVarTypeArrayError($attribute,$ty try { $parser->parse($docblock, $context); $this->fail(); - } catch (\Doctrine\Common\Annotations\AnnotationException $exc) { - $this->assertContains("[Type Error] Attribute \"$attribute\" of @Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithAttributes declared on property SomeClassName::invalidProperty. expects either a(n) $type, or an array of {$type}s, but got $given.", $exc->getMessage()); + } catch (AnnotationException $exc) { + self::assertContains("[Type Error] Attribute \"$attribute\" of @Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithAttributes declared on property SomeClassName::invalidProperty. expects either a(n) $type, or an array of {$type}s, but got $given.", $exc->getMessage()); } } @@ -633,60 +641,64 @@ public function testAnnotationWithRequiredAttributes() $docblock = '@Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithRequiredAttributes("Some Value", annot = @Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAnnotation)'; $result = $parser->parse($docblock); - $this->assertTrue(sizeof($result) === 1); - $this->assertInstanceOf('Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithRequiredAttributes', $result[0]); - $this->assertEquals("Some Value",$result[0]->getValue()); - $this->assertInstanceOf('Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAnnotation', $result[0]->getAnnot()); + self::assertCount(1, $result); + + /* @var $annotation Fixtures\AnnotationWithRequiredAttributes */ + $annotation = $result[0]; + + self::assertInstanceOf(Fixtures\AnnotationWithRequiredAttributes::class, $annotation); + self::assertEquals('Some Value', $annotation->getValue()); + self::assertInstanceOf(Fixtures\AnnotationTargetAnnotation::class, $annotation->getAnnot()); $docblock = '@Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithRequiredAttributes("Some Value")'; try { - $result = $parser->parse($docblock,$context); + $parser->parse($docblock, $context); $this->fail(); - } catch (\Doctrine\Common\Annotations\AnnotationException $exc) { - $this->assertContains('Attribute "annot" of @Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithRequiredAttributes declared on property SomeClassName::invalidProperty. expects a(n) Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAnnotation. This value should not be null.', $exc->getMessage()); + } catch (AnnotationException $exc) { + self::assertContains('Attribute "annot" of @Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithRequiredAttributes declared on property SomeClassName::invalidProperty. expects a(n) Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAnnotation. This value should not be null.', $exc->getMessage()); } $docblock = '@Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithRequiredAttributes(annot = @Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAnnotation)'; try { - $result = $parser->parse($docblock,$context); + $parser->parse($docblock, $context); $this->fail(); - } catch (\Doctrine\Common\Annotations\AnnotationException $exc) { - $this->assertContains('Attribute "value" of @Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithRequiredAttributes declared on property SomeClassName::invalidProperty. expects a(n) string. This value should not be null.', $exc->getMessage()); + } catch (AnnotationException $exc) { + self::assertContains('Attribute "value" of @Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithRequiredAttributes declared on property SomeClassName::invalidProperty. expects a(n) string. This value should not be null.', $exc->getMessage()); } } - public function testAnnotationWithRequiredAttributesWithoutContructor() + public function testAnnotationWithRequiredAttributesWithoutConstructor() { $parser = $this->createTestParser(); $context = 'property SomeClassName::invalidProperty.'; $parser->setTarget(Target::TARGET_PROPERTY); - $docblock = '@Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithRequiredAttributesWithoutContructor("Some Value", annot = @Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAnnotation)'; + $docblock = '@Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithRequiredAttributesWithoutConstructor("Some Value", annot = @Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAnnotation)'; $result = $parser->parse($docblock); - $this->assertTrue(sizeof($result) === 1); - $this->assertInstanceOf('Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithRequiredAttributesWithoutContructor', $result[0]); - $this->assertEquals("Some Value", $result[0]->value); - $this->assertInstanceOf('Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAnnotation', $result[0]->annot); + self::assertCount(1, $result); + self::assertInstanceOf(Fixtures\AnnotationWithRequiredAttributesWithoutConstructor::class, $result[0]); + self::assertEquals('Some Value', $result[0]->value); + self::assertInstanceOf(Fixtures\AnnotationTargetAnnotation::class, $result[0]->annot); - $docblock = '@Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithRequiredAttributesWithoutContructor("Some Value")'; + $docblock = '@Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithRequiredAttributesWithoutConstructor("Some Value")'; try { - $result = $parser->parse($docblock,$context); + $parser->parse($docblock, $context); $this->fail(); - } catch (\Doctrine\Common\Annotations\AnnotationException $exc) { - $this->assertContains('Attribute "annot" of @Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithRequiredAttributesWithoutContructor declared on property SomeClassName::invalidProperty. expects a(n) Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAnnotation. This value should not be null.', $exc->getMessage()); + } catch (AnnotationException $exc) { + self::assertContains('Attribute "annot" of @Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithRequiredAttributesWithoutConstructor declared on property SomeClassName::invalidProperty. expects a(n) \Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAnnotation. This value should not be null.', $exc->getMessage()); } - $docblock = '@Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithRequiredAttributesWithoutContructor(annot = @Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAnnotation)'; + $docblock = '@Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithRequiredAttributesWithoutConstructor(annot = @Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAnnotation)'; try { - $result = $parser->parse($docblock,$context); + $parser->parse($docblock, $context); $this->fail(); - } catch (\Doctrine\Common\Annotations\AnnotationException $exc) { - $this->assertContains('Attribute "value" of @Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithRequiredAttributesWithoutContructor declared on property SomeClassName::invalidProperty. expects a(n) string. This value should not be null.', $exc->getMessage()); + } catch (AnnotationException $exc) { + self::assertContains('Attribute "value" of @Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithRequiredAttributesWithoutConstructor declared on property SomeClassName::invalidProperty. expects a(n) string. This value should not be null.', $exc->getMessage()); } } @@ -782,12 +794,12 @@ public function getConstantsProvider() ClassWithConstants::SOME_VALUE ); $provider[] = array( - '@AnnotationWithConstants(IntefaceWithConstants::SOME_VALUE)', - IntefaceWithConstants::SOME_VALUE + '@AnnotationWithConstants(InterfaceWithConstants::SOME_VALUE)', + InterfaceWithConstants::SOME_VALUE ); $provider[] = array( - '@AnnotationWithConstants(\Doctrine\Tests\Common\Annotations\Fixtures\IntefaceWithConstants::SOME_VALUE)', - IntefaceWithConstants::SOME_VALUE + '@AnnotationWithConstants(\Doctrine\Tests\Common\Annotations\Fixtures\InterfaceWithConstants::SOME_VALUE)', + InterfaceWithConstants::SOME_VALUE ); $provider[] = array( '@AnnotationWithConstants({AnnotationWithConstants::STRING, AnnotationWithConstants::INTEGER, AnnotationWithConstants::FLOAT})', @@ -801,43 +813,43 @@ public function getConstantsProvider() ); $provider[] = array( '@AnnotationWithConstants({ - Doctrine\Tests\Common\Annotations\Fixtures\IntefaceWithConstants::SOME_KEY = AnnotationWithConstants::INTEGER + Doctrine\Tests\Common\Annotations\Fixtures\InterfaceWithConstants::SOME_KEY = AnnotationWithConstants::INTEGER })', - array(IntefaceWithConstants::SOME_KEY => AnnotationWithConstants::INTEGER) + array(InterfaceWithConstants::SOME_KEY => AnnotationWithConstants::INTEGER) ); $provider[] = array( '@AnnotationWithConstants({ - \Doctrine\Tests\Common\Annotations\Fixtures\IntefaceWithConstants::SOME_KEY = AnnotationWithConstants::INTEGER + \Doctrine\Tests\Common\Annotations\Fixtures\InterfaceWithConstants::SOME_KEY = AnnotationWithConstants::INTEGER })', - array(IntefaceWithConstants::SOME_KEY => AnnotationWithConstants::INTEGER) + array(InterfaceWithConstants::SOME_KEY => AnnotationWithConstants::INTEGER) ); $provider[] = array( '@AnnotationWithConstants({ AnnotationWithConstants::STRING = AnnotationWithConstants::INTEGER, ClassWithConstants::SOME_KEY = ClassWithConstants::SOME_VALUE, - Doctrine\Tests\Common\Annotations\Fixtures\ClassWithConstants::SOME_KEY = IntefaceWithConstants::SOME_VALUE + Doctrine\Tests\Common\Annotations\Fixtures\ClassWithConstants::SOME_KEY = InterfaceWithConstants::SOME_VALUE })', array( AnnotationWithConstants::STRING => AnnotationWithConstants::INTEGER, ClassWithConstants::SOME_KEY => ClassWithConstants::SOME_VALUE, - ClassWithConstants::SOME_KEY => IntefaceWithConstants::SOME_VALUE + ClassWithConstants::SOME_KEY => InterfaceWithConstants::SOME_VALUE ) ); $provider[] = array( '@AnnotationWithConstants(AnnotationWithConstants::class)', - 'Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithConstants' + AnnotationWithConstants::class ); $provider[] = array( '@AnnotationWithConstants({AnnotationWithConstants::class = AnnotationWithConstants::class})', - array('Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithConstants' => 'Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithConstants') + array(AnnotationWithConstants::class => AnnotationWithConstants::class) ); $provider[] = array( '@AnnotationWithConstants(Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithConstants::class)', - 'Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithConstants' + AnnotationWithConstants::class ); $provider[] = array( '@Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithConstants(Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithConstants::class)', - 'Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithConstants' + AnnotationWithConstants::class ); return $provider; } @@ -849,14 +861,14 @@ public function testSupportClassConstants($docblock, $expected) { $parser = $this->createTestParser(); $parser->setImports(array( - 'classwithconstants' => 'Doctrine\Tests\Common\Annotations\Fixtures\ClassWithConstants', - 'intefacewithconstants' => 'Doctrine\Tests\Common\Annotations\Fixtures\IntefaceWithConstants', - 'annotationwithconstants' => 'Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithConstants' + 'classwithconstants' => ClassWithConstants::class, + 'interfacewithconstants' => InterfaceWithConstants::class, + 'annotationwithconstants' => AnnotationWithConstants::class )); $result = $parser->parse($docblock); - $this->assertInstanceOf('\Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithConstants', $annotation = $result[0]); - $this->assertEquals($expected, $annotation->value); + self::assertInstanceOf(AnnotationWithConstants::class, $annotation = $result[0]); + self::assertEquals($expected, $annotation->value); } /** @@ -909,7 +921,7 @@ public function testAnnotationTargetSyntaxError() DOCBLOCK; $parser->setTarget(Target::TARGET_CLASS); - $parser->parse($docblock,$context); + $parser->parse($docblock, $context); } /** @@ -927,7 +939,7 @@ public function testAnnotationWithInvalidTargetDeclarationError() DOCBLOCK; $parser->setTarget(Target::TARGET_CLASS); - $parser->parse($docblock,$context); + $parser->parse($docblock, $context); } /** @@ -945,7 +957,7 @@ public function testAnnotationWithTargetEmptyError() DOCBLOCK; $parser->setTarget(Target::TARGET_CLASS); - $parser->parse($docblock,$context); + $parser->parse($docblock, $context); } /** @@ -965,7 +977,7 @@ public function testRegressionDDC575() $result = $parser->parse($docblock); - $this->assertInstanceOf("Doctrine\Tests\Common\Annotations\Name", $result[0]); + self::assertInstanceOf(Name::class, $result[0]); $docblock = <<parse($docblock); - $this->assertInstanceOf("Doctrine\Tests\Common\Annotations\Name", $result[0]); + self::assertInstanceOf(Name::class, $result[0]); } /** @@ -988,9 +1000,9 @@ public function testAnnotationWithoutClassIsIgnoredWithoutWarning() { $parser = new DocParser(); $parser->setIgnoreNotImportedAnnotations(true); - $result = $parser->parse("@param"); + $result = $parser->parse('@param'); - $this->assertEquals(0, count($result)); + self::assertEmpty($result); } /** @@ -1043,10 +1055,10 @@ public function testNotAnAnnotationClassIsIgnoredWithoutWarning() { $parser = new DocParser(); $parser->setIgnoreNotImportedAnnotations(true); - $parser->setIgnoredAnnotationNames(array('PHPUnit_Framework_TestCase' => true)); + $parser->setIgnoredAnnotationNames(array(\PHPUnit_Framework_TestCase::class => true)); $result = $parser->parse('@PHPUnit_Framework_TestCase'); - $this->assertEquals(0, count($result)); + self::assertEmpty($result); } public function testNotAnAnnotationClassIsIgnoredWithoutWarningWithoutCheating() @@ -1055,7 +1067,7 @@ public function testNotAnAnnotationClassIsIgnoredWithoutWarningWithoutCheating() $parser->setIgnoreNotImportedAnnotations(true); $result = $parser->parse('@PHPUnit_Framework_TestCase'); - $this->assertEmpty($result); + self::assertEmpty($result); } /** @@ -1076,7 +1088,7 @@ public function testAnnotationDoesntThrowExceptionWhenAtSignIsNotFollowedByIdent $parser = new DocParser(); $result = $parser->parse("'@'"); - $this->assertEquals(0, count($result)); + self::assertEmpty($result); } /** @@ -1094,19 +1106,19 @@ public function testAnnotationThrowsExceptionWhenAtSignIsNotFollowedByIdentifier */ public function testAutoloadAnnotation() { - $this->assertFalse(class_exists('Doctrine\Tests\Common\Annotations\Fixture\Annotation\Autoload', false), 'Pre-condition: Doctrine\Tests\Common\Annotations\Fixture\Annotation\Autoload not allowed to be loaded.'); + self::assertFalse(class_exists('Doctrine\Tests\Common\Annotations\Fixture\Annotation\Autoload', false), 'Pre-condition: Doctrine\Tests\Common\Annotations\Fixture\Annotation\Autoload not allowed to be loaded.'); $parser = new DocParser(); AnnotationRegistry::registerAutoloadNamespace('Doctrine\Tests\Common\Annotations\Fixtures\Annotation', __DIR__ . '/../../../../'); $parser->setImports(array( - 'autoload' => 'Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Autoload', + 'autoload' => Fixtures\Annotation\Autoload::class, )); $annotations = $parser->parse('@Autoload'); - $this->assertEquals(1, count($annotations)); - $this->assertInstanceOf('Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Autoload', $annotations[0]); + self::assertCount(1, $annotations); + self::assertInstanceOf(Fixtures\Annotation\Autoload::class, $annotations[0]); } public function createTestParser() @@ -1114,7 +1126,7 @@ public function createTestParser() $parser = new DocParser(); $parser->setIgnoreNotImportedAnnotations(true); $parser->setImports(array( - 'name' => 'Doctrine\Tests\Common\Annotations\Name', + 'name' => Name::class, '__NAMESPACE__' => 'Doctrine\Tests\Common\Annotations', )); @@ -1185,9 +1197,9 @@ public function testCastInt() { $parser = $this->createTestParser(); - $result = $parser->parse("@Name(foo=1234)"); + $result = $parser->parse('@Name(foo=1234)'); $annot = $result[0]; - $this->assertInternalType('int', $annot->foo); + self::assertInternalType('int', $annot->foo); } /** @@ -1197,9 +1209,9 @@ public function testCastNegativeInt() { $parser = $this->createTestParser(); - $result = $parser->parse("@Name(foo=-1234)"); + $result = $parser->parse('@Name(foo=-1234)'); $annot = $result[0]; - $this->assertInternalType('int', $annot->foo); + self::assertInternalType('int', $annot->foo); } /** @@ -1209,9 +1221,9 @@ public function testCastFloat() { $parser = $this->createTestParser(); - $result = $parser->parse("@Name(foo=1234.345)"); + $result = $parser->parse('@Name(foo=1234.345)'); $annot = $result[0]; - $this->assertInternalType('float', $annot->foo); + self::assertInternalType('float', $annot->foo); } /** @@ -1221,13 +1233,13 @@ public function testCastNegativeFloat() { $parser = $this->createTestParser(); - $result = $parser->parse("@Name(foo=-1234.345)"); + $result = $parser->parse('@Name(foo=-1234.345)'); $annot = $result[0]; - $this->assertInternalType('float', $annot->foo); + self::assertInternalType('float', $annot->foo); - $result = $parser->parse("@Marker(-1234.345)"); + $result = $parser->parse('@Marker(-1234.345)'); $annot = $result[0]; - $this->assertInternalType('float', $annot->value); + self::assertInternalType('float', $annot->value); } public function testReservedKeywordsInAnnotations() @@ -1235,23 +1247,23 @@ public function testReservedKeywordsInAnnotations() if (PHP_VERSION_ID >= 70000) { $this->markTestSkipped('This test requires PHP 5.6 or lower.'); } - require 'ReservedKeywordsClasses.php'; + require __DIR__ . '/ReservedKeywordsClasses.php'; $parser = $this->createTestParser(); $result = $parser->parse('@Doctrine\Tests\Common\Annotations\True'); - $this->assertTrue($result[0] instanceof True); + self::assertInstanceOf(True::class, $result[0]); $result = $parser->parse('@Doctrine\Tests\Common\Annotations\False'); - $this->assertTrue($result[0] instanceof False); + self::assertInstanceOf(False::class, $result[0]); $result = $parser->parse('@Doctrine\Tests\Common\Annotations\Null'); - $this->assertTrue($result[0] instanceof Null); + self::assertInstanceOf(Null::class, $result[0]); $result = $parser->parse('@True'); - $this->assertTrue($result[0] instanceof True); + self::assertInstanceOf(True::class, $result[0]); $result = $parser->parse('@False'); - $this->assertTrue($result[0] instanceof False); + self::assertInstanceOf(False::class, $result[0]); $result = $parser->parse('@Null'); - $this->assertTrue($result[0] instanceof Null); + self::assertInstanceOf(Null::class, $result[0]); } /** @@ -1287,8 +1299,8 @@ public function testTrailingCommaIsAllowed() "Foo", "Bar", })'); - $this->assertEquals(1, count($annots)); - $this->assertEquals(array('Foo', 'Bar'), $annots[0]->value); + self::assertCount(1, $annots); + self::assertEquals(array('Foo', 'Bar'), $annots[0]->value); } public function testTabPrefixIsAllowed() @@ -1301,8 +1313,8 @@ public function testTabPrefixIsAllowed() $parser = $this->createTestParser(); $result = $parser->parse($docblock); - $this->assertCount(1, $result); - $this->assertInstanceOf('Doctrine\Tests\Common\Annotations\Name', $result[0]); + self::assertCount(1, $result); + self::assertInstanceOf(Name::class, $result[0]); } public function testDefaultAnnotationValueIsNotOverwritten() @@ -1310,8 +1322,8 @@ public function testDefaultAnnotationValueIsNotOverwritten() $parser = $this->createTestParser(); $annots = $parser->parse('@Doctrine\Tests\Common\Annotations\Fixtures\Annotation\AnnotWithDefaultValue'); - $this->assertEquals(1, count($annots)); - $this->assertEquals('bar', $annots[0]->foo); + self::assertCount(1, $annots); + self::assertEquals('bar', $annots[0]->foo); } public function testArrayWithColon() @@ -1319,8 +1331,8 @@ public function testArrayWithColon() $parser = $this->createTestParser(); $annots = $parser->parse('@Name({"foo": "bar"})'); - $this->assertEquals(1, count($annots)); - $this->assertEquals(array('foo' => 'bar'), $annots[0]->value); + self::assertCount(1, $annots); + self::assertEquals(array('foo' => 'bar'), $annots[0]->value); } /** @@ -1341,8 +1353,8 @@ public function testEmptyArray() $parser = $this->createTestParser(); $annots = $parser->parse('@Name({"foo": {}})'); - $this->assertEquals(1, count($annots)); - $this->assertEquals(array('foo' => array()), $annots[0]->value); + self::assertCount(1, $annots); + self::assertEquals(array('foo' => array()), $annots[0]->value); } public function testKeyHasNumber() @@ -1350,8 +1362,8 @@ public function testKeyHasNumber() $parser = $this->createTestParser(); $annots = $parser->parse('@SettingsAnnotation(foo="test", bar2="test")'); - $this->assertEquals(1, count($annots)); - $this->assertEquals(array('foo' => 'test', 'bar2' => 'test'), $annots[0]->settings); + self::assertCount(1, $annots); + self::assertEquals(array('foo' => 'test', 'bar2' => 'test'), $annots[0]->settings); } /** @@ -1361,10 +1373,10 @@ public function testSupportsEscapedQuotedValues() { $result = $this->createTestParser()->parse('@Doctrine\Tests\Common\Annotations\Name(foo="""bar""")'); - $this->assertCount(1, $result); + self::assertCount(1, $result); - $this->assertTrue($result[0] instanceof Name); - $this->assertEquals('"bar"', $result[0]->foo); + self::assertInstanceOf(Name::class, $result[0]); + self::assertEquals('"bar"', $result[0]->foo); } /** @@ -1375,7 +1387,7 @@ public function testSupportsEscapedQuotedValues() public function testMultiByteAnnotation() { $overloadStringFunctions = 2; - if (!extension_loaded('mbstring') || (ini_get("mbstring.func_overload") & $overloadStringFunctions) == 0) { + if (!extension_loaded('mbstring') || (ini_get('mbstring.func_overload') & $overloadStringFunctions) == 0) { $this->markTestSkipped('This test requires mbstring function overloading is turned on'); } @@ -1389,7 +1401,7 @@ public function testMultiByteAnnotation() $docParser = $this->createTestParser(); $result = $docParser->parse($docblock); - $this->assertCount(1, $result); + self::assertCount(1, $result); } } @@ -1415,9 +1427,9 @@ class SomeAnnotationClassNameWithoutConstructor /** @Annotation */ class SomeAnnotationWithConstructorWithoutParams { - function __construct() + public function __construct() { - $this->data = "Some data"; + $this->data = 'Some data'; } public $data; public $name; @@ -1439,12 +1451,12 @@ class AnnotationWithInvalidTargetDeclaration{} class AnnotationWithTargetEmpty{} /** @Annotation */ -class AnnotationExtendsAnnotationTargetAll extends \Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll +class AnnotationExtendsAnnotationTargetAll extends AnnotationTargetAll { } /** @Annotation */ -class Name extends \Doctrine\Common\Annotations\Annotation { +class Name extends Annotation { public $foo; } @@ -1455,6 +1467,8 @@ class Marker { namespace Doctrine\Tests\Common\Annotations\FooBar; +use Doctrine\Common\Annotations\Annotation; + /** @Annotation */ -class Name extends \Doctrine\Common\Annotations\Annotation { +class Name extends Annotation { } diff --git a/tests/Doctrine/Tests/Common/Annotations/FileCacheReaderTest.php b/tests/Doctrine/Tests/Common/Annotations/FileCacheReaderTest.php index 325de88fd..d55f147d3 100644 --- a/tests/Doctrine/Tests/Common/Annotations/FileCacheReaderTest.php +++ b/tests/Doctrine/Tests/Common/Annotations/FileCacheReaderTest.php @@ -11,7 +11,7 @@ class FileCacheReaderTest extends AbstractReaderTest protected function getReader() { - $this->cacheDir = sys_get_temp_dir() . "/annotations_". uniqid(); + $this->cacheDir = sys_get_temp_dir() . '/annotations_' . uniqid('', true); @mkdir($this->cacheDir); return new FileCacheReader(new AnnotationReader(), $this->cacheDir); } @@ -29,12 +29,12 @@ public function tearDown() */ public function testAttemptToCreateAnnotationCacheDir() { - $this->cacheDir = sys_get_temp_dir() . "/not_existed_dir_". uniqid(); + $this->cacheDir = sys_get_temp_dir() . '/not_existed_dir_' . uniqid('', true); - $this->assertFalse(is_dir($this->cacheDir)); + self::assertFalse(is_dir($this->cacheDir)); new FileCacheReader(new AnnotationReader(), $this->cacheDir); - $this->assertTrue(is_dir($this->cacheDir)); + self::assertTrue(is_dir($this->cacheDir)); } } \ No newline at end of file diff --git a/tests/Doctrine/Tests/Common/Annotations/Fixtures/AnnotationWithAttributes.php b/tests/Doctrine/Tests/Common/Annotations/Fixtures/AnnotationWithAttributes.php index e3b5be7b7..e0ea83500 100644 --- a/tests/Doctrine/Tests/Common/Annotations/Fixtures/AnnotationWithAttributes.php +++ b/tests/Doctrine/Tests/Common/Annotations/Fixtures/AnnotationWithAttributes.php @@ -95,7 +95,7 @@ public function getArray() } /** - * @return Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll + * @return \Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll */ public function getAnnotation() { diff --git a/tests/Doctrine/Tests/Common/Annotations/Fixtures/AnnotationWithRequiredAttributes.php b/tests/Doctrine/Tests/Common/Annotations/Fixtures/AnnotationWithRequiredAttributes.php index 6eb1bc5aa..056ada5e5 100644 --- a/tests/Doctrine/Tests/Common/Annotations/Fixtures/AnnotationWithRequiredAttributes.php +++ b/tests/Doctrine/Tests/Common/Annotations/Fixtures/AnnotationWithRequiredAttributes.php @@ -27,7 +27,7 @@ public final function __construct(array $data) /** * - * @var Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAnnotation + * @var \Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAnnotation */ private $annot; @@ -40,7 +40,7 @@ public function getValue() } /** - * @return Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAnnotation + * @return \Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAnnotation */ public function getAnnot() { diff --git a/tests/Doctrine/Tests/Common/Annotations/Fixtures/AnnotationWithRequiredAttributesWithoutContructor.php b/tests/Doctrine/Tests/Common/Annotations/Fixtures/AnnotationWithRequiredAttributesWithoutConstructor.php similarity index 61% rename from tests/Doctrine/Tests/Common/Annotations/Fixtures/AnnotationWithRequiredAttributesWithoutContructor.php rename to tests/Doctrine/Tests/Common/Annotations/Fixtures/AnnotationWithRequiredAttributesWithoutConstructor.php index bf458ee77..68d4dad4c 100644 --- a/tests/Doctrine/Tests/Common/Annotations/Fixtures/AnnotationWithRequiredAttributesWithoutContructor.php +++ b/tests/Doctrine/Tests/Common/Annotations/Fixtures/AnnotationWithRequiredAttributesWithoutConstructor.php @@ -6,7 +6,7 @@ * @Annotation * @Target("ALL") */ -final class AnnotationWithRequiredAttributesWithoutContructor +final class AnnotationWithRequiredAttributesWithoutConstructor { /** @@ -17,7 +17,7 @@ final class AnnotationWithRequiredAttributesWithoutContructor /** * @Required - * @var Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAnnotation + * @var \Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAnnotation */ public $annot; diff --git a/tests/Doctrine/Tests/Common/Annotations/Fixtures/AnnotationWithVarType.php b/tests/Doctrine/Tests/Common/Annotations/Fixtures/AnnotationWithVarType.php index dc1d6ddbf..27af0b267 100644 --- a/tests/Doctrine/Tests/Common/Annotations/Fixtures/AnnotationWithVarType.php +++ b/tests/Doctrine/Tests/Common/Annotations/Fixtures/AnnotationWithVarType.php @@ -45,7 +45,7 @@ final class AnnotationWithVarType public $array; /** - * @var Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll + * @var \Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll */ public $annotation; @@ -60,7 +60,7 @@ final class AnnotationWithVarType public $arrayOfStrings; /** - * @var array + * @var \Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll[] */ public $arrayOfAnnotations; diff --git a/tests/Doctrine/Tests/Common/Annotations/Fixtures/ClassWithRequire.php b/tests/Doctrine/Tests/Common/Annotations/Fixtures/ClassWithRequire.php index 2dcc7263c..afb051a6b 100644 --- a/tests/Doctrine/Tests/Common/Annotations/Fixtures/ClassWithRequire.php +++ b/tests/Doctrine/Tests/Common/Annotations/Fixtures/ClassWithRequire.php @@ -3,7 +3,7 @@ namespace Doctrine\Tests\Common\Annotations\Fixtures; // Include a class named Api -require_once(__DIR__ . '/Api.php'); +require_once __DIR__ . '/Api.php'; use Doctrine\Tests\Common\Annotations\DummyAnnotationWithIgnoredAnnotation; diff --git a/tests/Doctrine/Tests/Common/Annotations/Fixtures/Controller.php b/tests/Doctrine/Tests/Common/Annotations/Fixtures/Controller.php index 85320642e..d537a6cc7 100644 --- a/tests/Doctrine/Tests/Common/Annotations/Fixtures/Controller.php +++ b/tests/Doctrine/Tests/Common/Annotations/Fixtures/Controller.php @@ -192,7 +192,7 @@ private function updateFieldAceProperty($name, array $changes) $aceIdProperty = new \ReflectionProperty('Symfony\Component\Security\Acl\Domain\Entry', 'id'); $aceIdProperty->setAccessible(true); - $aceIdProperty->setValue($ace, intval($aceId)); + $aceIdProperty->setValue($ace, (int) $aceId); } else { $currentIds[$ace->getId()] = true; } @@ -250,7 +250,7 @@ private function updateAceProperty($name, array $changes) $aceIdProperty = new \ReflectionProperty($ace, 'id'); $aceIdProperty->setAccessible(true); - $aceIdProperty->setValue($ace, intval($aceId)); + $aceIdProperty->setValue($ace, (int) $aceId); } else { $currentIds[$ace->getId()] = true; } diff --git a/tests/Doctrine/Tests/Common/Annotations/Fixtures/IntefaceWithConstants.php b/tests/Doctrine/Tests/Common/Annotations/Fixtures/IntefaceWithConstants.php deleted file mode 100644 index d375b201a..000000000 --- a/tests/Doctrine/Tests/Common/Annotations/Fixtures/IntefaceWithConstants.php +++ /dev/null @@ -1,10 +0,0 @@ - 'Annotations\Annotation\IgnorePhpDoc', 'ignoreannotation' => 'Annotations\Annotation\IgnoreAnnotation', - 'route' => 'Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Route', - 'template' => 'Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Template', + 'route' => Fixtures\Annotation\Route::class, + 'template' => Fixtures\Annotation\Template::class, '__NAMESPACE__' => 'Doctrine\Tests\Common\Annotations\Fixtures', ); $ignored = array( @@ -136,7 +136,7 @@ public function testDocLexerPerformance() */ public function testPhpParserPerformanceWithShortCut() { - $class = new \ReflectionClass('Doctrine\Tests\Common\Annotations\Fixtures\NamespacedSingleClassLOC1000'); + $class = new \ReflectionClass(Fixtures\NamespacedSingleClassLOC1000::class); $time = microtime(true); for ($i=0,$c=500; $i<$c; $i++) { @@ -153,7 +153,7 @@ public function testPhpParserPerformanceWithShortCut() */ public function testPhpParserPerformanceWithoutShortCut() { - $class = new \ReflectionClass('SingleClassLOC1000'); + $class = new \ReflectionClass(\SingleClassLOC1000::class); $time = microtime(true); for ($i=0,$c=500; $i<$c; $i++) { @@ -167,12 +167,12 @@ public function testPhpParserPerformanceWithoutShortCut() private function getMethod() { - return new \ReflectionMethod('Doctrine\Tests\Common\Annotations\Fixtures\Controller', 'helloAction'); + return new \ReflectionMethod(Fixtures\Controller::class, 'helloAction'); } private function printResults($test, $time, $iterations) { - if (0 == $iterations) { + if (! $iterations) { throw new \InvalidArgumentException('$iterations cannot be zero.'); } diff --git a/tests/Doctrine/Tests/Common/Annotations/PhpParserTest.php b/tests/Doctrine/Tests/Common/Annotations/PhpParserTest.php index 678954421..1858264ed 100644 --- a/tests/Doctrine/Tests/Common/Annotations/PhpParserTest.php +++ b/tests/Doctrine/Tests/Common/Annotations/PhpParserTest.php @@ -16,7 +16,7 @@ public function testParseClassWithMultipleClassesInFile() $class = new ReflectionClass(__NAMESPACE__ . '\Fixtures\MultipleClassesInFile'); $parser = new PhpParser(); - $this->assertEquals(array( + self::assertEquals(array( 'route' => __NAMESPACE__ . '\Fixtures\Annotation\Route', 'secure' => __NAMESPACE__ . '\Fixtures\Annotation\Secure', ), $parser->parseClass($class)); @@ -27,7 +27,7 @@ public function testParseClassWithMultipleImportsInUseStatement() $class = new ReflectionClass(__NAMESPACE__ . '\Fixtures\MultipleImportsInUseStatement'); $parser = new PhpParser(); - $this->assertEquals(array( + self::assertEquals(array( 'route' => __NAMESPACE__ . '\Fixtures\Annotation\Route', 'secure' => __NAMESPACE__ . '\Fixtures\Annotation\Secure', ), $parser->parseClass($class)); @@ -41,7 +41,7 @@ public function testParseClassWithGroupUseStatement() $class = new ReflectionClass(__NAMESPACE__ . '\Fixtures\GroupUseStatement'); $parser = new PhpParser(); - $this->assertEquals(array( + self::assertEquals(array( 'route' => __NAMESPACE__ . '\Fixtures\Annotation\Route', 'supersecure' => __NAMESPACE__ . '\Fixtures\Annotation\Secure', 'template' => __NAMESPACE__ . '\Fixtures\Annotation\Template', @@ -51,12 +51,13 @@ public function testParseClassWithGroupUseStatement() public function testParseClassWhenNotUserDefined() { $parser = new PhpParser(); - $this->assertEquals(array(), $parser->parseClass(new \ReflectionClass('\stdClass'))); + self::assertEquals(array(), $parser->parseClass(new \ReflectionClass(\stdClass::class))); } public function testClassFileDoesNotExist() { - $class = $this->getMockBuilder('\ReflectionClass') + /* @var $class ReflectionClass|\PHPUnit_Framework_MockObject_MockObject */ + $class = $this->getMockBuilder(ReflectionClass::class) ->disableOriginalConstructor() ->getMock(); $class->expects($this->once()) @@ -64,15 +65,15 @@ public function testClassFileDoesNotExist() ->will($this->returnValue('/valid/class/Fake.php(35) : eval()d code')); $parser = new PhpParser(); - $this->assertEquals(array(), $parser->parseClass($class)); + self::assertEquals(array(), $parser->parseClass($class)); } public function testParseClassWhenClassIsNotNamespaced() { $parser = new PhpParser(); - $class = new ReflectionClass('\AnnotationsTestsFixturesNonNamespacedClass'); + $class = new ReflectionClass(\AnnotationsTestsFixturesNonNamespacedClass::class); - $this->assertEquals(array( + self::assertEquals(array( 'route' => __NAMESPACE__ . '\Fixtures\Annotation\Route', 'template' => __NAMESPACE__ . '\Fixtures\Annotation\Template', ), $parser->parseClass($class)); @@ -83,7 +84,7 @@ public function testParseClassWhenClassIsInterface() $parser = new PhpParser(); $class = new ReflectionClass(__NAMESPACE__ . '\Fixtures\TestInterface'); - $this->assertEquals(array( + self::assertEquals(array( 'secure' => __NAMESPACE__ . '\Fixtures\Annotation\Secure', ), $parser->parseClass($class)); } @@ -93,7 +94,7 @@ public function testClassWithFullyQualifiedUseStatements() $parser = new PhpParser(); $class = new ReflectionClass(__NAMESPACE__ . '\Fixtures\ClassWithFullyQualifiedUseStatements'); - $this->assertEquals(array( + self::assertEquals(array( 'secure' => '\\' . __NAMESPACE__ . '\Fixtures\Annotation\Secure', 'route' => '\\' . __NAMESPACE__ . '\Fixtures\Annotation\Route', 'template' => '\\' . __NAMESPACE__ . '\Fixtures\Annotation\Template', @@ -105,7 +106,7 @@ public function testNamespaceAndClassCommentedOut() $parser = new PhpParser(); $class = new ReflectionClass(__NAMESPACE__ . '\Fixtures\NamespaceAndClassCommentedOut'); - $this->assertEquals(array( + self::assertEquals(array( 'route' => __NAMESPACE__ . '\Fixtures\Annotation\Route', 'template' => __NAMESPACE__ . '\Fixtures\Annotation\Template', ), $parser->parseClass($class)); @@ -116,7 +117,7 @@ public function testEqualNamespacesPerFileWithClassAsFirst() $parser = new PhpParser(); $class = new ReflectionClass(__NAMESPACE__ . '\Fixtures\EqualNamespacesPerFileWithClassAsFirst'); - $this->assertEquals(array( + self::assertEquals(array( 'secure' => __NAMESPACE__ . '\Fixtures\Annotation\Secure', 'route' => __NAMESPACE__ . '\Fixtures\Annotation\Route', ), $parser->parseClass($class)); @@ -127,7 +128,7 @@ public function testEqualNamespacesPerFileWithClassAsLast() $parser = new PhpParser(); $class = new ReflectionClass(__NAMESPACE__ . '\Fixtures\EqualNamespacesPerFileWithClassAsLast'); - $this->assertEquals(array( + self::assertEquals(array( 'route' => __NAMESPACE__ . '\Fixtures\Annotation\Route', 'template' => __NAMESPACE__ . '\Fixtures\Annotation\Template', ), $parser->parseClass($class)); @@ -138,7 +139,7 @@ public function testDifferentNamespacesPerFileWithClassAsFirst() $parser = new PhpParser(); $class = new ReflectionClass(__NAMESPACE__ . '\Fixtures\DifferentNamespacesPerFileWithClassAsFirst'); - $this->assertEquals(array( + self::assertEquals(array( 'secure' => __NAMESPACE__ . '\Fixtures\Annotation\Secure', ), $parser->parseClass($class)); } @@ -148,7 +149,7 @@ public function testDifferentNamespacesPerFileWithClassAsLast() $parser = new PhpParser(); $class = new ReflectionClass(__NAMESPACE__ . '\Fixtures\DifferentNamespacesPerFileWithClassAsLast'); - $this->assertEquals(array( + self::assertEquals(array( 'template' => __NAMESPACE__ . '\Fixtures\Annotation\Template', ), $parser->parseClass($class)); } @@ -156,9 +157,9 @@ public function testDifferentNamespacesPerFileWithClassAsLast() public function testGlobalNamespacesPerFileWithClassAsFirst() { $parser = new PhpParser(); - $class = new \ReflectionClass('\GlobalNamespacesPerFileWithClassAsFirst'); + $class = new \ReflectionClass(\GlobalNamespacesPerFileWithClassAsFirst::class); - $this->assertEquals(array( + self::assertEquals(array( 'secure' => __NAMESPACE__ . '\Fixtures\Annotation\Secure', 'route' => __NAMESPACE__ . '\Fixtures\Annotation\Route', ), $parser->parseClass($class)); @@ -167,9 +168,9 @@ public function testGlobalNamespacesPerFileWithClassAsFirst() public function testGlobalNamespacesPerFileWithClassAsLast() { $parser = new PhpParser(); - $class = new ReflectionClass('\GlobalNamespacesPerFileWithClassAsLast'); + $class = new ReflectionClass(\GlobalNamespacesPerFileWithClassAsLast::class); - $this->assertEquals(array( + self::assertEquals(array( 'route' => __NAMESPACE__ . '\Fixtures\Annotation\Route', 'template' => __NAMESPACE__ . '\Fixtures\Annotation\Template', ), $parser->parseClass($class)); @@ -180,7 +181,7 @@ public function testNamespaceWithClosureDeclaration() $parser = new PhpParser(); $class = new ReflectionClass(__NAMESPACE__ . '\Fixtures\NamespaceWithClosureDeclaration'); - $this->assertEquals(array( + self::assertEquals(array( 'secure' => __NAMESPACE__ . '\Fixtures\Annotation\Secure', 'route' => __NAMESPACE__ . '\Fixtures\Annotation\Route', 'template' => __NAMESPACE__ . '\Fixtures\Annotation\Template', @@ -192,13 +193,13 @@ public function testIfPointerResetsOnMultipleParsingTries() $parser = new PhpParser(); $class = new ReflectionClass(__NAMESPACE__ . '\Fixtures\NamespaceWithClosureDeclaration'); - $this->assertEquals(array( + self::assertEquals(array( 'secure' => __NAMESPACE__ . '\Fixtures\Annotation\Secure', 'route' => __NAMESPACE__ . '\Fixtures\Annotation\Route', 'template' => __NAMESPACE__ . '\Fixtures\Annotation\Template', ), $parser->parseClass($class)); - $this->assertEquals(array( + self::assertEquals(array( 'secure' => __NAMESPACE__ . '\Fixtures\Annotation\Secure', 'route' => __NAMESPACE__ . '\Fixtures\Annotation\Route', 'template' => __NAMESPACE__ . '\Fixtures\Annotation\Template', @@ -214,7 +215,7 @@ public function testClassWithClosure() $parser = new PhpParser(); $class = new ReflectionClass(__NAMESPACE__ . '\Fixtures\ClassWithClosure'); - $this->assertEquals(array( + self::assertEquals(array( 'annotationtargetall' => __NAMESPACE__ . '\Fixtures\AnnotationTargetAll', 'annotationtargetannotation' => __NAMESPACE__ . '\Fixtures\AnnotationTargetAnnotation', ), $parser->parseClass($class)); diff --git a/tests/Doctrine/Tests/Common/Annotations/SimpleAnnotationReaderTest.php b/tests/Doctrine/Tests/Common/Annotations/SimpleAnnotationReaderTest.php index 30ac52e23..5f1b73483 100644 --- a/tests/Doctrine/Tests/Common/Annotations/SimpleAnnotationReaderTest.php +++ b/tests/Doctrine/Tests/Common/Annotations/SimpleAnnotationReaderTest.php @@ -75,10 +75,10 @@ public function testErrorWhenInvalidAnnotationIsUsed() public function testInvalidAnnotationUsageButIgnoredClass() { $reader = $this->getReader(); - $ref = new \ReflectionClass('Doctrine\Tests\Common\Annotations\Fixtures\InvalidAnnotationUsageButIgnoredClass'); + $ref = new \ReflectionClass(Fixtures\InvalidAnnotationUsageButIgnoredClass::class); $annots = $reader->getClassAnnotations($ref); - $this->assertCount(1, $annots); + self::assertCount(1, $annots); } public function testIncludeIgnoreAnnotation() @@ -95,12 +95,12 @@ public function testIncludeIgnoreAnnotation() public function testInvalidAnnotationButIgnored() { $reader = $this->getReader(); - $class = new \ReflectionClass('Doctrine\Tests\Common\Annotations\Fixtures\ClassDDC1660'); + $class = new \ReflectionClass(Fixtures\ClassDDC1660::class); - $this->assertTrue(class_exists('Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Version')); - $this->assertCount(1, $reader->getClassAnnotations($class)); - $this->assertCount(1, $reader->getMethodAnnotations($class->getMethod('bar'))); - $this->assertCount(1, $reader->getPropertyAnnotations($class->getProperty('foo'))); + self::assertTrue(class_exists(Fixtures\Annotation\Version::class)); + self::assertCount(1, $reader->getClassAnnotations($class)); + self::assertCount(1, $reader->getMethodAnnotations($class->getMethod('bar'))); + self::assertCount(1, $reader->getPropertyAnnotations($class->getProperty('foo'))); } protected function getReader() diff --git a/tests/Doctrine/Tests/Common/Annotations/Ticket/DCOM55Test.php b/tests/Doctrine/Tests/Common/Annotations/Ticket/DCOM55Test.php index a6159d59a..0cedfcac7 100644 --- a/tests/Doctrine/Tests/Common/Annotations/Ticket/DCOM55Test.php +++ b/tests/Doctrine/Tests/Common/Annotations/Ticket/DCOM55Test.php @@ -27,8 +27,8 @@ public function testAnnotation() $reader = new AnnotationReader(); $annots = $reader->getClassAnnotations($class); - $this->assertEquals(1, count($annots)); - $this->assertInstanceOf(__NAMESPACE__.'\\DCOM55Annotation', $annots[0]); + self::assertCount(1, $annots); + self::assertInstanceOf(__NAMESPACE__.'\\DCOM55Annotation', $annots[0]); } public function testParseAnnotationDocblocks() @@ -37,7 +37,7 @@ public function testParseAnnotationDocblocks() $reader = new AnnotationReader(); $annots = $reader->getClassAnnotations($class); - $this->assertEquals(0, count($annots)); + self::assertEmpty($annots); } } diff --git a/tests/Doctrine/Tests/Common/Annotations/Ticket/DCOM58Test.php b/tests/Doctrine/Tests/Common/Annotations/Ticket/DCOM58Test.php index 769ab3862..52c0546f4 100644 --- a/tests/Doctrine/Tests/Common/Annotations/Ticket/DCOM58Test.php +++ b/tests/Doctrine/Tests/Common/Annotations/Ticket/DCOM58Test.php @@ -16,63 +16,64 @@ class DCOM58Test extends \PHPUnit_Framework_TestCase public function testIssue() { $reader = new AnnotationReader(); - $result = $reader->getClassAnnotations(new \ReflectionClass(__NAMESPACE__."\MappedClass")); + $result = $reader->getClassAnnotations(new \ReflectionClass(__NAMESPACE__ . '\MappedClass')); - foreach ($result as $annot) { - $classAnnotations[get_class($annot)] = $annot; - } + $classAnnotations = array_combine( + array_map('get_class', $result), + $result + ); - $this->assertTrue(!isset($classAnnotations['']), 'Class "xxx" is not a valid entity or mapped super class.'); + self::assertArrayNotHasKey('', $classAnnotations, 'Class "xxx" is not a valid entity or mapped super class.'); } public function testIssueGlobalNamespace() { - $docblock = "@Entity"; + $docblock = '@Entity'; $parser = new DocParser(); $parser->setImports(array( - "__NAMESPACE__" =>"Doctrine\Tests\Common\Annotations\Ticket\Doctrine\ORM\Mapping" + '__NAMESPACE__' => 'Doctrine\Tests\Common\Annotations\Ticket\Doctrine\ORM\Mapping' )); $annots = $parser->parse($docblock); - $this->assertEquals(1, count($annots)); - $this->assertInstanceOf("Doctrine\Tests\Common\Annotations\Ticket\Doctrine\ORM\Mapping\Entity", $annots[0]); + self::assertCount(1, $annots); + self::assertInstanceOf(Doctrine\ORM\Mapping\Entity::class, $annots[0]); } public function testIssueNamespaces() { - $docblock = "@Entity"; + $docblock = '@Entity'; $parser = new DocParser(); - $parser->addNamespace("Doctrine\Tests\Common\Annotations\Ticket\Doctrine\ORM"); + $parser->addNamespace('Doctrine\Tests\Common\Annotations\Ticket\Doctrine\ORM'); $annots = $parser->parse($docblock); - $this->assertEquals(1, count($annots)); - $this->assertInstanceOf("Doctrine\Tests\Common\Annotations\Ticket\Doctrine\ORM\Entity", $annots[0]); + self::assertCount(1, $annots); + self::assertInstanceOf(Doctrine\ORM\Entity::class, $annots[0]); } public function testIssueMultipleNamespaces() { - $docblock = "@Entity"; + $docblock = '@Entity'; $parser = new DocParser(); - $parser->addNamespace("Doctrine\Tests\Common\Annotations\Ticket\Doctrine\ORM\Mapping"); - $parser->addNamespace("Doctrine\Tests\Common\Annotations\Ticket\Doctrine\ORM"); + $parser->addNamespace('Doctrine\Tests\Common\Annotations\Ticket\Doctrine\ORM\Mapping'); + $parser->addNamespace('Doctrine\Tests\Common\Annotations\Ticket\Doctrine\ORM'); $annots = $parser->parse($docblock); - $this->assertEquals(1, count($annots)); - $this->assertInstanceOf("Doctrine\Tests\Common\Annotations\Ticket\Doctrine\ORM\Mapping\Entity", $annots[0]); + self::assertCount(1, $annots); + self::assertInstanceOf(Doctrine\ORM\Mapping\Entity::class, $annots[0]); } public function testIssueWithNamespacesOrImports() { - $docblock = "@Entity"; + $docblock = '@Entity'; $parser = new DocParser(); $annots = $parser->parse($docblock); - $this->assertEquals(1, count($annots)); - $this->assertInstanceOf("Entity", $annots[0]); - $this->assertEquals(1, count($annots)); + self::assertCount(1, $annots); + self::assertInstanceOf(\Entity::class, $annots[0]); + self::assertCount(1, $annots); } @@ -82,8 +83,8 @@ public function testIssueSimpleAnnotationReader() $reader->addNamespace('Doctrine\Tests\Common\Annotations\Ticket\Doctrine\ORM\Mapping'); $annots = $reader->getClassAnnotations(new \ReflectionClass(__NAMESPACE__."\MappedClass")); - $this->assertEquals(1, count($annots)); - $this->assertInstanceOf("Doctrine\Tests\Common\Annotations\Ticket\Doctrine\ORM\Mapping\Entity", $annots[0]); + self::assertCount(1, $annots); + self::assertInstanceOf(Doctrine\ORM\Mapping\Entity::class, $annots[0]); } } diff --git a/tests/Doctrine/Tests/TestInit.php b/tests/Doctrine/Tests/TestInit.php index e433ae187..8419260fb 100644 --- a/tests/Doctrine/Tests/TestInit.php +++ b/tests/Doctrine/Tests/TestInit.php @@ -17,7 +17,7 @@ } }); -require_once __DIR__ . "/../../../vendor/autoload.php"; +require_once __DIR__ . '/../../../vendor/autoload.php'; \Doctrine\Common\Annotations\AnnotationRegistry::registerAutoloadNamespace( 'Doctrine\Tests\Common\Annotations\Fixtures', __DIR__ . '/../../'