From 586af72770f443eb4a9d98021834499e49710666 Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Fri, 30 Dec 2016 14:36:36 +0100 Subject: [PATCH 01/32] Replacing `assertEquals()` + `count()` with `assertCount()` --- .../Common/Annotations/AbstractReaderTest.php | 50 +++++++++---------- .../Common/Annotations/DocParserTest.php | 50 +++++++++---------- .../Common/Annotations/Ticket/DCOM55Test.php | 4 +- .../Common/Annotations/Ticket/DCOM58Test.php | 12 ++--- 4 files changed, 58 insertions(+), 58 deletions(-) diff --git a/tests/Doctrine/Tests/Common/Annotations/AbstractReaderTest.php b/tests/Doctrine/Tests/Common/Annotations/AbstractReaderTest.php index cd0867aa2..b87806bea 100644 --- a/tests/Doctrine/Tests/Common/Annotations/AbstractReaderTest.php +++ b/tests/Doctrine/Tests/Common/Annotations/AbstractReaderTest.php @@ -22,30 +22,30 @@ public function testAnnotations() $class = $this->getReflectionClass(); $reader = $this->getReader(); - $this->assertEquals(1, count($reader->getClassAnnotations($class))); + $this->assertCount(1, $reader->getClassAnnotations($class)); $this->assertInstanceOf($annotName = 'Doctrine\Tests\Common\Annotations\DummyAnnotation', $annot = $reader->getClassAnnotation($class, $annotName)); $this->assertEquals("hello", $annot->dummyValue); $field1Prop = $class->getProperty('field1'); $propAnnots = $reader->getPropertyAnnotations($field1Prop); - $this->assertEquals(1, count($propAnnots)); + $this->assertCount(1, $propAnnots); $this->assertInstanceOf($annotName, $annot = $reader->getPropertyAnnotation($field1Prop, $annotName)); $this->assertEquals("fieldHello", $annot->dummyValue); $getField1Method = $class->getMethod('getField1'); $methodAnnots = $reader->getMethodAnnotations($getField1Method); - $this->assertEquals(1, count($methodAnnots)); + $this->assertCount(1, $methodAnnots); $this->assertInstanceOf($annotName, $annot = $reader->getMethodAnnotation($getField1Method, $annotName)); $this->assertEquals(array(1, 2, "three"), $annot->value); $field2Prop = $class->getProperty('field2'); $propAnnots = $reader->getPropertyAnnotations($field2Prop); - $this->assertEquals(1, count($propAnnots)); + $this->assertCount(1, $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->assertCount(1, $joinTableAnnot->joinColumns); + $this->assertCount(1, $joinTableAnnot->inverseJoinColumns); + $this->assertInstanceOf(DummyJoinColumn::class, $joinTableAnnot->joinColumns[0]); + $this->assertInstanceOf(DummyJoinColumn::class, $joinTableAnnot->inverseJoinColumns[0]); $this->assertEquals('col1', $joinTableAnnot->joinColumns[0]->name); $this->assertEquals('col2', $joinTableAnnot->joinColumns[0]->referencedColumnName); $this->assertEquals('col3', $joinTableAnnot->inverseJoinColumns[0]->name); @@ -70,10 +70,10 @@ public function testAnnotationsWithValidTargets() $reader = $this->getReader(); $class = new ReflectionClass('Doctrine\Tests\Common\Annotations\Fixtures\ClassWithValidAnnotationTarget'); - $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')))); + $this->assertCount(1, $reader->getClassAnnotations($class)); + $this->assertCount(1, $reader->getPropertyAnnotations($class->getProperty('foo'))); + $this->assertCount(1, $reader->getMethodAnnotations($class->getMethod('someFunction'))); + $this->assertCount(1, $reader->getPropertyAnnotations($class->getProperty('nested'))); } public function testAnnotationsWithVarType() @@ -81,8 +81,8 @@ public function testAnnotationsWithVarType() $reader = $this->getReader(); $class = new ReflectionClass('Doctrine\Tests\Common\Annotations\Fixtures\ClassWithAnnotationWithVarType'); - $this->assertEquals(1,count($fooAnnot = $reader->getPropertyAnnotations($class->getProperty('foo')))); - $this->assertEquals(1,count($barAnnot = $reader->getMethodAnnotations($class->getMethod('bar')))); + $this->assertCount(1, $fooAnnot = $reader->getPropertyAnnotations($class->getProperty('foo'))); + $this->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); @@ -93,8 +93,8 @@ public function testAtInDescription() $reader = $this->getReader(); $class = new ReflectionClass('Doctrine\Tests\Common\Annotations\Fixtures\ClassWithAtInDescriptionAndAnnotation'); - $this->assertEquals(1, count($fooAnnot = $reader->getPropertyAnnotations($class->getProperty('foo')))); - $this->assertEquals(1, count($barAnnot = $reader->getPropertyAnnotations($class->getProperty('bar')))); + $this->assertCount(1, $fooAnnot = $reader->getPropertyAnnotations($class->getProperty('foo'))); + $this->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]); @@ -246,7 +246,7 @@ public function testMultipleAnnotationsOnSameLine() { $reader = $this->getReader(); $annots = $reader->getPropertyAnnotations(new \ReflectionProperty('Doctrine\Tests\Common\Annotations\DummyClass2', 'id')); - $this->assertEquals(3, count($annots)); + $this->assertCount(3, $annots); } public function testNonAnnotationProblem() @@ -270,7 +270,7 @@ public function testImportWithConcreteAnnotation() $reader = $this->getReader(); $property = new \ReflectionProperty('Doctrine\Tests\Common\Annotations\TestImportWithConcreteAnnotation', 'field'); $annotations = $reader->getPropertyAnnotations($property); - $this->assertEquals(1, count($annotations)); + $this->assertCount(1, $annotations); $this->assertNotNull($reader->getPropertyAnnotation($property, 'Doctrine\Tests\Common\Annotations\DummyAnnotation')); } @@ -282,11 +282,11 @@ public function testImportWithInheritance() $ref = new \ReflectionClass($class); $childAnnotations = $reader->getPropertyAnnotations($ref->getProperty('child')); - $this->assertEquals(1, count($childAnnotations)); + $this->assertCount(1, $childAnnotations); $this->assertInstanceOf('Doctrine\Tests\Common\Annotations\Foo\Name', reset($childAnnotations)); $parentAnnotations = $reader->getPropertyAnnotations($ref->getProperty('parent')); - $this->assertEquals(1, count($parentAnnotations)); + $this->assertCount(1, $parentAnnotations); $this->assertInstanceOf('Doctrine\Tests\Common\Annotations\Bar\Name', reset($parentAnnotations)); } @@ -315,7 +315,7 @@ public function testTopLevelAnnotation() $reader = $this->getReader(); $annotations = $reader->getPropertyAnnotations(new \ReflectionProperty('Doctrine\Tests\Common\Annotations\TestTopLevelAnnotationClass', 'field')); - $this->assertEquals(1, count($annotations)); + $this->assertCount(1, $annotations); $this->assertInstanceOf('\TopLevelAnnotation', reset($annotations)); } @@ -391,7 +391,7 @@ public function testInvalidAnnotationUsageButIgnoredClass() $ref = new \ReflectionClass('Doctrine\Tests\Common\Annotations\Fixtures\InvalidAnnotationUsageButIgnoredClass'); $annots = $reader->getClassAnnotations($ref); - $this->assertEquals(2, count($annots)); + $this->assertCount(2, $annots); } /** @@ -404,9 +404,9 @@ public function testInvalidAnnotationButIgnored() $class = new \ReflectionClass('Doctrine\Tests\Common\Annotations\Fixtures\ClassDDC1660'); $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'))); + $this->assertEmpty($reader->getClassAnnotations($class)); + $this->assertEmpty($reader->getMethodAnnotations($class->getMethod('bar'))); + $this->assertEmpty($reader->getPropertyAnnotations($class->getProperty('foo'))); } public function testAnnotationEnumeratorException() diff --git a/tests/Doctrine/Tests/Common/Annotations/DocParserTest.php b/tests/Doctrine/Tests/Common/Annotations/DocParserTest.php index 632dd0794..0c6dbc2dd 100644 --- a/tests/Doctrine/Tests/Common/Annotations/DocParserTest.php +++ b/tests/Doctrine/Tests/Common/Annotations/DocParserTest.php @@ -19,9 +19,9 @@ public function testNestedArraysWithNestedAnnotation() $result = $parser->parse('@Name(foo={1,2, {"key"=@Name}})'); $annot = $result[0]; - $this->assertTrue($annot instanceof Name); + $this->assertInstanceOf(Name::class, $annot); $this->assertNull($annot->value); - $this->assertEquals(3, count($annot->foo)); + $this->assertCount(3, $annot->foo); $this->assertEquals(1, $annot->foo[0]); $this->assertEquals(2, $annot->foo[1]); $this->assertTrue(is_array($annot->foo[2])); @@ -90,9 +90,9 @@ public function testBasicAnnotations() DOCBLOCK; $result = $parser->parse($docblock); - $this->assertEquals(1, count($result)); + $this->assertCount(1, $result); $annot = $result[0]; - $this->assertTrue($annot instanceof Name); + $this->assertInstanceOf(Name::class, $annot); $this->assertEquals("bar", $annot->foo); $this->assertNull($annot->value); } @@ -137,9 +137,9 @@ public function testNamespacedAnnotations() DOCBLOCK; $result = $parser->parse($docblock); - $this->assertEquals(1, count($result)); + $this->assertCount(1, $result); $annot = $result[0]; - $this->assertTrue($annot instanceof Name); + $this->assertInstanceOf(Name::class, $annot); $this->assertEquals("bar", $annot->foo); } @@ -165,11 +165,11 @@ public function testTypicalMethodDocBlock() DOCBLOCK; $result = $parser->parse($docblock); - $this->assertEquals(2, count($result)); + $this->assertCount(2, $result); $this->assertTrue(isset($result[0])); $this->assertTrue(isset($result[1])); $annot = $result[0]; - $this->assertTrue($annot instanceof Name); + $this->assertInstanceOf(Name::class, $annot); $this->assertEquals("bar", $annot->foo); $marker = $result[1]; $this->assertTrue($marker instanceof Marker); @@ -188,7 +188,7 @@ public function testAnnotationWithoutConstructor() DOCBLOCK; $result = $parser->parse($docblock); - $this->assertEquals(count($result), 1); + $this->assertCount(1, $result); $annot = $result[0]; $this->assertNotNull($annot); @@ -209,7 +209,7 @@ public function testAnnotationWithoutConstructor() $result = $parser->parse($docblock); - $this->assertEquals(count($result), 1); + $this->assertCount(1, $result); $annot = $result[0]; $this->assertNotNull($annot); @@ -228,7 +228,7 @@ public function testAnnotationWithoutConstructor() DOCBLOCK; $result = $parser->parse($docblock); - $this->assertEquals(count($result), 1); + $this->assertCount(1, $result); $annot = $result[0]; $this->assertEquals($annot->data, "Some data"); @@ -242,7 +242,7 @@ public function testAnnotationWithoutConstructor() DOCBLOCK; $result = $parser->parse($docblock); - $this->assertEquals(count($result), 1); + $this->assertCount(1, $result); $annot = $result[0]; $this->assertEquals($annot->name, "Some name"); @@ -255,7 +255,7 @@ public function testAnnotationWithoutConstructor() DOCBLOCK; $result = $parser->parse($docblock); - $this->assertEquals(count($result), 1); + $this->assertCount(1, $result); $annot = $result[0]; $this->assertEquals($annot->data, "Some data"); @@ -270,7 +270,7 @@ public function testAnnotationWithoutConstructor() DOCBLOCK; $result = $parser->parse($docblock); - $this->assertEquals(count($result), 1); + $this->assertCount(1, $result); $annot = $result[0]; $this->assertEquals($annot->name, "Some name"); @@ -284,7 +284,7 @@ public function testAnnotationWithoutConstructor() DOCBLOCK; $result = $parser->parse($docblock); - $this->assertEquals(count($result), 1); + $this->assertCount(1, $result); $annot = $result[0]; $this->assertEquals($annot->name, "Some name"); @@ -297,7 +297,7 @@ public function testAnnotationWithoutConstructor() DOCBLOCK; $result = $parser->parse($docblock); - $this->assertEquals(count($result), 1); + $this->assertCount(1, $result); $this->assertTrue($result[0] instanceof SomeAnnotationClassNameWithoutConstructorAndProperties); } @@ -990,7 +990,7 @@ public function testAnnotationWithoutClassIsIgnoredWithoutWarning() $parser->setIgnoreNotImportedAnnotations(true); $result = $parser->parse("@param"); - $this->assertEquals(0, count($result)); + $this->assertEmpty($result); } /** @@ -1046,7 +1046,7 @@ public function testNotAnAnnotationClassIsIgnoredWithoutWarning() $parser->setIgnoredAnnotationNames(array('PHPUnit_Framework_TestCase' => true)); $result = $parser->parse('@PHPUnit_Framework_TestCase'); - $this->assertEquals(0, count($result)); + $this->assertEmpty($result); } public function testNotAnAnnotationClassIsIgnoredWithoutWarningWithoutCheating() @@ -1076,7 +1076,7 @@ public function testAnnotationDoesntThrowExceptionWhenAtSignIsNotFollowedByIdent $parser = new DocParser(); $result = $parser->parse("'@'"); - $this->assertEquals(0, count($result)); + $this->assertEmpty($result); } /** @@ -1105,7 +1105,7 @@ public function testAutoloadAnnotation() )); $annotations = $parser->parse('@Autoload'); - $this->assertEquals(1, count($annotations)); + $this->assertCount(1, $annotations); $this->assertInstanceOf('Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Autoload', $annotations[0]); } @@ -1287,7 +1287,7 @@ public function testTrailingCommaIsAllowed() "Foo", "Bar", })'); - $this->assertEquals(1, count($annots)); + $this->assertCount(1, $annots); $this->assertEquals(array('Foo', 'Bar'), $annots[0]->value); } @@ -1310,7 +1310,7 @@ public function testDefaultAnnotationValueIsNotOverwritten() $parser = $this->createTestParser(); $annots = $parser->parse('@Doctrine\Tests\Common\Annotations\Fixtures\Annotation\AnnotWithDefaultValue'); - $this->assertEquals(1, count($annots)); + $this->assertCount(1, $annots); $this->assertEquals('bar', $annots[0]->foo); } @@ -1319,7 +1319,7 @@ public function testArrayWithColon() $parser = $this->createTestParser(); $annots = $parser->parse('@Name({"foo": "bar"})'); - $this->assertEquals(1, count($annots)); + $this->assertCount(1, $annots); $this->assertEquals(array('foo' => 'bar'), $annots[0]->value); } @@ -1341,7 +1341,7 @@ public function testEmptyArray() $parser = $this->createTestParser(); $annots = $parser->parse('@Name({"foo": {}})'); - $this->assertEquals(1, count($annots)); + $this->assertCount(1, $annots); $this->assertEquals(array('foo' => array()), $annots[0]->value); } @@ -1350,7 +1350,7 @@ public function testKeyHasNumber() $parser = $this->createTestParser(); $annots = $parser->parse('@SettingsAnnotation(foo="test", bar2="test")'); - $this->assertEquals(1, count($annots)); + $this->assertCount(1, $annots); $this->assertEquals(array('foo' => 'test', 'bar2' => 'test'), $annots[0]->settings); } diff --git a/tests/Doctrine/Tests/Common/Annotations/Ticket/DCOM55Test.php b/tests/Doctrine/Tests/Common/Annotations/Ticket/DCOM55Test.php index a6159d59a..dcd168946 100644 --- a/tests/Doctrine/Tests/Common/Annotations/Ticket/DCOM55Test.php +++ b/tests/Doctrine/Tests/Common/Annotations/Ticket/DCOM55Test.php @@ -27,7 +27,7 @@ public function testAnnotation() $reader = new AnnotationReader(); $annots = $reader->getClassAnnotations($class); - $this->assertEquals(1, count($annots)); + $this->assertCount(1, $annots); $this->assertInstanceOf(__NAMESPACE__.'\\DCOM55Annotation', $annots[0]); } @@ -37,7 +37,7 @@ public function testParseAnnotationDocblocks() $reader = new AnnotationReader(); $annots = $reader->getClassAnnotations($class); - $this->assertEquals(0, count($annots)); + $this->assertEmpty($annots); } } diff --git a/tests/Doctrine/Tests/Common/Annotations/Ticket/DCOM58Test.php b/tests/Doctrine/Tests/Common/Annotations/Ticket/DCOM58Test.php index 769ab3862..10c162947 100644 --- a/tests/Doctrine/Tests/Common/Annotations/Ticket/DCOM58Test.php +++ b/tests/Doctrine/Tests/Common/Annotations/Ticket/DCOM58Test.php @@ -35,7 +35,7 @@ public function testIssueGlobalNamespace() $annots = $parser->parse($docblock); - $this->assertEquals(1, count($annots)); + $this->assertCount(1, $annots); $this->assertInstanceOf("Doctrine\Tests\Common\Annotations\Ticket\Doctrine\ORM\Mapping\Entity", $annots[0]); } @@ -47,7 +47,7 @@ public function testIssueNamespaces() $annots = $parser->parse($docblock); - $this->assertEquals(1, count($annots)); + $this->assertCount(1, $annots); $this->assertInstanceOf("Doctrine\Tests\Common\Annotations\Ticket\Doctrine\ORM\Entity", $annots[0]); } @@ -60,7 +60,7 @@ public function testIssueMultipleNamespaces() $annots = $parser->parse($docblock); - $this->assertEquals(1, count($annots)); + $this->assertCount(1, $annots); $this->assertInstanceOf("Doctrine\Tests\Common\Annotations\Ticket\Doctrine\ORM\Mapping\Entity", $annots[0]); } @@ -70,9 +70,9 @@ public function testIssueWithNamespacesOrImports() $parser = new DocParser(); $annots = $parser->parse($docblock); - $this->assertEquals(1, count($annots)); + $this->assertCount(1, $annots); $this->assertInstanceOf("Entity", $annots[0]); - $this->assertEquals(1, count($annots)); + $this->assertCount(1, $annots); } @@ -82,7 +82,7 @@ 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->assertCount(1, $annots); $this->assertInstanceOf("Doctrine\Tests\Common\Annotations\Ticket\Doctrine\ORM\Mapping\Entity", $annots[0]); } From a7619f0bdedf2a35d1eaa96d8dd3a68b353d9890 Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Fri, 30 Dec 2016 14:38:55 +0100 Subject: [PATCH 02/32] Replacing `assertEquals()` + `sizeof()` with `assertCount()` --- tests/Doctrine/Tests/Common/Annotations/DocParserTest.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/Doctrine/Tests/Common/Annotations/DocParserTest.php b/tests/Doctrine/Tests/Common/Annotations/DocParserTest.php index 0c6dbc2dd..e438e8f6a 100644 --- a/tests/Doctrine/Tests/Common/Annotations/DocParserTest.php +++ b/tests/Doctrine/Tests/Common/Annotations/DocParserTest.php @@ -526,7 +526,7 @@ public function testAnnotationWithVarType($attribute, $value) $result = $parser->parse($docblock, $context); - $this->assertTrue(sizeof($result) === 1); + $this->assertCount(1, $result); $this->assertInstanceOf('Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithVarType', $result[0]); $this->assertNotNull($result[0]->$attribute); } @@ -580,7 +580,7 @@ public function testAnnotationWithAttributes($attribute, $value) $result = $parser->parse($docblock, $context); - $this->assertTrue(sizeof($result) === 1); + $this->assertCount(1, $result); $this->assertInstanceOf('Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithAttributes', $result[0]); $getter = "get".ucfirst($attribute); $this->assertNotNull($result[0]->$getter()); @@ -633,7 +633,7 @@ 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->assertCount(1, $result); $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()); @@ -667,7 +667,7 @@ public function testAnnotationWithRequiredAttributesWithoutContructor() $docblock = '@Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithRequiredAttributesWithoutContructor("Some Value", annot = @Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAnnotation)'; $result = $parser->parse($docblock); - $this->assertTrue(sizeof($result) === 1); + $this->assertCount(1, $result); $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); From 38f40df41f79f0204ed792f0943416d727e2532d Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Fri, 30 Dec 2016 14:40:54 +0100 Subject: [PATCH 03/32] Using `::class` where applicable --- .../Common/Annotations/AbstractReaderTest.php | 105 +++++++++--------- 1 file changed, 52 insertions(+), 53 deletions(-) diff --git a/tests/Doctrine/Tests/Common/Annotations/AbstractReaderTest.php b/tests/Doctrine/Tests/Common/Annotations/AbstractReaderTest.php index b87806bea..17d2a08ec 100644 --- a/tests/Doctrine/Tests/Common/Annotations/AbstractReaderTest.php +++ b/tests/Doctrine/Tests/Common/Annotations/AbstractReaderTest.php @@ -13,8 +13,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() @@ -23,7 +22,7 @@ public function testAnnotations() $reader = $this->getReader(); $this->assertCount(1, $reader->getClassAnnotations($class)); - $this->assertInstanceOf($annotName = 'Doctrine\Tests\Common\Annotations\DummyAnnotation', $annot = $reader->getClassAnnotation($class, $annotName)); + $this->assertInstanceOf($annotName = DummyAnnotation::class, $annot = $reader->getClassAnnotation($class, $annotName)); $this->assertEquals("hello", $annot->dummyValue); $field1Prop = $class->getProperty('field1'); @@ -41,7 +40,7 @@ public function testAnnotations() $field2Prop = $class->getProperty('field2'); $propAnnots = $reader->getPropertyAnnotations($field2Prop); $this->assertCount(1, $propAnnots); - $this->assertInstanceOf($annotName = 'Doctrine\Tests\Common\Annotations\DummyJoinTable', $joinTableAnnot = $reader->getPropertyAnnotation($field2Prop, $annotName)); + $this->assertInstanceOf($annotName = DummyJoinTable::class, $joinTableAnnot = $reader->getPropertyAnnotation($field2Prop, $annotName)); $this->assertCount(1, $joinTableAnnot->joinColumns); $this->assertCount(1, $joinTableAnnot->inverseJoinColumns); $this->assertInstanceOf(DummyJoinColumn::class, $joinTableAnnot->joinColumns[0]); @@ -51,24 +50,24 @@ public function testAnnotations() $this->assertEquals('col3', $joinTableAnnot->inverseJoinColumns[0]->name); $this->assertEquals('col4', $joinTableAnnot->inverseJoinColumns[0]->referencedColumnName); - $dummyAnnot = $reader->getMethodAnnotation($class->getMethod('getField1'), 'Doctrine\Tests\Common\Annotations\DummyAnnotation'); + $dummyAnnot = $reader->getMethodAnnotation($class->getMethod('getField1'), DummyAnnotation::class); $this->assertEquals('', $dummyAnnot->dummyValue); $this->assertEquals(array(1, 2, 'three'), $dummyAnnot->value); - $dummyAnnot = $reader->getMethodAnnotation($class->getMethod('getField3'), 'Doctrine\Tests\Common\Annotations\DummyAnnotation'); + $dummyAnnot = $reader->getMethodAnnotation($class->getMethod('getField3'), DummyAnnotation::class); $this->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'); + $dummyAnnot = $reader->getPropertyAnnotation($class->getProperty('field1'), DummyAnnotation::class); $this->assertEquals('fieldHello', $dummyAnnot->dummyValue); - $classAnnot = $reader->getClassAnnotation($class, 'Doctrine\Tests\Common\Annotations\DummyAnnotation'); + $classAnnot = $reader->getClassAnnotation($class, DummyAnnotation::class); $this->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->assertCount(1, $reader->getClassAnnotations($class)); $this->assertCount(1, $reader->getPropertyAnnotations($class->getProperty('foo'))); @@ -79,31 +78,31 @@ public function testAnnotationsWithValidTargets() public function testAnnotationsWithVarType() { $reader = $this->getReader(); - $class = new ReflectionClass('Doctrine\Tests\Common\Annotations\Fixtures\ClassWithAnnotationWithVarType'); + $class = new ReflectionClass(Fixtures\ClassWithAnnotationWithVarType::class); $this->assertCount(1, $fooAnnot = $reader->getPropertyAnnotations($class->getProperty('foo'))); $this->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); + $this->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->assertCount(1, $fooAnnot = $reader->getPropertyAnnotations($class->getProperty('foo'))); $this->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]); + $this->assertInstanceOf(Fixtures\AnnotationTargetPropertyMethod::class, $fooAnnot[0]); + $this->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); } @@ -115,13 +114,13 @@ 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')); + $annots = $reader->getClassAnnotations(new \ReflectionClass(Fixtures\ClassWithRequire::class)); $this->assertCount(1, $annots); } @@ -132,7 +131,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 +141,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 +151,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 +161,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 +171,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 +181,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,7 +191,7 @@ 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')); } @@ -204,7 +203,7 @@ public function testClassWithPropertyInvalidVarTypeError() 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 +215,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 +225,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 +235,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,7 +244,7 @@ public function testPropertySyntaxErrorContext() public function testMultipleAnnotationsOnSameLine() { $reader = $this->getReader(); - $annots = $reader->getPropertyAnnotations(new \ReflectionProperty('Doctrine\Tests\Common\Annotations\DummyClass2', 'id')); + $annots = $reader->getPropertyAnnotations(new \ReflectionProperty(DummyClass2::class, 'id')); $this->assertCount(3, $annots); } @@ -253,7 +252,7 @@ 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->assertNotNull($annot = $reader->getPropertyAnnotation(new \ReflectionProperty(DummyClassNonAnnotationProblem::class, 'foo'), $name = DummyAnnotation::class)); $this->assertInstanceOf($name, $annot); } @@ -261,17 +260,17 @@ 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')); + $this->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->assertCount(1, $annotations); - $this->assertNotNull($reader->getPropertyAnnotation($property, 'Doctrine\Tests\Common\Annotations\DummyAnnotation')); + $this->assertNotNull($reader->getPropertyAnnotation($property, DummyAnnotation::class)); } public function testImportWithInheritance() @@ -283,11 +282,11 @@ public function testImportWithInheritance() $childAnnotations = $reader->getPropertyAnnotations($ref->getProperty('child')); $this->assertCount(1, $childAnnotations); - $this->assertInstanceOf('Doctrine\Tests\Common\Annotations\Foo\Name', reset($childAnnotations)); + $this->assertInstanceOf(Foo\Name::class, reset($childAnnotations)); $parentAnnotations = $reader->getPropertyAnnotations($ref->getProperty('parent')); $this->assertCount(1, $parentAnnotations); - $this->assertInstanceOf('Doctrine\Tests\Common\Annotations\Bar\Name', reset($parentAnnotations)); + $this->assertInstanceOf(Bar\Name::class, reset($parentAnnotations)); } /** @@ -297,7 +296,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 +306,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->assertCount(1, $annotations); - $this->assertInstanceOf('\TopLevelAnnotation', reset($annotations)); + $this->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); + $this->assertInstanceOf(Name::class, $annotation); } private static $testResetsPhpParserAfterUseRun = false; @@ -342,7 +341,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'); + $this->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 +349,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 @@ -381,14 +380,14 @@ 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->assertCount(2, $annots); @@ -401,9 +400,9 @@ 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->assertTrue(class_exists(Fixtures\Annotation\Version::class)); $this->assertEmpty($reader->getClassAnnotations($class)); $this->assertEmpty($reader->getMethodAnnotations($class->getMethod('bar'))); $this->assertEmpty($reader->getPropertyAnnotations($class->getProperty('foo'))); @@ -412,13 +411,13 @@ public function testInvalidAnnotationButIgnored() 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'))); - $this->assertInstanceOf('Doctrine\Tests\Common\Annotations\Fixtures\AnnotationEnum', $bar[0]); - $this->assertInstanceOf('Doctrine\Tests\Common\Annotations\Fixtures\AnnotationEnum', $foo[0]); + $this->assertInstanceOf(Fixtures\AnnotationEnum::class, $bar[0]); + $this->assertInstanceOf(Fixtures\AnnotationEnum::class, $foo[0]); try { $reader->getPropertyAnnotations($class->getProperty('invalidProperty')); @@ -441,7 +440,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); } From 19a8aa0a68d7b17b6ba87f50fbb78108a893cbfe Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Fri, 30 Dec 2016 14:42:28 +0100 Subject: [PATCH 04/32] Declaring access modifiers --- tests/Doctrine/Tests/Common/Annotations/DocParserTest.php | 2 +- .../Tests/Common/Annotations/Fixtures/TestInterface.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/Doctrine/Tests/Common/Annotations/DocParserTest.php b/tests/Doctrine/Tests/Common/Annotations/DocParserTest.php index e438e8f6a..51e7ec2c4 100644 --- a/tests/Doctrine/Tests/Common/Annotations/DocParserTest.php +++ b/tests/Doctrine/Tests/Common/Annotations/DocParserTest.php @@ -1415,7 +1415,7 @@ class SomeAnnotationClassNameWithoutConstructor /** @Annotation */ class SomeAnnotationWithConstructorWithoutParams { - function __construct() + public function __construct() { $this->data = "Some data"; } diff --git a/tests/Doctrine/Tests/Common/Annotations/Fixtures/TestInterface.php b/tests/Doctrine/Tests/Common/Annotations/Fixtures/TestInterface.php index 58c5e6af5..08c3e10ec 100644 --- a/tests/Doctrine/Tests/Common/Annotations/Fixtures/TestInterface.php +++ b/tests/Doctrine/Tests/Common/Annotations/Fixtures/TestInterface.php @@ -9,5 +9,5 @@ interface TestInterface /** * @Secure */ - function foo(); + public function foo(); } \ No newline at end of file From 4355e9994f979f1e5a6a64893ef987be80562164 Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Fri, 30 Dec 2016 14:43:54 +0100 Subject: [PATCH 05/32] Using single quotes where applicable, since we don't rely on interpolation --- .../Common/Annotations/AbstractReaderTest.php | 6 +-- .../Annotations/Annotation/TargetTest.php | 6 +-- .../Tests/Common/Annotations/DocLexerTest.php | 2 +- .../Common/Annotations/DocParserTest.php | 50 +++++++++---------- .../Annotations/FileCacheReaderTest.php | 4 +- .../Common/Annotations/Ticket/DCOM58Test.php | 12 ++--- tests/Doctrine/Tests/TestInit.php | 2 +- 7 files changed, 41 insertions(+), 41 deletions(-) diff --git a/tests/Doctrine/Tests/Common/Annotations/AbstractReaderTest.php b/tests/Doctrine/Tests/Common/Annotations/AbstractReaderTest.php index 17d2a08ec..a101f8998 100644 --- a/tests/Doctrine/Tests/Common/Annotations/AbstractReaderTest.php +++ b/tests/Doctrine/Tests/Common/Annotations/AbstractReaderTest.php @@ -23,19 +23,19 @@ public function testAnnotations() $this->assertCount(1, $reader->getClassAnnotations($class)); $this->assertInstanceOf($annotName = DummyAnnotation::class, $annot = $reader->getClassAnnotation($class, $annotName)); - $this->assertEquals("hello", $annot->dummyValue); + $this->assertEquals('hello', $annot->dummyValue); $field1Prop = $class->getProperty('field1'); $propAnnots = $reader->getPropertyAnnotations($field1Prop); $this->assertCount(1, $propAnnots); $this->assertInstanceOf($annotName, $annot = $reader->getPropertyAnnotation($field1Prop, $annotName)); - $this->assertEquals("fieldHello", $annot->dummyValue); + $this->assertEquals('fieldHello', $annot->dummyValue); $getField1Method = $class->getMethod('getField1'); $methodAnnots = $reader->getMethodAnnotations($getField1Method); $this->assertCount(1, $methodAnnots); $this->assertInstanceOf($annotName, $annot = $reader->getMethodAnnotation($getField1Method, $annotName)); - $this->assertEquals(array(1, 2, "three"), $annot->value); + $this->assertEquals(array(1, 2, 'three'), $annot->value); $field2Prop = $class->getProperty('field2'); $propAnnots = $reader->getPropertyAnnotations($field2Prop); diff --git a/tests/Doctrine/Tests/Common/Annotations/Annotation/TargetTest.php b/tests/Doctrine/Tests/Common/Annotations/Annotation/TargetTest.php index 7627f7636..1402e21bb 100644 --- a/tests/Doctrine/Tests/Common/Annotations/Annotation/TargetTest.php +++ b/tests/Doctrine/Tests/Common/Annotations/Annotation/TargetTest.php @@ -33,14 +33,14 @@ class TargetTest extends \PHPUnit_Framework_TestCase */ public function testValidMixedTargets() { - $target = new Target(array("value" => array("ALL"))); + $target = new Target(array('value' => array('ALL'))); $this->assertEquals(Target::TARGET_ALL, $target->targets); - $target = new Target(array("value" => array("METHOD", "METHOD"))); + $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("PROPERTY", "METHOD"))); + $target = new Target(array('value' => array('PROPERTY', 'METHOD'))); $this->assertEquals(Target::TARGET_METHOD | Target::TARGET_PROPERTY, $target->targets); } } diff --git a/tests/Doctrine/Tests/Common/Annotations/DocLexerTest.php b/tests/Doctrine/Tests/Common/Annotations/DocLexerTest.php index b9fe007f3..27c977146 100644 --- a/tests/Doctrine/Tests/Common/Annotations/DocLexerTest.php +++ b/tests/Doctrine/Tests/Common/Annotations/DocLexerTest.php @@ -10,7 +10,7 @@ public function testMarkerAnnotation() { $lexer = new DocLexer; - $lexer->setInput("@Name"); + $lexer->setInput('@Name'); $this->assertNull($lexer->token); $this->assertNull($lexer->lookahead); diff --git a/tests/Doctrine/Tests/Common/Annotations/DocParserTest.php b/tests/Doctrine/Tests/Common/Annotations/DocParserTest.php index 51e7ec2c4..d24eca29e 100644 --- a/tests/Doctrine/Tests/Common/Annotations/DocParserTest.php +++ b/tests/Doctrine/Tests/Common/Annotations/DocParserTest.php @@ -36,7 +36,7 @@ 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); @@ -93,7 +93,7 @@ public function testBasicAnnotations() $this->assertCount(1, $result); $annot = $result[0]; $this->assertInstanceOf(Name::class, $annot); - $this->assertEquals("bar", $annot->foo); + $this->assertEquals('bar', $annot->foo); $this->assertNull($annot->value); } @@ -140,7 +140,7 @@ public function testNamespacedAnnotations() $this->assertCount(1, $result); $annot = $result[0]; $this->assertInstanceOf(Name::class, $annot); - $this->assertEquals("bar", $annot->foo); + $this->assertEquals('bar', $annot->foo); } /** @@ -170,7 +170,7 @@ public function testTypicalMethodDocBlock() $this->assertTrue(isset($result[1])); $annot = $result[0]; $this->assertInstanceOf(Name::class, $annot); - $this->assertEquals("bar", $annot->foo); + $this->assertEquals('bar', $annot->foo); $marker = $result[1]; $this->assertTrue($marker instanceof Marker); } @@ -196,7 +196,7 @@ public function testAnnotationWithoutConstructor() $this->assertNull($annot->name); $this->assertNotNull($annot->data); - $this->assertEquals($annot->data, "Some data"); + $this->assertEquals($annot->data, 'Some data'); @@ -215,8 +215,8 @@ public function testAnnotationWithoutConstructor() $this->assertNotNull($annot); $this->assertTrue($annot instanceof SomeAnnotationClassNameWithoutConstructor); - $this->assertEquals($annot->name, "Some Name"); - $this->assertEquals($annot->data, "Some data"); + $this->assertEquals($annot->name, 'Some Name'); + $this->assertEquals($annot->data, 'Some data'); @@ -231,7 +231,7 @@ public function testAnnotationWithoutConstructor() $this->assertCount(1, $result); $annot = $result[0]; - $this->assertEquals($annot->data, "Some data"); + $this->assertEquals($annot->data, 'Some data'); $this->assertNull($annot->name); @@ -245,7 +245,7 @@ public function testAnnotationWithoutConstructor() $this->assertCount(1, $result); $annot = $result[0]; - $this->assertEquals($annot->name, "Some name"); + $this->assertEquals($annot->name, 'Some name'); $this->assertNull($annot->data); $docblock = <<assertCount(1, $result); $annot = $result[0]; - $this->assertEquals($annot->data, "Some data"); + $this->assertEquals($annot->data, 'Some data'); $this->assertNull($annot->name); @@ -273,8 +273,8 @@ public function testAnnotationWithoutConstructor() $this->assertCount(1, $result); $annot = $result[0]; - $this->assertEquals($annot->name, "Some name"); - $this->assertEquals($annot->data, "Some data"); + $this->assertEquals($annot->name, 'Some name'); + $this->assertEquals($annot->data, 'Some data'); $docblock = <<assertCount(1, $result); $annot = $result[0]; - $this->assertEquals($annot->name, "Some name"); - $this->assertEquals($annot->data, "Some data"); + $this->assertEquals($annot->name, 'Some name'); + $this->assertEquals($annot->data, 'Some data'); $docblock = <<assertCount(1, $result); $this->assertInstanceOf('Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithAttributes', $result[0]); - $getter = "get".ucfirst($attribute); + $getter = 'get' .ucfirst($attribute); $this->assertNotNull($result[0]->$getter()); } @@ -635,7 +635,7 @@ public function testAnnotationWithRequiredAttributes() $this->assertCount(1, $result); $this->assertInstanceOf('Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithRequiredAttributes', $result[0]); - $this->assertEquals("Some Value",$result[0]->getValue()); + $this->assertEquals('Some Value',$result[0]->getValue()); $this->assertInstanceOf('Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAnnotation', $result[0]->getAnnot()); @@ -669,7 +669,7 @@ public function testAnnotationWithRequiredAttributesWithoutContructor() $this->assertCount(1, $result); $this->assertInstanceOf('Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithRequiredAttributesWithoutContructor', $result[0]); - $this->assertEquals("Some Value", $result[0]->value); + $this->assertEquals('Some Value', $result[0]->value); $this->assertInstanceOf('Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAnnotation', $result[0]->annot); @@ -988,7 +988,7 @@ public function testAnnotationWithoutClassIsIgnoredWithoutWarning() { $parser = new DocParser(); $parser->setIgnoreNotImportedAnnotations(true); - $result = $parser->parse("@param"); + $result = $parser->parse('@param'); $this->assertEmpty($result); } @@ -1185,7 +1185,7 @@ 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); } @@ -1197,7 +1197,7 @@ 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); } @@ -1209,7 +1209,7 @@ 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); } @@ -1221,11 +1221,11 @@ 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); - $result = $parser->parse("@Marker(-1234.345)"); + $result = $parser->parse('@Marker(-1234.345)'); $annot = $result[0]; $this->assertInternalType('float', $annot->value); } @@ -1375,7 +1375,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'); } @@ -1417,7 +1417,7 @@ class SomeAnnotationWithConstructorWithoutParams { public function __construct() { - $this->data = "Some data"; + $this->data = 'Some data'; } public $data; public $name; diff --git a/tests/Doctrine/Tests/Common/Annotations/FileCacheReaderTest.php b/tests/Doctrine/Tests/Common/Annotations/FileCacheReaderTest.php index 325de88fd..cbdbaa8cf 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(); @mkdir($this->cacheDir); return new FileCacheReader(new AnnotationReader(), $this->cacheDir); } @@ -29,7 +29,7 @@ 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(); $this->assertFalse(is_dir($this->cacheDir)); diff --git a/tests/Doctrine/Tests/Common/Annotations/Ticket/DCOM58Test.php b/tests/Doctrine/Tests/Common/Annotations/Ticket/DCOM58Test.php index 10c162947..47cbe77ba 100644 --- a/tests/Doctrine/Tests/Common/Annotations/Ticket/DCOM58Test.php +++ b/tests/Doctrine/Tests/Common/Annotations/Ticket/DCOM58Test.php @@ -27,10 +27,10 @@ public function testIssue() 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); @@ -41,7 +41,7 @@ public function testIssueGlobalNamespace() public function testIssueNamespaces() { - $docblock = "@Entity"; + $docblock = '@Entity'; $parser = new DocParser(); $parser->addNamespace("Doctrine\Tests\Common\Annotations\Ticket\Doctrine\ORM"); @@ -53,7 +53,7 @@ public function testIssueNamespaces() 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"); @@ -66,12 +66,12 @@ public function testIssueMultipleNamespaces() public function testIssueWithNamespacesOrImports() { - $docblock = "@Entity"; + $docblock = '@Entity'; $parser = new DocParser(); $annots = $parser->parse($docblock); $this->assertCount(1, $annots); - $this->assertInstanceOf("Entity", $annots[0]); + $this->assertInstanceOf('Entity', $annots[0]); $this->assertCount(1, $annots); } 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__ . '/../../' From 6e56e66f91514647976ae8147e2be7c647b2fef5 Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Fri, 30 Dec 2016 14:47:44 +0100 Subject: [PATCH 06/32] Importing used classes --- .../Common/Annotations/AbstractReaderTest.php | 5 +-- .../Common/Annotations/DocParserTest.php | 33 +++++++++++-------- 2 files changed, 22 insertions(+), 16 deletions(-) diff --git a/tests/Doctrine/Tests/Common/Annotations/AbstractReaderTest.php b/tests/Doctrine/Tests/Common/Annotations/AbstractReaderTest.php index a101f8998..11be5e861 100644 --- a/tests/Doctrine/Tests/Common/Annotations/AbstractReaderTest.php +++ b/tests/Doctrine/Tests/Common/Annotations/AbstractReaderTest.php @@ -4,6 +4,7 @@ use Doctrine\Common\Annotations\Annotation\IgnoreAnnotation; use Doctrine\Common\Annotations\Annotation; +use Doctrine\Common\Annotations\AnnotationException; use Doctrine\Common\Annotations\Reader; use ReflectionClass, Doctrine\Common\Annotations\AnnotationReader; @@ -422,14 +423,14 @@ public function testAnnotationEnumeratorException() try { $reader->getPropertyAnnotations($class->getProperty('invalidProperty')); $this->fail(); - } catch (\Doctrine\Common\Annotations\AnnotationException $exc) { + } catch (AnnotationException $exc) { $this->assertEquals('[Enum Error] Attribute "value" of @Doctrine\Tests\Common\Annotations\Fixtures\AnnotationEnum declared on property Doctrine\Tests\Common\Annotations\Fixtures\ClassWithAnnotationEnum::$invalidProperty accept only [ONE, TWO, THREE], but got FOUR.', $exc->getMessage()); } try { $reader->getMethodAnnotations($class->getMethod('invalidMethod')); $this->fail(); - } catch (\Doctrine\Common\Annotations\AnnotationException $exc) { + } catch (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()); } } diff --git a/tests/Doctrine/Tests/Common/Annotations/DocParserTest.php b/tests/Doctrine/Tests/Common/Annotations/DocParserTest.php index d24eca29e..14e34f92e 100644 --- a/tests/Doctrine/Tests/Common/Annotations/DocParserTest.php +++ b/tests/Doctrine/Tests/Common/Annotations/DocParserTest.php @@ -2,9 +2,12 @@ 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; @@ -344,7 +347,7 @@ public function testAnnotationTarget() $parser->parse($docComment, $context); $this->fail(); - } catch (\Doctrine\Common\Annotations\AnnotationException $exc) { + } catch (AnnotationException $exc) { $this->assertNotNull($exc->getMessage()); } @@ -360,7 +363,7 @@ public function testAnnotationTarget() $parser->parse($docComment, $context); $this->fail(); - } catch (\Doctrine\Common\Annotations\AnnotationException $exc) { + } catch (AnnotationException $exc) { $this->assertNotNull($exc->getMessage()); } @@ -375,7 +378,7 @@ public function testAnnotationTarget() $parser->parse($docComment, $context); $this->fail(); - } catch (\Doctrine\Common\Annotations\AnnotationException $exc) { + } catch (AnnotationException $exc) { $this->assertNotNull($exc->getMessage()); } @@ -544,7 +547,7 @@ public function testAnnotationWithVarTypeError($attribute,$type,$value,$given) try { $parser->parse($docblock, $context); $this->fail(); - } catch (\Doctrine\Common\Annotations\AnnotationException $exc) { + } catch (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()); } } @@ -563,7 +566,7 @@ public function testAnnotationWithVarTypeArrayError($attribute,$type,$value,$giv try { $parser->parse($docblock, $context); $this->fail(); - } catch (\Doctrine\Common\Annotations\AnnotationException $exc) { + } catch (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()); } } @@ -599,7 +602,7 @@ public function testAnnotationWithAttributesError($attribute,$type,$value,$given try { $parser->parse($docblock, $context); $this->fail(); - } catch (\Doctrine\Common\Annotations\AnnotationException $exc) { + } catch (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()); } } @@ -618,7 +621,7 @@ public function testAnnotationWithAttributesWithVarTypeArrayError($attribute,$ty try { $parser->parse($docblock, $context); $this->fail(); - } catch (\Doctrine\Common\Annotations\AnnotationException $exc) { + } catch (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()); } } @@ -643,7 +646,7 @@ public function testAnnotationWithRequiredAttributes() try { $result = $parser->parse($docblock,$context); $this->fail(); - } catch (\Doctrine\Common\Annotations\AnnotationException $exc) { + } catch (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()); } @@ -651,7 +654,7 @@ public function testAnnotationWithRequiredAttributes() try { $result = $parser->parse($docblock,$context); $this->fail(); - } catch (\Doctrine\Common\Annotations\AnnotationException $exc) { + } catch (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()); } @@ -677,7 +680,7 @@ public function testAnnotationWithRequiredAttributesWithoutContructor() try { $result = $parser->parse($docblock,$context); $this->fail(); - } catch (\Doctrine\Common\Annotations\AnnotationException $exc) { + } catch (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()); } @@ -685,7 +688,7 @@ public function testAnnotationWithRequiredAttributesWithoutContructor() try { $result = $parser->parse($docblock,$context); $this->fail(); - } catch (\Doctrine\Common\Annotations\AnnotationException $exc) { + } catch (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()); } @@ -1439,12 +1442,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 +1458,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 { } From 029a9de189127a1a15c6c5a83f28556394b302bf Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Fri, 30 Dec 2016 14:48:13 +0100 Subject: [PATCH 07/32] Removing unnecessary parentheses --- .../Tests/Common/Annotations/Fixtures/ClassWithRequire.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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; From 60a4073037177d3e497513fdcfa4982b58784be9 Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Fri, 30 Dec 2016 14:52:10 +0100 Subject: [PATCH 08/32] Using `::class` where applicable --- .../Annotations/AnnotationReaderTest.php | 18 ++--- .../Annotations/AnnotationRegistryTest.php | 2 +- .../Common/Annotations/CachedReaderTest.php | 13 ++-- .../Common/Annotations/DocParserTest.php | 76 +++++++++---------- .../Common/Annotations/PerformanceTest.php | 10 +-- .../Common/Annotations/PhpParserTest.php | 10 +-- .../SimpleAnnotationReaderTest.php | 6 +- .../Common/Annotations/Ticket/DCOM58Test.php | 10 +-- 8 files changed, 73 insertions(+), 72 deletions(-) diff --git a/tests/Doctrine/Tests/Common/Annotations/AnnotationReaderTest.php b/tests/Doctrine/Tests/Common/Annotations/AnnotationReaderTest.php index 00176758c..52769dcb5 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]); + $this->assertInstanceOf(Bar\Autoload::class, $annotations[0]); $annotations = $reader->getMethodAnnotations($ref->getMethod('traitMethod')); - $this->assertInstanceOf('Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Autoload', $annotations[0]); + $this->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]); + $this->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]); + $this->assertInstanceOf(Bar\Autoload::class, $annotations[0]); $annotations = $reader->getPropertyAnnotations($ref->getProperty('traitProperty')); - $this->assertInstanceOf('Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Autoload', $annotations[0]); + $this->assertInstanceOf(Fixtures\Annotation\Autoload::class, $annotations[0]); } public function testOmitNotRegisteredAnnotation() @@ -58,7 +58,7 @@ 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); diff --git a/tests/Doctrine/Tests/Common/Annotations/AnnotationRegistryTest.php b/tests/Doctrine/Tests/Common/Annotations/AnnotationRegistryTest.php index 7ae5ed079..fd0c02687 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 diff --git a/tests/Doctrine/Tests/Common/Annotations/CachedReaderTest.php b/tests/Doctrine/Tests/Common/Annotations/CachedReaderTest.php index fa723bcbf..4df01659f 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,7 @@ protected function doTestCacheStale($className, $lastCacheModification) { $cacheKey = $className; - $cache = $this->createMock('Doctrine\Common\Cache\Cache'); + $cache = $this->createMock(Cache::class); $cache ->expects($this->at(0)) ->method('fetch') diff --git a/tests/Doctrine/Tests/Common/Annotations/DocParserTest.php b/tests/Doctrine/Tests/Common/Annotations/DocParserTest.php index 14e34f92e..9417c4e8f 100644 --- a/tests/Doctrine/Tests/Common/Annotations/DocParserTest.php +++ b/tests/Doctrine/Tests/Common/Annotations/DocParserTest.php @@ -311,7 +311,7 @@ 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(); @@ -339,7 +339,7 @@ public function testAnnotationTarget() try { - $class = new \ReflectionClass('Doctrine\Tests\Common\Annotations\Fixtures\ClassWithInvalidAnnotationTargetAtClass'); + $class = new \ReflectionClass(Fixtures\ClassWithInvalidAnnotationTargetAtClass::class); $context = 'class ' . $class->getName(); $docComment = $class->getDocComment(); @@ -354,7 +354,7 @@ public function testAnnotationTarget() 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() . '()'; @@ -369,7 +369,7 @@ public function testAnnotationTarget() 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(); @@ -480,13 +480,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'), ); } @@ -508,12 +508,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'), ); } @@ -530,7 +530,7 @@ public function testAnnotationWithVarType($attribute, $value) $result = $parser->parse($docblock, $context); $this->assertCount(1, $result); - $this->assertInstanceOf('Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithVarType', $result[0]); + $this->assertInstanceOf(Fixtures\AnnotationWithVarType::class, $result[0]); $this->assertNotNull($result[0]->$attribute); } @@ -584,7 +584,7 @@ public function testAnnotationWithAttributes($attribute, $value) $result = $parser->parse($docblock, $context); $this->assertCount(1, $result); - $this->assertInstanceOf('Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithAttributes', $result[0]); + $this->assertInstanceOf(Fixtures\AnnotationWithAttributes::class, $result[0]); $getter = 'get' .ucfirst($attribute); $this->assertNotNull($result[0]->$getter()); } @@ -637,9 +637,9 @@ public function testAnnotationWithRequiredAttributes() $result = $parser->parse($docblock); $this->assertCount(1, $result); - $this->assertInstanceOf('Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithRequiredAttributes', $result[0]); + $this->assertInstanceOf(Fixtures\AnnotationWithRequiredAttributes::class, $result[0]); $this->assertEquals('Some Value',$result[0]->getValue()); - $this->assertInstanceOf('Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAnnotation', $result[0]->getAnnot()); + $this->assertInstanceOf(Fixtures\AnnotationTargetAnnotation::class, $result[0]->getAnnot()); $docblock = '@Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithRequiredAttributes("Some Value")'; @@ -671,9 +671,9 @@ public function testAnnotationWithRequiredAttributesWithoutContructor() $result = $parser->parse($docblock); $this->assertCount(1, $result); - $this->assertInstanceOf('Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithRequiredAttributesWithoutContructor', $result[0]); + $this->assertInstanceOf(Fixtures\AnnotationWithRequiredAttributesWithoutContructor::class, $result[0]); $this->assertEquals('Some Value', $result[0]->value); - $this->assertInstanceOf('Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAnnotation', $result[0]->annot); + $this->assertInstanceOf(Fixtures\AnnotationTargetAnnotation::class, $result[0]->annot); $docblock = '@Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithRequiredAttributesWithoutContructor("Some Value")'; @@ -828,19 +828,19 @@ public function getConstantsProvider() ); $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; } @@ -852,13 +852,13 @@ 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, + 'intefacewithconstants' => IntefaceWithConstants::class, + 'annotationwithconstants' => AnnotationWithConstants::class )); $result = $parser->parse($docblock); - $this->assertInstanceOf('\Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithConstants', $annotation = $result[0]); + $this->assertInstanceOf(AnnotationWithConstants::class, $annotation = $result[0]); $this->assertEquals($expected, $annotation->value); } @@ -968,7 +968,7 @@ public function testRegressionDDC575() $result = $parser->parse($docblock); - $this->assertInstanceOf("Doctrine\Tests\Common\Annotations\Name", $result[0]); + $this->assertInstanceOf(Name::class, $result[0]); $docblock = <<parse($docblock); - $this->assertInstanceOf("Doctrine\Tests\Common\Annotations\Name", $result[0]); + $this->assertInstanceOf(Name::class, $result[0]); } /** @@ -1046,7 +1046,7 @@ 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->assertEmpty($result); @@ -1104,12 +1104,12 @@ public function testAutoloadAnnotation() 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->assertCount(1, $annotations); - $this->assertInstanceOf('Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Autoload', $annotations[0]); + $this->assertInstanceOf(Fixtures\Annotation\Autoload::class, $annotations[0]); } public function createTestParser() @@ -1117,7 +1117,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', )); @@ -1305,7 +1305,7 @@ public function testTabPrefixIsAllowed() $parser = $this->createTestParser(); $result = $parser->parse($docblock); $this->assertCount(1, $result); - $this->assertInstanceOf('Doctrine\Tests\Common\Annotations\Name', $result[0]); + $this->assertInstanceOf(Name::class, $result[0]); } public function testDefaultAnnotationValueIsNotOverwritten() diff --git a/tests/Doctrine/Tests/Common/Annotations/PerformanceTest.php b/tests/Doctrine/Tests/Common/Annotations/PerformanceTest.php index c7778b2ae..3490f4b58 100644 --- a/tests/Doctrine/Tests/Common/Annotations/PerformanceTest.php +++ b/tests/Doctrine/Tests/Common/Annotations/PerformanceTest.php @@ -81,8 +81,8 @@ public function testDocParsePerformance() $imports = array( 'ignorephpdoc' => '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,7 +167,7 @@ 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) diff --git a/tests/Doctrine/Tests/Common/Annotations/PhpParserTest.php b/tests/Doctrine/Tests/Common/Annotations/PhpParserTest.php index 678954421..070ef5670 100644 --- a/tests/Doctrine/Tests/Common/Annotations/PhpParserTest.php +++ b/tests/Doctrine/Tests/Common/Annotations/PhpParserTest.php @@ -51,12 +51,12 @@ public function testParseClassWithGroupUseStatement() public function testParseClassWhenNotUserDefined() { $parser = new PhpParser(); - $this->assertEquals(array(), $parser->parseClass(new \ReflectionClass('\stdClass'))); + $this->assertEquals(array(), $parser->parseClass(new \ReflectionClass(\stdClass::class))); } public function testClassFileDoesNotExist() { - $class = $this->getMockBuilder('\ReflectionClass') + $class = $this->getMockBuilder(ReflectionClass::class) ->disableOriginalConstructor() ->getMock(); $class->expects($this->once()) @@ -70,7 +70,7 @@ public function testClassFileDoesNotExist() public function testParseClassWhenClassIsNotNamespaced() { $parser = new PhpParser(); - $class = new ReflectionClass('\AnnotationsTestsFixturesNonNamespacedClass'); + $class = new ReflectionClass(\AnnotationsTestsFixturesNonNamespacedClass::class); $this->assertEquals(array( 'route' => __NAMESPACE__ . '\Fixtures\Annotation\Route', @@ -156,7 +156,7 @@ public function testDifferentNamespacesPerFileWithClassAsLast() public function testGlobalNamespacesPerFileWithClassAsFirst() { $parser = new PhpParser(); - $class = new \ReflectionClass('\GlobalNamespacesPerFileWithClassAsFirst'); + $class = new \ReflectionClass(\GlobalNamespacesPerFileWithClassAsFirst::class); $this->assertEquals(array( 'secure' => __NAMESPACE__ . '\Fixtures\Annotation\Secure', @@ -167,7 +167,7 @@ public function testGlobalNamespacesPerFileWithClassAsFirst() public function testGlobalNamespacesPerFileWithClassAsLast() { $parser = new PhpParser(); - $class = new ReflectionClass('\GlobalNamespacesPerFileWithClassAsLast'); + $class = new ReflectionClass(\GlobalNamespacesPerFileWithClassAsLast::class); $this->assertEquals(array( 'route' => __NAMESPACE__ . '\Fixtures\Annotation\Route', diff --git a/tests/Doctrine/Tests/Common/Annotations/SimpleAnnotationReaderTest.php b/tests/Doctrine/Tests/Common/Annotations/SimpleAnnotationReaderTest.php index 30ac52e23..c266c763f 100644 --- a/tests/Doctrine/Tests/Common/Annotations/SimpleAnnotationReaderTest.php +++ b/tests/Doctrine/Tests/Common/Annotations/SimpleAnnotationReaderTest.php @@ -75,7 +75,7 @@ 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); @@ -95,9 +95,9 @@ 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->assertTrue(class_exists(Fixtures\Annotation\Version::class)); $this->assertCount(1, $reader->getClassAnnotations($class)); $this->assertCount(1, $reader->getMethodAnnotations($class->getMethod('bar'))); $this->assertCount(1, $reader->getPropertyAnnotations($class->getProperty('foo'))); diff --git a/tests/Doctrine/Tests/Common/Annotations/Ticket/DCOM58Test.php b/tests/Doctrine/Tests/Common/Annotations/Ticket/DCOM58Test.php index 47cbe77ba..ab05c3476 100644 --- a/tests/Doctrine/Tests/Common/Annotations/Ticket/DCOM58Test.php +++ b/tests/Doctrine/Tests/Common/Annotations/Ticket/DCOM58Test.php @@ -36,7 +36,7 @@ public function testIssueGlobalNamespace() $annots = $parser->parse($docblock); $this->assertCount(1, $annots); - $this->assertInstanceOf("Doctrine\Tests\Common\Annotations\Ticket\Doctrine\ORM\Mapping\Entity", $annots[0]); + $this->assertInstanceOf(Doctrine\ORM\Mapping\Entity::class, $annots[0]); } public function testIssueNamespaces() @@ -48,7 +48,7 @@ public function testIssueNamespaces() $annots = $parser->parse($docblock); $this->assertCount(1, $annots); - $this->assertInstanceOf("Doctrine\Tests\Common\Annotations\Ticket\Doctrine\ORM\Entity", $annots[0]); + $this->assertInstanceOf(Doctrine\ORM\Entity::class, $annots[0]); } public function testIssueMultipleNamespaces() @@ -61,7 +61,7 @@ public function testIssueMultipleNamespaces() $annots = $parser->parse($docblock); $this->assertCount(1, $annots); - $this->assertInstanceOf("Doctrine\Tests\Common\Annotations\Ticket\Doctrine\ORM\Mapping\Entity", $annots[0]); + $this->assertInstanceOf(Doctrine\ORM\Mapping\Entity::class, $annots[0]); } public function testIssueWithNamespacesOrImports() @@ -71,7 +71,7 @@ public function testIssueWithNamespacesOrImports() $annots = $parser->parse($docblock); $this->assertCount(1, $annots); - $this->assertInstanceOf('Entity', $annots[0]); + $this->assertInstanceOf(\Entity::class, $annots[0]); $this->assertCount(1, $annots); } @@ -83,7 +83,7 @@ public function testIssueSimpleAnnotationReader() $annots = $reader->getClassAnnotations(new \ReflectionClass(__NAMESPACE__."\MappedClass")); $this->assertCount(1, $annots); - $this->assertInstanceOf("Doctrine\Tests\Common\Annotations\Ticket\Doctrine\ORM\Mapping\Entity", $annots[0]); + $this->assertInstanceOf(Doctrine\ORM\Mapping\Entity::class, $annots[0]); } } From d227309c14206ac1c164b0c1d55c688dfc904eab Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Fri, 30 Dec 2016 14:52:52 +0100 Subject: [PATCH 09/32] Using explicit type casts rather than cast functions --- .../Doctrine/Tests/Common/Annotations/Fixtures/Controller.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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; } From ae1b38d8cbd0430cca4fd5c78630fef3087fb80f Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Fri, 30 Dec 2016 14:55:02 +0100 Subject: [PATCH 10/32] Using `assertArrayNotHasKey` rather than manual `isset()` checking --- tests/Doctrine/Tests/Common/Annotations/Ticket/DCOM58Test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Doctrine/Tests/Common/Annotations/Ticket/DCOM58Test.php b/tests/Doctrine/Tests/Common/Annotations/Ticket/DCOM58Test.php index ab05c3476..5b51c29ee 100644 --- a/tests/Doctrine/Tests/Common/Annotations/Ticket/DCOM58Test.php +++ b/tests/Doctrine/Tests/Common/Annotations/Ticket/DCOM58Test.php @@ -22,7 +22,7 @@ public function testIssue() $classAnnotations[get_class($annot)] = $annot; } - $this->assertTrue(!isset($classAnnotations['']), 'Class "xxx" is not a valid entity or mapped super class.'); + $this->assertArrayNotHasKey('', $classAnnotations, 'Class "xxx" is not a valid entity or mapped super class.'); } public function testIssueGlobalNamespace() From cc34239206394dc1409c6e8a1c3ce43f7d8bda3d Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Fri, 30 Dec 2016 14:59:37 +0100 Subject: [PATCH 11/32] Using `assertInstanceOf` rather than manual `instanceof` checking --- .../Common/Annotations/DocParserTest.php | 41 +++++++++---------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/tests/Doctrine/Tests/Common/Annotations/DocParserTest.php b/tests/Doctrine/Tests/Common/Annotations/DocParserTest.php index 9417c4e8f..709870c2a 100644 --- a/tests/Doctrine/Tests/Common/Annotations/DocParserTest.php +++ b/tests/Doctrine/Tests/Common/Annotations/DocParserTest.php @@ -31,7 +31,7 @@ public function testNestedArraysWithNestedAnnotation() $nestedArray = $annot->foo[2]; $this->assertTrue(isset($nestedArray['key'])); - $this->assertTrue($nestedArray['key'] instanceof Name); + $this->assertInstanceOf(Name::class, $nestedArray['key']); } public function testBasicAnnotations() @@ -41,7 +41,7 @@ public function testBasicAnnotations() // Marker annotation $result = $parser->parse('@Name'); $annot = $result[0]; - $this->assertTrue($annot instanceof Name); + $this->assertInstanceOf(Name::class, $annot); $this->assertNull($annot->value); $this->assertNull($annot->foo); @@ -66,18 +66,18 @@ public function testBasicAnnotations() $result = $parser->parse('@Name(@Name, @Name)'); $annot = $result[0]; - $this->assertTrue($annot instanceof Name); + $this->assertInstanceOf(Name::class, $annot); $this->assertTrue(is_array($annot->value)); - $this->assertTrue($annot->value[0] instanceof Name); - $this->assertTrue($annot->value[1] instanceof Name); + $this->assertInstanceOf(Name::class, $annot->value[0]); + $this->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->assertInstanceOf(Name::class, $annot); $this->assertTrue(is_array($annot->value)); - $this->assertTrue($annot->value[0] instanceof Name); + $this->assertInstanceOf(Name::class, $annot->value[0]); $this->assertTrue(is_array($annot->value[1])); $this->assertEquals('value1', $annot->value[1]['key1']); $this->assertEquals('value2', $annot->value[1]['key2']); @@ -108,7 +108,7 @@ public function testDefaultValueAnnotations() $result = $parser->parse('@Name({"key1"="value1"})'); $annot = $result[0]; - $this->assertTrue($annot instanceof Name); + $this->assertInstanceOf(Name::class, $annot); $this->assertTrue(is_array($annot->value)); $this->assertEquals('value1', $annot->value['key1']); @@ -116,7 +116,7 @@ public function testDefaultValueAnnotations() $result = $parser->parse('@Name({"key1"="value1"}, foo="bar")'); $annot = $result[0]; - $this->assertTrue($annot instanceof Name); + $this->assertInstanceOf(Name::class, $annot); $this->assertTrue(is_array($annot->value)); $this->assertEquals('value1', $annot->value['key1']); $this->assertEquals('bar', $annot->foo); @@ -175,7 +175,7 @@ public function testTypicalMethodDocBlock() $this->assertInstanceOf(Name::class, $annot); $this->assertEquals('bar', $annot->foo); $marker = $result[1]; - $this->assertTrue($marker instanceof Marker); + $this->assertInstanceOf(Marker::class, $marker); } @@ -194,8 +194,7 @@ public function testAnnotationWithoutConstructor() $this->assertCount(1, $result); $annot = $result[0]; - $this->assertNotNull($annot); - $this->assertTrue($annot instanceof SomeAnnotationClassNameWithoutConstructor); + $this->assertInstanceOf(SomeAnnotationClassNameWithoutConstructor::class, $annot); $this->assertNull($annot->name); $this->assertNotNull($annot->data); @@ -216,7 +215,7 @@ public function testAnnotationWithoutConstructor() $annot = $result[0]; $this->assertNotNull($annot); - $this->assertTrue($annot instanceof SomeAnnotationClassNameWithoutConstructor); + $this->assertInstanceOf(SomeAnnotationClassNameWithoutConstructor::class, $annot); $this->assertEquals($annot->name, 'Some Name'); $this->assertEquals($annot->data, 'Some data'); @@ -301,7 +300,7 @@ public function testAnnotationWithoutConstructor() $result = $parser->parse($docblock); $this->assertCount(1, $result); - $this->assertTrue($result[0] instanceof SomeAnnotationClassNameWithoutConstructorAndProperties); + $this->assertInstanceOf(SomeAnnotationClassNameWithoutConstructorAndProperties::class, $result[0]); } public function testAnnotationTarget() @@ -1243,18 +1242,18 @@ public function testReservedKeywordsInAnnotations() $parser = $this->createTestParser(); $result = $parser->parse('@Doctrine\Tests\Common\Annotations\True'); - $this->assertTrue($result[0] instanceof True); + $this->assertInstanceOf(True::class, $result[0]); $result = $parser->parse('@Doctrine\Tests\Common\Annotations\False'); - $this->assertTrue($result[0] instanceof False); + $this->assertInstanceOf(False::class, $result[0]); $result = $parser->parse('@Doctrine\Tests\Common\Annotations\Null'); - $this->assertTrue($result[0] instanceof Null); + $this->assertInstanceOf(Null::class, $result[0]); $result = $parser->parse('@True'); - $this->assertTrue($result[0] instanceof True); + $this->assertInstanceOf(True::class, $result[0]); $result = $parser->parse('@False'); - $this->assertTrue($result[0] instanceof False); + $this->assertInstanceOf(False::class, $result[0]); $result = $parser->parse('@Null'); - $this->assertTrue($result[0] instanceof Null); + $this->assertInstanceOf(Null::class, $result[0]); } /** @@ -1366,7 +1365,7 @@ public function testSupportsEscapedQuotedValues() $this->assertCount(1, $result); - $this->assertTrue($result[0] instanceof Name); + $this->assertInstanceOf(Name::class, $result[0]); $this->assertEquals('"bar"', $result[0]->foo); } From 18ec721da1127b5abdb6627622016216758ac9ca Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Fri, 30 Dec 2016 15:00:50 +0100 Subject: [PATCH 12/32] Removing unsafe `uniqid()` usage --- .../Doctrine/Tests/Common/Annotations/FileCacheReaderTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/Doctrine/Tests/Common/Annotations/FileCacheReaderTest.php b/tests/Doctrine/Tests/Common/Annotations/FileCacheReaderTest.php index cbdbaa8cf..659851d56 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,7 +29,7 @@ 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)); From eda812551153dfceaa84d87c321951d7e66e938b Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Fri, 30 Dec 2016 15:01:16 +0100 Subject: [PATCH 13/32] Removing non-absolute path include --- tests/Doctrine/Tests/Common/Annotations/DocParserTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Doctrine/Tests/Common/Annotations/DocParserTest.php b/tests/Doctrine/Tests/Common/Annotations/DocParserTest.php index 709870c2a..06b5ad770 100644 --- a/tests/Doctrine/Tests/Common/Annotations/DocParserTest.php +++ b/tests/Doctrine/Tests/Common/Annotations/DocParserTest.php @@ -1237,7 +1237,7 @@ 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(); From 0d291dd503c1842f90fc82a22ced090ebc256638 Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Fri, 30 Dec 2016 15:03:13 +0100 Subject: [PATCH 14/32] Typo fix in class name s/contructor/constructor --- tests/Doctrine/Tests/Common/Annotations/DocParserTest.php | 2 +- ...=> AnnotationWithRequiredAttributesWithoutConstructor.php} | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) rename tests/Doctrine/Tests/Common/Annotations/Fixtures/{AnnotationWithRequiredAttributesWithoutContructor.php => AnnotationWithRequiredAttributesWithoutConstructor.php} (61%) diff --git a/tests/Doctrine/Tests/Common/Annotations/DocParserTest.php b/tests/Doctrine/Tests/Common/Annotations/DocParserTest.php index 06b5ad770..8afc5f9e8 100644 --- a/tests/Doctrine/Tests/Common/Annotations/DocParserTest.php +++ b/tests/Doctrine/Tests/Common/Annotations/DocParserTest.php @@ -670,7 +670,7 @@ public function testAnnotationWithRequiredAttributesWithoutContructor() $result = $parser->parse($docblock); $this->assertCount(1, $result); - $this->assertInstanceOf(Fixtures\AnnotationWithRequiredAttributesWithoutContructor::class, $result[0]); + $this->assertInstanceOf(Fixtures\AnnotationWithRequiredAttributesWithoutConstructor::class, $result[0]); $this->assertEquals('Some Value', $result[0]->value); $this->assertInstanceOf(Fixtures\AnnotationTargetAnnotation::class, $result[0]->annot); 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; From 452c37d6387bb299ea1bb0d9e564a4dafddbbf1b Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Fri, 30 Dec 2016 15:09:57 +0100 Subject: [PATCH 15/32] Typo fix s/inteface/interface --- .../Tests/Common/Annotations/DocLexerTest.php | 6 ++-- .../Common/Annotations/DocParserTest.php | 36 +++++++++---------- .../Fixtures/IntefaceWithConstants.php | 10 ------ .../Fixtures/InterfaceWithConstants.php | 10 ++++++ 4 files changed, 31 insertions(+), 31 deletions(-) delete mode 100644 tests/Doctrine/Tests/Common/Annotations/Fixtures/IntefaceWithConstants.php create mode 100644 tests/Doctrine/Tests/Common/Annotations/Fixtures/InterfaceWithConstants.php diff --git a/tests/Doctrine/Tests/Common/Annotations/DocLexerTest.php b/tests/Doctrine/Tests/Common/Annotations/DocLexerTest.php index 27c977146..ebd8aa66f 100644 --- a/tests/Doctrine/Tests/Common/Annotations/DocLexerTest.php +++ b/tests/Doctrine/Tests/Common/Annotations/DocLexerTest.php @@ -28,7 +28,7 @@ public function testMarkerAnnotation() 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, ) diff --git a/tests/Doctrine/Tests/Common/Annotations/DocParserTest.php b/tests/Doctrine/Tests/Common/Annotations/DocParserTest.php index 8afc5f9e8..abcc3129e 100644 --- a/tests/Doctrine/Tests/Common/Annotations/DocParserTest.php +++ b/tests/Doctrine/Tests/Common/Annotations/DocParserTest.php @@ -10,7 +10,7 @@ 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 { @@ -659,14 +659,14 @@ public function testAnnotationWithRequiredAttributes() } - 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->assertCount(1, $result); @@ -675,20 +675,20 @@ public function testAnnotationWithRequiredAttributesWithoutContructor() $this->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); $this->fail(); } catch (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()); + $this->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); $this->fail(); } catch (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()); + $this->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()); } } @@ -784,12 +784,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})', @@ -803,26 +803,26 @@ 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( @@ -852,7 +852,7 @@ public function testSupportClassConstants($docblock, $expected) $parser = $this->createTestParser(); $parser->setImports(array( 'classwithconstants' => ClassWithConstants::class, - 'intefacewithconstants' => IntefaceWithConstants::class, + 'interfacewithconstants' => InterfaceWithConstants::class, 'annotationwithconstants' => AnnotationWithConstants::class )); 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 @@ - Date: Fri, 30 Dec 2016 15:11:31 +0100 Subject: [PATCH 16/32] Documenting possible mock types --- tests/Doctrine/Tests/Common/Annotations/CachedReaderTest.php | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/Doctrine/Tests/Common/Annotations/CachedReaderTest.php b/tests/Doctrine/Tests/Common/Annotations/CachedReaderTest.php index 4df01659f..a7a2247e0 100644 --- a/tests/Doctrine/Tests/Common/Annotations/CachedReaderTest.php +++ b/tests/Doctrine/Tests/Common/Annotations/CachedReaderTest.php @@ -80,6 +80,7 @@ protected function doTestCacheStale($className, $lastCacheModification) { $cacheKey = $className; + /* @var $cache Cache|\PHPUnit_Framework_MockObject_MockObject */ $cache = $this->createMock(Cache::class); $cache ->expects($this->at(0)) From 7321a5bd36c63b9fae0b02e92cf9b25e7831c1cf Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Fri, 30 Dec 2016 15:13:26 +0100 Subject: [PATCH 17/32] Correcting documented parameter type --- lib/Doctrine/Common/Annotations/DocParser.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 * From b13ba6270338106a0ddea8155962efab0ac02d2d Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Fri, 30 Dec 2016 15:13:49 +0100 Subject: [PATCH 18/32] Removing double quotes (loads of weird escape sequences otherwise) --- .../Tests/Common/Annotations/Ticket/DCOM58Test.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/Doctrine/Tests/Common/Annotations/Ticket/DCOM58Test.php b/tests/Doctrine/Tests/Common/Annotations/Ticket/DCOM58Test.php index 5b51c29ee..05314caf4 100644 --- a/tests/Doctrine/Tests/Common/Annotations/Ticket/DCOM58Test.php +++ b/tests/Doctrine/Tests/Common/Annotations/Ticket/DCOM58Test.php @@ -16,7 +16,7 @@ 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; @@ -30,7 +30,7 @@ public function testIssueGlobalNamespace() $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); @@ -43,7 +43,7 @@ public function testIssueNamespaces() { $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); @@ -55,8 +55,8 @@ public function testIssueMultipleNamespaces() { $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); From f982d4fe69ea5fae853570d52fcaa99fd263cee5 Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Fri, 30 Dec 2016 15:14:38 +0100 Subject: [PATCH 19/32] Corrected iterations count comparison --- tests/Doctrine/Tests/Common/Annotations/PerformanceTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Doctrine/Tests/Common/Annotations/PerformanceTest.php b/tests/Doctrine/Tests/Common/Annotations/PerformanceTest.php index 3490f4b58..0bf33b6ae 100644 --- a/tests/Doctrine/Tests/Common/Annotations/PerformanceTest.php +++ b/tests/Doctrine/Tests/Common/Annotations/PerformanceTest.php @@ -172,7 +172,7 @@ private function getMethod() private function printResults($test, $time, $iterations) { - if (0 == $iterations) { + if (! $iterations) { throw new \InvalidArgumentException('$iterations cannot be zero.'); } From 2f98446c69dc0a0e022ebaf53e31264fceb5e682 Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Fri, 30 Dec 2016 15:16:15 +0100 Subject: [PATCH 20/32] Corrected namespacing of some docblock variable declarations --- .../Common/Annotations/Fixtures/AnnotationWithAttributes.php | 2 +- .../Annotations/Fixtures/AnnotationWithRequiredAttributes.php | 4 ++-- .../Common/Annotations/Fixtures/AnnotationWithVarType.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) 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/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; From 247b875df3bb0e8ed7ee70aecaa04e957237f33a Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Fri, 30 Dec 2016 15:18:58 +0100 Subject: [PATCH 21/32] Adding hinting about retrieved annotation type --- .../Tests/Common/Annotations/DocParserTest.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tests/Doctrine/Tests/Common/Annotations/DocParserTest.php b/tests/Doctrine/Tests/Common/Annotations/DocParserTest.php index abcc3129e..80ae053d5 100644 --- a/tests/Doctrine/Tests/Common/Annotations/DocParserTest.php +++ b/tests/Doctrine/Tests/Common/Annotations/DocParserTest.php @@ -636,9 +636,13 @@ public function testAnnotationWithRequiredAttributes() $result = $parser->parse($docblock); $this->assertCount(1, $result); - $this->assertInstanceOf(Fixtures\AnnotationWithRequiredAttributes::class, $result[0]); - $this->assertEquals('Some Value',$result[0]->getValue()); - $this->assertInstanceOf(Fixtures\AnnotationTargetAnnotation::class, $result[0]->getAnnot()); + + /* @var $annotation Fixtures\AnnotationWithRequiredAttributes */ + $annotation = $result[0]; + + $this->assertInstanceOf(Fixtures\AnnotationWithRequiredAttributes::class, $annotation); + $this->assertEquals('Some Value', $annotation->getValue()); + $this->assertInstanceOf(Fixtures\AnnotationTargetAnnotation::class, $annotation->getAnnot()); $docblock = '@Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithRequiredAttributes("Some Value")'; From c79e39738755aae795b517a86632b9571b440ef2 Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Fri, 30 Dec 2016 15:35:08 +0100 Subject: [PATCH 22/32] Removed possible undefined variable failure --- .../Tests/Common/Annotations/Ticket/DCOM58Test.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/Doctrine/Tests/Common/Annotations/Ticket/DCOM58Test.php b/tests/Doctrine/Tests/Common/Annotations/Ticket/DCOM58Test.php index 05314caf4..400641965 100644 --- a/tests/Doctrine/Tests/Common/Annotations/Ticket/DCOM58Test.php +++ b/tests/Doctrine/Tests/Common/Annotations/Ticket/DCOM58Test.php @@ -18,9 +18,10 @@ public function testIssue() $reader = new AnnotationReader(); $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->assertArrayNotHasKey('', $classAnnotations, 'Class "xxx" is not a valid entity or mapped super class.'); } From 41ec04398d3d891601864ef4678429f028173998 Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Fri, 30 Dec 2016 15:35:30 +0100 Subject: [PATCH 23/32] Better error matching via `assertStringMatchesFormat()` --- .../Tests/Common/Annotations/AbstractReaderTest.php | 2 +- .../Tests/Common/Annotations/DocParserTest.php | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/tests/Doctrine/Tests/Common/Annotations/AbstractReaderTest.php b/tests/Doctrine/Tests/Common/Annotations/AbstractReaderTest.php index 11be5e861..7689264e9 100644 --- a/tests/Doctrine/Tests/Common/Annotations/AbstractReaderTest.php +++ b/tests/Doctrine/Tests/Common/Annotations/AbstractReaderTest.php @@ -199,7 +199,7 @@ public function testClassWithPropertyInvalidVarTypeError() /** * @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() { diff --git a/tests/Doctrine/Tests/Common/Annotations/DocParserTest.php b/tests/Doctrine/Tests/Common/Annotations/DocParserTest.php index 80ae053d5..344092376 100644 --- a/tests/Doctrine/Tests/Common/Annotations/DocParserTest.php +++ b/tests/Doctrine/Tests/Common/Annotations/DocParserTest.php @@ -547,7 +547,10 @@ public function testAnnotationWithVarTypeError($attribute,$type,$value,$given) $parser->parse($docblock, $context); $this->fail(); } catch (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()); + $this->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() + ); } } @@ -566,7 +569,10 @@ public function testAnnotationWithVarTypeArrayError($attribute,$type,$value,$giv $parser->parse($docblock, $context); $this->fail(); } catch (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()); + $this->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() + ); } } From c1a3e60107fad0955f17ce116ab2664d6fc486c6 Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Fri, 30 Dec 2016 15:37:54 +0100 Subject: [PATCH 24/32] Removed unused imports --- tests/Doctrine/Tests/Common/Annotations/AbstractReaderTest.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/Doctrine/Tests/Common/Annotations/AbstractReaderTest.php b/tests/Doctrine/Tests/Common/Annotations/AbstractReaderTest.php index 7689264e9..ed0808f29 100644 --- a/tests/Doctrine/Tests/Common/Annotations/AbstractReaderTest.php +++ b/tests/Doctrine/Tests/Common/Annotations/AbstractReaderTest.php @@ -2,10 +2,8 @@ namespace Doctrine\Tests\Common\Annotations; -use Doctrine\Common\Annotations\Annotation\IgnoreAnnotation; use Doctrine\Common\Annotations\Annotation; use Doctrine\Common\Annotations\AnnotationException; -use Doctrine\Common\Annotations\Reader; use ReflectionClass, Doctrine\Common\Annotations\AnnotationReader; require_once __DIR__ . '/TopLevelAnnotation.php'; From 0d192a2fad63e5e5f7fbaaaeb1fccd1839f790b2 Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Fri, 30 Dec 2016 15:38:47 +0100 Subject: [PATCH 25/32] Removed unused variables --- tests/Doctrine/Tests/Common/Annotations/DocParserTest.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/Doctrine/Tests/Common/Annotations/DocParserTest.php b/tests/Doctrine/Tests/Common/Annotations/DocParserTest.php index 344092376..44a26735a 100644 --- a/tests/Doctrine/Tests/Common/Annotations/DocParserTest.php +++ b/tests/Doctrine/Tests/Common/Annotations/DocParserTest.php @@ -653,7 +653,7 @@ public function testAnnotationWithRequiredAttributes() $docblock = '@Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithRequiredAttributes("Some Value")'; try { - $result = $parser->parse($docblock,$context); + $parser->parse($docblock,$context); $this->fail(); } catch (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()); @@ -661,7 +661,7 @@ public function testAnnotationWithRequiredAttributes() $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 (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()); @@ -687,7 +687,7 @@ public function testAnnotationWithRequiredAttributesWithoutConstructor() $docblock = '@Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithRequiredAttributesWithoutConstructor("Some Value")'; try { - $result = $parser->parse($docblock,$context); + $parser->parse($docblock,$context); $this->fail(); } catch (AnnotationException $exc) { $this->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()); @@ -695,7 +695,7 @@ public function testAnnotationWithRequiredAttributesWithoutConstructor() $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 (AnnotationException $exc) { $this->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()); From 1df6eba6d7d1687e7a960498974c11ca4a3fea8a Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Fri, 30 Dec 2016 15:39:42 +0100 Subject: [PATCH 26/32] Documenting possible mock types --- tests/Doctrine/Tests/Common/Annotations/PhpParserTest.php | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/Doctrine/Tests/Common/Annotations/PhpParserTest.php b/tests/Doctrine/Tests/Common/Annotations/PhpParserTest.php index 070ef5670..f4200a0b0 100644 --- a/tests/Doctrine/Tests/Common/Annotations/PhpParserTest.php +++ b/tests/Doctrine/Tests/Common/Annotations/PhpParserTest.php @@ -56,6 +56,7 @@ public function testParseClassWhenNotUserDefined() public function testClassFileDoesNotExist() { + /* @var $class ReflectionClass|\PHPUnit_Framework_MockObject_MockObject */ $class = $this->getMockBuilder(ReflectionClass::class) ->disableOriginalConstructor() ->getMock(); From bd26dd1107435c462bef070942f206e8fb23a2cc Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Fri, 30 Dec 2016 15:41:15 +0100 Subject: [PATCH 27/32] Replacing useless FQCN --- .../Tests/Common/Annotations/AbstractReaderTest.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/Doctrine/Tests/Common/Annotations/AbstractReaderTest.php b/tests/Doctrine/Tests/Common/Annotations/AbstractReaderTest.php index ed0808f29..d1364ae73 100644 --- a/tests/Doctrine/Tests/Common/Annotations/AbstractReaderTest.php +++ b/tests/Doctrine/Tests/Common/Annotations/AbstractReaderTest.php @@ -631,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; } From 19ea97862f23488392c2c1afcc2c9a94912b3093 Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Fri, 30 Dec 2016 15:42:40 +0100 Subject: [PATCH 28/32] Replacing manual `is_array` checks with `assertInternalType('array', ...)` --- .../Tests/Common/Annotations/DocParserTest.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/Doctrine/Tests/Common/Annotations/DocParserTest.php b/tests/Doctrine/Tests/Common/Annotations/DocParserTest.php index 44a26735a..b5e1c911f 100644 --- a/tests/Doctrine/Tests/Common/Annotations/DocParserTest.php +++ b/tests/Doctrine/Tests/Common/Annotations/DocParserTest.php @@ -27,7 +27,7 @@ public function testNestedArraysWithNestedAnnotation() $this->assertCount(3, $annot->foo); $this->assertEquals(1, $annot->foo[0]); $this->assertEquals(2, $annot->foo[1]); - $this->assertTrue(is_array($annot->foo[2])); + $this->assertInternalType('array', $annot->foo[2]); $nestedArray = $annot->foo[2]; $this->assertTrue(isset($nestedArray['key'])); @@ -49,13 +49,13 @@ public function testBasicAnnotations() $result = $parser->parse('@Name(foo={"key1" = "value1"})'); $annot = $result[0]; $this->assertNull($annot->value); - $this->assertTrue(is_array($annot->foo)); + $this->assertInternalType('array', $annot->foo); $this->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->assertInternalType('array', $annot->value); $this->assertEquals('foo', $annot->value[2]); $this->assertEquals('bar', $annot->value[4]); $this->assertFalse(isset($annot->value[0])); @@ -67,7 +67,7 @@ public function testBasicAnnotations() $annot = $result[0]; $this->assertInstanceOf(Name::class, $annot); - $this->assertTrue(is_array($annot->value)); + $this->assertInternalType('array', $annot->value); $this->assertInstanceOf(Name::class, $annot->value[0]); $this->assertInstanceOf(Name::class, $annot->value[1]); @@ -76,9 +76,9 @@ public function testBasicAnnotations() $annot = $result[0]; $this->assertInstanceOf(Name::class, $annot); - $this->assertTrue(is_array($annot->value)); + $this->assertInternalType('array', $annot->value); $this->assertInstanceOf(Name::class, $annot->value[0]); - $this->assertTrue(is_array($annot->value[1])); + $this->assertInternalType('array', $annot->value[1]); $this->assertEquals('value1', $annot->value[1]['key1']); $this->assertEquals('value2', $annot->value[1]['key2']); @@ -109,7 +109,7 @@ public function testDefaultValueAnnotations() $annot = $result[0]; $this->assertInstanceOf(Name::class, $annot); - $this->assertTrue(is_array($annot->value)); + $this->assertInternalType('array', $annot->value); $this->assertEquals('value1', $annot->value['key1']); // Array as first value and additional values @@ -117,7 +117,7 @@ public function testDefaultValueAnnotations() $annot = $result[0]; $this->assertInstanceOf(Name::class, $annot); - $this->assertTrue(is_array($annot->value)); + $this->assertInternalType('array', $annot->value); $this->assertEquals('value1', $annot->value['key1']); $this->assertEquals('bar', $annot->foo); } From 2f32c4710e636e86e593489c3253f14b2883f28a Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Fri, 30 Dec 2016 16:09:12 +0100 Subject: [PATCH 29/32] s/$this->assert/self::assert As per @lcobucci's review --- .../Common/Annotations/AbstractReaderTest.php | 130 ++++---- .../Annotations/Annotation/TargetTest.php | 8 +- .../Annotations/AnnotationReaderTest.php | 12 +- .../Annotations/AnnotationRegistryTest.php | 10 +- .../Common/Annotations/CachedReaderTest.php | 2 +- .../Tests/Common/Annotations/DocLexerTest.php | 44 +-- .../Common/Annotations/DocParserTest.php | 286 +++++++++--------- .../Annotations/FileCacheReaderTest.php | 4 +- .../Common/Annotations/PhpParserTest.php | 38 +-- .../SimpleAnnotationReaderTest.php | 10 +- .../Common/Annotations/Ticket/DCOM55Test.php | 6 +- .../Common/Annotations/Ticket/DCOM58Test.php | 24 +- 12 files changed, 287 insertions(+), 287 deletions(-) diff --git a/tests/Doctrine/Tests/Common/Annotations/AbstractReaderTest.php b/tests/Doctrine/Tests/Common/Annotations/AbstractReaderTest.php index d1364ae73..b41b0ac89 100644 --- a/tests/Doctrine/Tests/Common/Annotations/AbstractReaderTest.php +++ b/tests/Doctrine/Tests/Common/Annotations/AbstractReaderTest.php @@ -20,47 +20,47 @@ public function testAnnotations() $class = $this->getReflectionClass(); $reader = $this->getReader(); - $this->assertCount(1, $reader->getClassAnnotations($class)); - $this->assertInstanceOf($annotName = DummyAnnotation::class, $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->assertCount(1, $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->assertCount(1, $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->assertCount(1, $propAnnots); - $this->assertInstanceOf($annotName = DummyJoinTable::class, $joinTableAnnot = $reader->getPropertyAnnotation($field2Prop, $annotName)); - $this->assertCount(1, $joinTableAnnot->joinColumns); - $this->assertCount(1, $joinTableAnnot->inverseJoinColumns); - $this->assertInstanceOf(DummyJoinColumn::class, $joinTableAnnot->joinColumns[0]); - $this->assertInstanceOf(DummyJoinColumn::class, $joinTableAnnot->inverseJoinColumns[0]); - $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'), DummyAnnotation::class); - $this->assertEquals('', $dummyAnnot->dummyValue); - $this->assertEquals(array(1, 2, 'three'), $dummyAnnot->value); + self::assertEquals('', $dummyAnnot->dummyValue); + self::assertEquals(array(1, 2, 'three'), $dummyAnnot->value); $dummyAnnot = $reader->getMethodAnnotation($class->getMethod('getField3'), DummyAnnotation::class); - $this->assertEquals('\d{4}-[01]\d-[0-3]\d [0-2]\d:[0-5]\d:[0-5]\d', $dummyAnnot->value); + 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'), DummyAnnotation::class); - $this->assertEquals('fieldHello', $dummyAnnot->dummyValue); + self::assertEquals('fieldHello', $dummyAnnot->dummyValue); $classAnnot = $reader->getClassAnnotation($class, DummyAnnotation::class); - $this->assertEquals('hello', $classAnnot->dummyValue); + self::assertEquals('hello', $classAnnot->dummyValue); } public function testAnnotationsWithValidTargets() @@ -68,10 +68,10 @@ public function testAnnotationsWithValidTargets() $reader = $this->getReader(); $class = new ReflectionClass(Fixtures\ClassWithValidAnnotationTarget::class); - $this->assertCount(1, $reader->getClassAnnotations($class)); - $this->assertCount(1, $reader->getPropertyAnnotations($class->getProperty('foo'))); - $this->assertCount(1, $reader->getMethodAnnotations($class->getMethod('someFunction'))); - $this->assertCount(1, $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() @@ -79,11 +79,11 @@ public function testAnnotationsWithVarType() $reader = $this->getReader(); $class = new ReflectionClass(Fixtures\ClassWithAnnotationWithVarType::class); - $this->assertCount(1, $fooAnnot = $reader->getPropertyAnnotations($class->getProperty('foo'))); - $this->assertCount(1, $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(Fixtures\AnnotationTargetAll::class, $barAnnot[0]->annotation); + self::assertInternalType('string', $fooAnnot[0]->string); + self::assertInstanceOf(Fixtures\AnnotationTargetAll::class, $barAnnot[0]->annotation); } public function testAtInDescription() @@ -91,11 +91,11 @@ public function testAtInDescription() $reader = $this->getReader(); $class = new ReflectionClass(Fixtures\ClassWithAtInDescriptionAndAnnotation::class); - $this->assertCount(1, $fooAnnot = $reader->getPropertyAnnotations($class->getProperty('foo'))); - $this->assertCount(1, $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(Fixtures\AnnotationTargetPropertyMethod::class, $fooAnnot[0]); - $this->assertInstanceOf(Fixtures\AnnotationTargetPropertyMethod::class, $barAnnot[0]); + self::assertInstanceOf(Fixtures\AnnotationTargetPropertyMethod::class, $fooAnnot[0]); + self::assertInstanceOf(Fixtures\AnnotationTargetPropertyMethod::class, $barAnnot[0]); } public function testClassWithWithDanglingComma() @@ -103,7 +103,7 @@ public function testClassWithWithDanglingComma() $reader = $this->getReader(); $annots = $reader->getClassAnnotations(new \ReflectionClass(DummyClassWithDanglingComma::class)); - $this->assertCount(1, $annots); + self::assertCount(1, $annots); } /** @@ -120,7 +120,7 @@ public function testClassWithWithInclude() { $reader = $this->getReader(); $annots = $reader->getClassAnnotations(new \ReflectionClass(Fixtures\ClassWithRequire::class)); - $this->assertCount(1, $annots); + self::assertCount(1, $annots); } /** @@ -244,15 +244,15 @@ public function testMultipleAnnotationsOnSameLine() { $reader = $this->getReader(); $annots = $reader->getPropertyAnnotations(new \ReflectionProperty(DummyClass2::class, 'id')); - $this->assertCount(3, $annots); + self::assertCount(3, $annots); } public function testNonAnnotationProblem() { $reader = $this->getReader(); - $this->assertNotNull($annot = $reader->getPropertyAnnotation(new \ReflectionProperty(DummyClassNonAnnotationProblem::class, 'foo'), $name = DummyAnnotation::class)); - $this->assertInstanceOf($name, $annot); + self::assertNotNull($annot = $reader->getPropertyAnnotation(new \ReflectionProperty(DummyClassNonAnnotationProblem::class, 'foo'), $name = DummyAnnotation::class)); + self::assertInstanceOf($name, $annot); } public function testIncludeIgnoreAnnotation() @@ -260,7 +260,7 @@ public function testIncludeIgnoreAnnotation() $reader = $this->getReader(); $reader->getPropertyAnnotations(new \ReflectionProperty(Fixtures\ClassWithIgnoreAnnotation::class, 'foo')); - $this->assertFalse(class_exists(Fixtures\IgnoreAnnotationClass::class, false)); + self::assertFalse(class_exists(Fixtures\IgnoreAnnotationClass::class, false)); } public function testImportWithConcreteAnnotation() @@ -268,8 +268,8 @@ public function testImportWithConcreteAnnotation() $reader = $this->getReader(); $property = new \ReflectionProperty(TestImportWithConcreteAnnotation::class, 'field'); $annotations = $reader->getPropertyAnnotations($property); - $this->assertCount(1, $annotations); - $this->assertNotNull($reader->getPropertyAnnotation($property, DummyAnnotation::class)); + self::assertCount(1, $annotations); + self::assertNotNull($reader->getPropertyAnnotation($property, DummyAnnotation::class)); } public function testImportWithInheritance() @@ -280,12 +280,12 @@ public function testImportWithInheritance() $ref = new \ReflectionClass($class); $childAnnotations = $reader->getPropertyAnnotations($ref->getProperty('child')); - $this->assertCount(1, $childAnnotations); - $this->assertInstanceOf(Foo\Name::class, reset($childAnnotations)); + self::assertCount(1, $childAnnotations); + self::assertInstanceOf(Foo\Name::class, reset($childAnnotations)); $parentAnnotations = $reader->getPropertyAnnotations($ref->getProperty('parent')); - $this->assertCount(1, $parentAnnotations); - $this->assertInstanceOf(Bar\Name::class, reset($parentAnnotations)); + self::assertCount(1, $parentAnnotations); + self::assertInstanceOf(Bar\Name::class, reset($parentAnnotations)); } /** @@ -313,8 +313,8 @@ public function testTopLevelAnnotation() $reader = $this->getReader(); $annotations = $reader->getPropertyAnnotations(new \ReflectionProperty(TestTopLevelAnnotationClass::class, 'field')); - $this->assertCount(1, $annotations); - $this->assertInstanceOf(\TopLevelAnnotation::class, reset($annotations)); + self::assertCount(1, $annotations); + self::assertInstanceOf(\TopLevelAnnotation::class, reset($annotations)); } public function testIgnoresAnnotationsNotPrefixedWithWhitespace() @@ -322,7 +322,7 @@ public function testIgnoresAnnotationsNotPrefixedWithWhitespace() $reader = $this->getReader(); $annotation = $reader->getClassAnnotation(new \ReflectionClass(new TestIgnoresNonAnnotationsClass()), Name::class); - $this->assertInstanceOf(Name::class, $annotation); + self::assertInstanceOf(Name::class, $annotation); } private static $testResetsPhpParserAfterUseRun = false; @@ -340,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::class), '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(); @@ -365,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); } /** @@ -389,7 +389,7 @@ public function testInvalidAnnotationUsageButIgnoredClass() $ref = new \ReflectionClass(Fixtures\InvalidAnnotationUsageButIgnoredClass::class); $annots = $reader->getClassAnnotations($ref); - $this->assertCount(2, $annots); + self::assertCount(2, $annots); } /** @@ -401,10 +401,10 @@ public function testInvalidAnnotationButIgnored() $reader = $this->getReader(); $class = new \ReflectionClass(Fixtures\ClassDDC1660::class); - $this->assertTrue(class_exists(Fixtures\Annotation\Version::class)); - $this->assertEmpty($reader->getClassAnnotations($class)); - $this->assertEmpty($reader->getMethodAnnotations($class->getMethod('bar'))); - $this->assertEmpty($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() @@ -412,24 +412,24 @@ public function testAnnotationEnumeratorException() $reader = $this->getReader(); $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(Fixtures\AnnotationEnum::class, $bar[0]); - $this->assertInstanceOf(Fixtures\AnnotationEnum::class, $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 (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()); + 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 (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()); + 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()); } } diff --git a/tests/Doctrine/Tests/Common/Annotations/Annotation/TargetTest.php b/tests/Doctrine/Tests/Common/Annotations/Annotation/TargetTest.php index 1402e21bb..20f483872 100644 --- a/tests/Doctrine/Tests/Common/Annotations/Annotation/TargetTest.php +++ b/tests/Doctrine/Tests/Common/Annotations/Annotation/TargetTest.php @@ -34,14 +34,14 @@ class TargetTest extends \PHPUnit_Framework_TestCase public function testValidMixedTargets() { $target = new Target(array('value' => array('ALL'))); - $this->assertEquals(Target::TARGET_ALL, $target->targets); + 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); + 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); + 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 52769dcb5..f49ed7db9 100644 --- a/tests/Doctrine/Tests/Common/Annotations/AnnotationReaderTest.php +++ b/tests/Doctrine/Tests/Common/Annotations/AnnotationReaderTest.php @@ -25,10 +25,10 @@ public function testMethodAnnotationFromTrait() $ref = new \ReflectionClass(Fixtures\ClassUsesTrait::class); $annotations = $reader->getMethodAnnotations($ref->getMethod('someMethod')); - $this->assertInstanceOf(Bar\Autoload::class, $annotations[0]); + self::assertInstanceOf(Bar\Autoload::class, $annotations[0]); $annotations = $reader->getMethodAnnotations($ref->getMethod('traitMethod')); - $this->assertInstanceOf(Fixtures\Annotation\Autoload::class, $annotations[0]); + self::assertInstanceOf(Fixtures\Annotation\Autoload::class, $annotations[0]); } public function testMethodAnnotationFromOverwrittenTrait() @@ -37,7 +37,7 @@ public function testMethodAnnotationFromOverwrittenTrait() $ref = new \ReflectionClass(Fixtures\ClassOverwritesTrait::class); $annotations = $reader->getMethodAnnotations($ref->getMethod('traitMethod')); - $this->assertInstanceOf(Bar2\Autoload::class, $annotations[0]); + self::assertInstanceOf(Bar2\Autoload::class, $annotations[0]); } public function testPropertyAnnotationFromTrait() @@ -46,10 +46,10 @@ public function testPropertyAnnotationFromTrait() $ref = new \ReflectionClass(Fixtures\ClassUsesTrait::class); $annotations = $reader->getPropertyAnnotations($ref->getProperty('aProperty')); - $this->assertInstanceOf(Bar\Autoload::class, $annotations[0]); + self::assertInstanceOf(Bar\Autoload::class, $annotations[0]); $annotations = $reader->getPropertyAnnotations($ref->getProperty('traitProperty')); - $this->assertInstanceOf(Fixtures\Annotation\Autoload::class, $annotations[0]); + self::assertInstanceOf(Fixtures\Annotation\Autoload::class, $annotations[0]); } public function testOmitNotRegisteredAnnotation() @@ -61,7 +61,7 @@ public function testOmitNotRegisteredAnnotation() $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 fd0c02687..36db2b535 100644 --- a/tests/Doctrine/Tests/Common/Annotations/AnnotationRegistryTest.php +++ b/tests/Doctrine/Tests/Common/Annotations/AnnotationRegistryTest.php @@ -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 a7a2247e0..d558eba91 100644 --- a/tests/Doctrine/Tests/Common/Annotations/CachedReaderTest.php +++ b/tests/Doctrine/Tests/Common/Annotations/CachedReaderTest.php @@ -109,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 ebd8aa66f..5f6db9917 100644 --- a/tests/Doctrine/Tests/Common/Annotations/DocLexerTest.php +++ b/tests/Doctrine/Tests/Common/Annotations/DocLexerTest.php @@ -11,18 +11,18 @@ public function testMarkerAnnotation() $lexer = new DocLexer; $lexer->setInput('@Name'); - $this->assertNull($lexer->token); - $this->assertNull($lexer->lookahead); + 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() @@ -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 b5e1c911f..256ab32b4 100644 --- a/tests/Doctrine/Tests/Common/Annotations/DocParserTest.php +++ b/tests/Doctrine/Tests/Common/Annotations/DocParserTest.php @@ -22,16 +22,16 @@ public function testNestedArraysWithNestedAnnotation() $result = $parser->parse('@Name(foo={1,2, {"key"=@Name}})'); $annot = $result[0]; - $this->assertInstanceOf(Name::class, $annot); - $this->assertNull($annot->value); - $this->assertCount(3, $annot->foo); - $this->assertEquals(1, $annot->foo[0]); - $this->assertEquals(2, $annot->foo[1]); - $this->assertInternalType('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->assertInstanceOf(Name::class, $nestedArray['key']); + self::assertTrue(isset($nestedArray['key'])); + self::assertInstanceOf(Name::class, $nestedArray['key']); } public function testBasicAnnotations() @@ -41,46 +41,46 @@ public function testBasicAnnotations() // Marker annotation $result = $parser->parse('@Name'); $annot = $result[0]; - $this->assertInstanceOf(Name::class, $annot); - $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->assertInternalType('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->assertInternalType('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->assertInstanceOf(Name::class, $annot); - $this->assertInternalType('array', $annot->value); - $this->assertInstanceOf(Name::class, $annot->value[0]); - $this->assertInstanceOf(Name::class, $annot->value[1]); + 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->assertInstanceOf(Name::class, $annot); - $this->assertInternalType('array', $annot->value); - $this->assertInstanceOf(Name::class, $annot->value[0]); - $this->assertInternalType('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->assertCount(1, $result); + self::assertCount(1, $result); $annot = $result[0]; - $this->assertInstanceOf(Name::class, $annot); - $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() @@ -108,18 +108,18 @@ public function testDefaultValueAnnotations() $result = $parser->parse('@Name({"key1"="value1"})'); $annot = $result[0]; - $this->assertInstanceOf(Name::class, $annot); - $this->assertInternalType('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->assertInstanceOf(Name::class, $annot); - $this->assertInternalType('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() @@ -140,10 +140,10 @@ public function testNamespacedAnnotations() DOCBLOCK; $result = $parser->parse($docblock); - $this->assertCount(1, $result); + self::assertCount(1, $result); $annot = $result[0]; - $this->assertInstanceOf(Name::class, $annot); - $this->assertEquals('bar', $annot->foo); + self::assertInstanceOf(Name::class, $annot); + self::assertEquals('bar', $annot->foo); } /** @@ -168,14 +168,14 @@ public function testTypicalMethodDocBlock() DOCBLOCK; $result = $parser->parse($docblock); - $this->assertCount(2, $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->assertInstanceOf(Name::class, $annot); - $this->assertEquals('bar', $annot->foo); + self::assertInstanceOf(Name::class, $annot); + self::assertEquals('bar', $annot->foo); $marker = $result[1]; - $this->assertInstanceOf(Marker::class, $marker); + self::assertInstanceOf(Marker::class, $marker); } @@ -191,14 +191,14 @@ public function testAnnotationWithoutConstructor() DOCBLOCK; $result = $parser->parse($docblock); - $this->assertCount(1, $result); + self::assertCount(1, $result); $annot = $result[0]; - $this->assertInstanceOf(SomeAnnotationClassNameWithoutConstructor::class, $annot); + 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'); @@ -211,14 +211,14 @@ public function testAnnotationWithoutConstructor() $result = $parser->parse($docblock); - $this->assertCount(1, $result); + self::assertCount(1, $result); $annot = $result[0]; - $this->assertNotNull($annot); - $this->assertInstanceOf(SomeAnnotationClassNameWithoutConstructor::class, $annot); + 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'); @@ -230,11 +230,11 @@ public function testAnnotationWithoutConstructor() DOCBLOCK; $result = $parser->parse($docblock); - $this->assertCount(1, $result); + 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->assertCount(1, $result); + 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->assertCount(1, $result); + 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); @@ -272,11 +272,11 @@ public function testAnnotationWithoutConstructor() DOCBLOCK; $result = $parser->parse($docblock); - $this->assertCount(1, $result); + 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->assertCount(1, $result); + 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->assertCount(1, $result); - $this->assertInstanceOf(SomeAnnotationClassNameWithoutConstructorAndProperties::class, $result[0]); + self::assertCount(1, $result); + self::assertInstanceOf(SomeAnnotationClassNameWithoutConstructorAndProperties::class, $result[0]); } public function testAnnotationTarget() @@ -317,7 +317,7 @@ public function testAnnotationTarget() $docComment = $class->getDocComment(); $parser->setTarget(Target::TARGET_CLASS); - $this->assertNotNull($parser->parse($docComment,$context)); + self::assertNotNull($parser->parse($docComment,$context)); $property = $class->getProperty('foo'); @@ -325,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)); @@ -334,7 +334,7 @@ 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 { @@ -347,7 +347,7 @@ public function testAnnotationTarget() $this->fail(); } catch (AnnotationException $exc) { - $this->assertNotNull($exc->getMessage()); + self::assertNotNull($exc->getMessage()); } @@ -363,7 +363,7 @@ public function testAnnotationTarget() $this->fail(); } catch (AnnotationException $exc) { - $this->assertNotNull($exc->getMessage()); + self::assertNotNull($exc->getMessage()); } @@ -378,7 +378,7 @@ public function testAnnotationTarget() $this->fail(); } catch (AnnotationException $exc) { - $this->assertNotNull($exc->getMessage()); + self::assertNotNull($exc->getMessage()); } } @@ -528,9 +528,9 @@ public function testAnnotationWithVarType($attribute, $value) $result = $parser->parse($docblock, $context); - $this->assertCount(1, $result); - $this->assertInstanceOf(Fixtures\AnnotationWithVarType::class, $result[0]); - $this->assertNotNull($result[0]->$attribute); + self::assertCount(1, $result); + self::assertInstanceOf(Fixtures\AnnotationWithVarType::class, $result[0]); + self::assertNotNull($result[0]->$attribute); } /** @@ -547,7 +547,7 @@ public function testAnnotationWithVarTypeError($attribute,$type,$value,$given) $parser->parse($docblock, $context); $this->fail(); } catch (AnnotationException $exc) { - $this->assertStringMatchesFormat( + 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() ); @@ -569,7 +569,7 @@ public function testAnnotationWithVarTypeArrayError($attribute,$type,$value,$giv $parser->parse($docblock, $context); $this->fail(); } catch (AnnotationException $exc) { - $this->assertStringMatchesFormat( + 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() ); @@ -588,10 +588,10 @@ public function testAnnotationWithAttributes($attribute, $value) $result = $parser->parse($docblock, $context); - $this->assertCount(1, $result); - $this->assertInstanceOf(Fixtures\AnnotationWithAttributes::class, $result[0]); + self::assertCount(1, $result); + self::assertInstanceOf(Fixtures\AnnotationWithAttributes::class, $result[0]); $getter = 'get' .ucfirst($attribute); - $this->assertNotNull($result[0]->$getter()); + self::assertNotNull($result[0]->$getter()); } /** @@ -608,7 +608,7 @@ public function testAnnotationWithAttributesError($attribute,$type,$value,$given $parser->parse($docblock, $context); $this->fail(); } catch (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()); + 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()); } } @@ -627,7 +627,7 @@ public function testAnnotationWithAttributesWithVarTypeArrayError($attribute,$ty $parser->parse($docblock, $context); $this->fail(); } catch (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()); + 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()); } } @@ -641,14 +641,14 @@ public function testAnnotationWithRequiredAttributes() $docblock = '@Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithRequiredAttributes("Some Value", annot = @Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAnnotation)'; $result = $parser->parse($docblock); - $this->assertCount(1, $result); + self::assertCount(1, $result); /* @var $annotation Fixtures\AnnotationWithRequiredAttributes */ $annotation = $result[0]; - $this->assertInstanceOf(Fixtures\AnnotationWithRequiredAttributes::class, $annotation); - $this->assertEquals('Some Value', $annotation->getValue()); - $this->assertInstanceOf(Fixtures\AnnotationTargetAnnotation::class, $annotation->getAnnot()); + 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")'; @@ -656,7 +656,7 @@ public function testAnnotationWithRequiredAttributes() $parser->parse($docblock,$context); $this->fail(); } catch (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()); + 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)'; @@ -664,7 +664,7 @@ public function testAnnotationWithRequiredAttributes() $parser->parse($docblock,$context); $this->fail(); } catch (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()); + 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()); } } @@ -679,10 +679,10 @@ public function testAnnotationWithRequiredAttributesWithoutConstructor() $docblock = '@Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithRequiredAttributesWithoutConstructor("Some Value", annot = @Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAnnotation)'; $result = $parser->parse($docblock); - $this->assertCount(1, $result); - $this->assertInstanceOf(Fixtures\AnnotationWithRequiredAttributesWithoutConstructor::class, $result[0]); - $this->assertEquals('Some Value', $result[0]->value); - $this->assertInstanceOf(Fixtures\AnnotationTargetAnnotation::class, $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\AnnotationWithRequiredAttributesWithoutConstructor("Some Value")'; @@ -690,7 +690,7 @@ public function testAnnotationWithRequiredAttributesWithoutConstructor() $parser->parse($docblock,$context); $this->fail(); } catch (AnnotationException $exc) { - $this->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()); + 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\AnnotationWithRequiredAttributesWithoutConstructor(annot = @Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAnnotation)'; @@ -698,7 +698,7 @@ public function testAnnotationWithRequiredAttributesWithoutConstructor() $parser->parse($docblock,$context); $this->fail(); } catch (AnnotationException $exc) { - $this->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()); + 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()); } } @@ -867,8 +867,8 @@ public function testSupportClassConstants($docblock, $expected) )); $result = $parser->parse($docblock); - $this->assertInstanceOf(AnnotationWithConstants::class, $annotation = $result[0]); - $this->assertEquals($expected, $annotation->value); + self::assertInstanceOf(AnnotationWithConstants::class, $annotation = $result[0]); + self::assertEquals($expected, $annotation->value); } /** @@ -977,7 +977,7 @@ public function testRegressionDDC575() $result = $parser->parse($docblock); - $this->assertInstanceOf(Name::class, $result[0]); + self::assertInstanceOf(Name::class, $result[0]); $docblock = <<parse($docblock); - $this->assertInstanceOf(Name::class, $result[0]); + self::assertInstanceOf(Name::class, $result[0]); } /** @@ -1002,7 +1002,7 @@ public function testAnnotationWithoutClassIsIgnoredWithoutWarning() $parser->setIgnoreNotImportedAnnotations(true); $result = $parser->parse('@param'); - $this->assertEmpty($result); + self::assertEmpty($result); } /** @@ -1058,7 +1058,7 @@ public function testNotAnAnnotationClassIsIgnoredWithoutWarning() $parser->setIgnoredAnnotationNames(array(\PHPUnit_Framework_TestCase::class => true)); $result = $parser->parse('@PHPUnit_Framework_TestCase'); - $this->assertEmpty($result); + self::assertEmpty($result); } public function testNotAnAnnotationClassIsIgnoredWithoutWarningWithoutCheating() @@ -1067,7 +1067,7 @@ public function testNotAnAnnotationClassIsIgnoredWithoutWarningWithoutCheating() $parser->setIgnoreNotImportedAnnotations(true); $result = $parser->parse('@PHPUnit_Framework_TestCase'); - $this->assertEmpty($result); + self::assertEmpty($result); } /** @@ -1088,7 +1088,7 @@ public function testAnnotationDoesntThrowExceptionWhenAtSignIsNotFollowedByIdent $parser = new DocParser(); $result = $parser->parse("'@'"); - $this->assertEmpty($result); + self::assertEmpty($result); } /** @@ -1106,7 +1106,7 @@ 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(); @@ -1117,8 +1117,8 @@ public function testAutoloadAnnotation() )); $annotations = $parser->parse('@Autoload'); - $this->assertCount(1, $annotations); - $this->assertInstanceOf(Fixtures\Annotation\Autoload::class, $annotations[0]); + self::assertCount(1, $annotations); + self::assertInstanceOf(Fixtures\Annotation\Autoload::class, $annotations[0]); } public function createTestParser() @@ -1199,7 +1199,7 @@ public function testCastInt() $result = $parser->parse('@Name(foo=1234)'); $annot = $result[0]; - $this->assertInternalType('int', $annot->foo); + self::assertInternalType('int', $annot->foo); } /** @@ -1211,7 +1211,7 @@ public function testCastNegativeInt() $result = $parser->parse('@Name(foo=-1234)'); $annot = $result[0]; - $this->assertInternalType('int', $annot->foo); + self::assertInternalType('int', $annot->foo); } /** @@ -1223,7 +1223,7 @@ public function testCastFloat() $result = $parser->parse('@Name(foo=1234.345)'); $annot = $result[0]; - $this->assertInternalType('float', $annot->foo); + self::assertInternalType('float', $annot->foo); } /** @@ -1235,11 +1235,11 @@ public function testCastNegativeFloat() $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)'); $annot = $result[0]; - $this->assertInternalType('float', $annot->value); + self::assertInternalType('float', $annot->value); } public function testReservedKeywordsInAnnotations() @@ -1252,18 +1252,18 @@ public function testReservedKeywordsInAnnotations() $parser = $this->createTestParser(); $result = $parser->parse('@Doctrine\Tests\Common\Annotations\True'); - $this->assertInstanceOf(True::class, $result[0]); + self::assertInstanceOf(True::class, $result[0]); $result = $parser->parse('@Doctrine\Tests\Common\Annotations\False'); - $this->assertInstanceOf(False::class, $result[0]); + self::assertInstanceOf(False::class, $result[0]); $result = $parser->parse('@Doctrine\Tests\Common\Annotations\Null'); - $this->assertInstanceOf(Null::class, $result[0]); + self::assertInstanceOf(Null::class, $result[0]); $result = $parser->parse('@True'); - $this->assertInstanceOf(True::class, $result[0]); + self::assertInstanceOf(True::class, $result[0]); $result = $parser->parse('@False'); - $this->assertInstanceOf(False::class, $result[0]); + self::assertInstanceOf(False::class, $result[0]); $result = $parser->parse('@Null'); - $this->assertInstanceOf(Null::class, $result[0]); + self::assertInstanceOf(Null::class, $result[0]); } /** @@ -1299,8 +1299,8 @@ public function testTrailingCommaIsAllowed() "Foo", "Bar", })'); - $this->assertCount(1, $annots); - $this->assertEquals(array('Foo', 'Bar'), $annots[0]->value); + self::assertCount(1, $annots); + self::assertEquals(array('Foo', 'Bar'), $annots[0]->value); } public function testTabPrefixIsAllowed() @@ -1313,8 +1313,8 @@ public function testTabPrefixIsAllowed() $parser = $this->createTestParser(); $result = $parser->parse($docblock); - $this->assertCount(1, $result); - $this->assertInstanceOf(Name::class, $result[0]); + self::assertCount(1, $result); + self::assertInstanceOf(Name::class, $result[0]); } public function testDefaultAnnotationValueIsNotOverwritten() @@ -1322,8 +1322,8 @@ public function testDefaultAnnotationValueIsNotOverwritten() $parser = $this->createTestParser(); $annots = $parser->parse('@Doctrine\Tests\Common\Annotations\Fixtures\Annotation\AnnotWithDefaultValue'); - $this->assertCount(1, $annots); - $this->assertEquals('bar', $annots[0]->foo); + self::assertCount(1, $annots); + self::assertEquals('bar', $annots[0]->foo); } public function testArrayWithColon() @@ -1331,8 +1331,8 @@ public function testArrayWithColon() $parser = $this->createTestParser(); $annots = $parser->parse('@Name({"foo": "bar"})'); - $this->assertCount(1, $annots); - $this->assertEquals(array('foo' => 'bar'), $annots[0]->value); + self::assertCount(1, $annots); + self::assertEquals(array('foo' => 'bar'), $annots[0]->value); } /** @@ -1353,8 +1353,8 @@ public function testEmptyArray() $parser = $this->createTestParser(); $annots = $parser->parse('@Name({"foo": {}})'); - $this->assertCount(1, $annots); - $this->assertEquals(array('foo' => array()), $annots[0]->value); + self::assertCount(1, $annots); + self::assertEquals(array('foo' => array()), $annots[0]->value); } public function testKeyHasNumber() @@ -1362,8 +1362,8 @@ public function testKeyHasNumber() $parser = $this->createTestParser(); $annots = $parser->parse('@SettingsAnnotation(foo="test", bar2="test")'); - $this->assertCount(1, $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); } /** @@ -1373,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->assertInstanceOf(Name::class, $result[0]); - $this->assertEquals('"bar"', $result[0]->foo); + self::assertInstanceOf(Name::class, $result[0]); + self::assertEquals('"bar"', $result[0]->foo); } /** @@ -1401,7 +1401,7 @@ public function testMultiByteAnnotation() $docParser = $this->createTestParser(); $result = $docParser->parse($docblock); - $this->assertCount(1, $result); + self::assertCount(1, $result); } } diff --git a/tests/Doctrine/Tests/Common/Annotations/FileCacheReaderTest.php b/tests/Doctrine/Tests/Common/Annotations/FileCacheReaderTest.php index 659851d56..d55f147d3 100644 --- a/tests/Doctrine/Tests/Common/Annotations/FileCacheReaderTest.php +++ b/tests/Doctrine/Tests/Common/Annotations/FileCacheReaderTest.php @@ -31,10 +31,10 @@ public function testAttemptToCreateAnnotationCacheDir() { $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/PhpParserTest.php b/tests/Doctrine/Tests/Common/Annotations/PhpParserTest.php index f4200a0b0..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,7 +51,7 @@ public function testParseClassWithGroupUseStatement() public function testParseClassWhenNotUserDefined() { $parser = new PhpParser(); - $this->assertEquals(array(), $parser->parseClass(new \ReflectionClass(\stdClass::class))); + self::assertEquals(array(), $parser->parseClass(new \ReflectionClass(\stdClass::class))); } public function testClassFileDoesNotExist() @@ -65,7 +65,7 @@ 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() @@ -73,7 +73,7 @@ public function testParseClassWhenClassIsNotNamespaced() $parser = new PhpParser(); $class = new ReflectionClass(\AnnotationsTestsFixturesNonNamespacedClass::class); - $this->assertEquals(array( + self::assertEquals(array( 'route' => __NAMESPACE__ . '\Fixtures\Annotation\Route', 'template' => __NAMESPACE__ . '\Fixtures\Annotation\Template', ), $parser->parseClass($class)); @@ -84,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)); } @@ -94,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', @@ -106,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)); @@ -117,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)); @@ -128,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)); @@ -139,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)); } @@ -149,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)); } @@ -159,7 +159,7 @@ public function testGlobalNamespacesPerFileWithClassAsFirst() $parser = new PhpParser(); $class = new \ReflectionClass(\GlobalNamespacesPerFileWithClassAsFirst::class); - $this->assertEquals(array( + self::assertEquals(array( 'secure' => __NAMESPACE__ . '\Fixtures\Annotation\Secure', 'route' => __NAMESPACE__ . '\Fixtures\Annotation\Route', ), $parser->parseClass($class)); @@ -170,7 +170,7 @@ public function testGlobalNamespacesPerFileWithClassAsLast() $parser = new PhpParser(); $class = new ReflectionClass(\GlobalNamespacesPerFileWithClassAsLast::class); - $this->assertEquals(array( + self::assertEquals(array( 'route' => __NAMESPACE__ . '\Fixtures\Annotation\Route', 'template' => __NAMESPACE__ . '\Fixtures\Annotation\Template', ), $parser->parseClass($class)); @@ -181,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', @@ -193,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', @@ -215,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 c266c763f..5f1b73483 100644 --- a/tests/Doctrine/Tests/Common/Annotations/SimpleAnnotationReaderTest.php +++ b/tests/Doctrine/Tests/Common/Annotations/SimpleAnnotationReaderTest.php @@ -78,7 +78,7 @@ public function testInvalidAnnotationUsageButIgnoredClass() $ref = new \ReflectionClass(Fixtures\InvalidAnnotationUsageButIgnoredClass::class); $annots = $reader->getClassAnnotations($ref); - $this->assertCount(1, $annots); + self::assertCount(1, $annots); } public function testIncludeIgnoreAnnotation() @@ -97,10 +97,10 @@ public function testInvalidAnnotationButIgnored() $reader = $this->getReader(); $class = new \ReflectionClass(Fixtures\ClassDDC1660::class); - $this->assertTrue(class_exists(Fixtures\Annotation\Version::class)); - $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 dcd168946..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->assertCount(1, $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->assertEmpty($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 400641965..52c0546f4 100644 --- a/tests/Doctrine/Tests/Common/Annotations/Ticket/DCOM58Test.php +++ b/tests/Doctrine/Tests/Common/Annotations/Ticket/DCOM58Test.php @@ -23,7 +23,7 @@ public function testIssue() $result ); - $this->assertArrayNotHasKey('', $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() @@ -36,8 +36,8 @@ public function testIssueGlobalNamespace() $annots = $parser->parse($docblock); - $this->assertCount(1, $annots); - $this->assertInstanceOf(Doctrine\ORM\Mapping\Entity::class, $annots[0]); + self::assertCount(1, $annots); + self::assertInstanceOf(Doctrine\ORM\Mapping\Entity::class, $annots[0]); } public function testIssueNamespaces() @@ -48,8 +48,8 @@ public function testIssueNamespaces() $annots = $parser->parse($docblock); - $this->assertCount(1, $annots); - $this->assertInstanceOf(Doctrine\ORM\Entity::class, $annots[0]); + self::assertCount(1, $annots); + self::assertInstanceOf(Doctrine\ORM\Entity::class, $annots[0]); } public function testIssueMultipleNamespaces() @@ -61,8 +61,8 @@ public function testIssueMultipleNamespaces() $annots = $parser->parse($docblock); - $this->assertCount(1, $annots); - $this->assertInstanceOf(Doctrine\ORM\Mapping\Entity::class, $annots[0]); + self::assertCount(1, $annots); + self::assertInstanceOf(Doctrine\ORM\Mapping\Entity::class, $annots[0]); } public function testIssueWithNamespacesOrImports() @@ -71,9 +71,9 @@ public function testIssueWithNamespacesOrImports() $parser = new DocParser(); $annots = $parser->parse($docblock); - $this->assertCount(1, $annots); - $this->assertInstanceOf(\Entity::class, $annots[0]); - $this->assertCount(1, $annots); + self::assertCount(1, $annots); + self::assertInstanceOf(\Entity::class, $annots[0]); + self::assertCount(1, $annots); } @@ -83,8 +83,8 @@ public function testIssueSimpleAnnotationReader() $reader->addNamespace('Doctrine\Tests\Common\Annotations\Ticket\Doctrine\ORM\Mapping'); $annots = $reader->getClassAnnotations(new \ReflectionClass(__NAMESPACE__."\MappedClass")); - $this->assertCount(1, $annots); - $this->assertInstanceOf(Doctrine\ORM\Mapping\Entity::class, $annots[0]); + self::assertCount(1, $annots); + self::assertInstanceOf(Doctrine\ORM\Mapping\Entity::class, $annots[0]); } } From 2c0e84ea9c4ae6c8bd6bab4bb1850d467a4432df Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Fri, 30 Dec 2016 16:09:51 +0100 Subject: [PATCH 30/32] EOF EOL --- .../Tests/Common/Annotations/Fixtures/TestInterface.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Doctrine/Tests/Common/Annotations/Fixtures/TestInterface.php b/tests/Doctrine/Tests/Common/Annotations/Fixtures/TestInterface.php index 08c3e10ec..82c272777 100644 --- a/tests/Doctrine/Tests/Common/Annotations/Fixtures/TestInterface.php +++ b/tests/Doctrine/Tests/Common/Annotations/Fixtures/TestInterface.php @@ -10,4 +10,4 @@ interface TestInterface * @Secure */ public function foo(); -} \ No newline at end of file +} From 0393c9c38c6acb714f065d9f480fa0f586619293 Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Fri, 30 Dec 2016 16:10:06 +0100 Subject: [PATCH 31/32] EOF EOL --- .../Common/Annotations/Fixtures/InterfaceWithConstants.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Doctrine/Tests/Common/Annotations/Fixtures/InterfaceWithConstants.php b/tests/Doctrine/Tests/Common/Annotations/Fixtures/InterfaceWithConstants.php index 8b5243ea6..ebb9ff699 100644 --- a/tests/Doctrine/Tests/Common/Annotations/Fixtures/InterfaceWithConstants.php +++ b/tests/Doctrine/Tests/Common/Annotations/Fixtures/InterfaceWithConstants.php @@ -7,4 +7,4 @@ interface InterfaceWithConstants const SOME_VALUE = 'InterfaceWithConstants.SOME_VALUE'; const SOME_KEY = 'InterfaceWithConstants.SOME_KEY'; -} \ No newline at end of file +} From 38bff01928adc7a65a8e38961ff97de829558af8 Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Fri, 30 Dec 2016 16:10:49 +0100 Subject: [PATCH 32/32] CS (spacing) --- .../Tests/Common/Annotations/DocParserTest.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/Doctrine/Tests/Common/Annotations/DocParserTest.php b/tests/Doctrine/Tests/Common/Annotations/DocParserTest.php index 256ab32b4..ea067d405 100644 --- a/tests/Doctrine/Tests/Common/Annotations/DocParserTest.php +++ b/tests/Doctrine/Tests/Common/Annotations/DocParserTest.php @@ -653,7 +653,7 @@ public function testAnnotationWithRequiredAttributes() $docblock = '@Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithRequiredAttributes("Some Value")'; try { - $parser->parse($docblock,$context); + $parser->parse($docblock, $context); $this->fail(); } 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()); @@ -661,7 +661,7 @@ public function testAnnotationWithRequiredAttributes() $docblock = '@Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithRequiredAttributes(annot = @Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAnnotation)'; try { - $parser->parse($docblock,$context); + $parser->parse($docblock, $context); $this->fail(); } 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()); @@ -687,7 +687,7 @@ public function testAnnotationWithRequiredAttributesWithoutConstructor() $docblock = '@Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithRequiredAttributesWithoutConstructor("Some Value")'; try { - $parser->parse($docblock,$context); + $parser->parse($docblock, $context); $this->fail(); } 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()); @@ -695,7 +695,7 @@ public function testAnnotationWithRequiredAttributesWithoutConstructor() $docblock = '@Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithRequiredAttributesWithoutConstructor(annot = @Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAnnotation)'; try { - $parser->parse($docblock,$context); + $parser->parse($docblock, $context); $this->fail(); } 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()); @@ -921,7 +921,7 @@ public function testAnnotationTargetSyntaxError() DOCBLOCK; $parser->setTarget(Target::TARGET_CLASS); - $parser->parse($docblock,$context); + $parser->parse($docblock, $context); } /** @@ -939,7 +939,7 @@ public function testAnnotationWithInvalidTargetDeclarationError() DOCBLOCK; $parser->setTarget(Target::TARGET_CLASS); - $parser->parse($docblock,$context); + $parser->parse($docblock, $context); } /** @@ -957,7 +957,7 @@ public function testAnnotationWithTargetEmptyError() DOCBLOCK; $parser->setTarget(Target::TARGET_CLASS); - $parser->parse($docblock,$context); + $parser->parse($docblock, $context); } /**