[BUGFIX] Extbase container injection test triggers PHP bug 19/27219/2
authorChristian Kuhn <lolli@schwarzbu.ch>
Fri, 31 Jan 2014 20:27:08 +0000 (21:27 +0100)
committerChristian Kuhn <lolli@schwarzbu.ch>
Fri, 31 Jan 2014 21:02:43 +0000 (22:02 +0100)
PHP's reflection behaves differently in an edge case used in
extbase constructor injection.
The patch removes the specific check from tests and adds
documentation of this case.

Change-Id: I8ff5ce0d87a28f93ae6be0fd5778289cc9cab7aa
Resolves: #55538
Related: #52349
Releases: 6.2
Reviewed-on: https://review.typo3.org/27219
Reviewed-by: Anja Leichsenring
Tested-by: Anja Leichsenring
Reviewed-by: Wouter Wolters
Tested-by: Wouter Wolters
Reviewed-by: Christian Kuhn
Tested-by: Christian Kuhn
typo3/sysext/extbase/Tests/Unit/Object/Container/ContainerTest.php
typo3/sysext/extbase/Tests/Unit/Object/Container/Fixtures/ContainerConstructorInjectionTestFixtures.php

index c7b23ad..6599894 100644 (file)
@@ -655,26 +655,6 @@ class ContainerTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase {
                $this->assertNull($object->argumentTestClassTwo);
        }
 
-       /**
-        * test class TwoConstructorArgumentsFirstOptional
-        *
-        * @test
-        */
-       public function getInstanceOnFirstOptionalAndSecondMandatoryInjectsOnlySecondArgumentAndFirstArgumentIsNullIfNoArgumentsGiven() {
-               $object = $this->container->getInstance(
-                       'TYPO3\\CMS\\Extbase\\Tests\\Unit\\Object\\Container\\Fixtures\\TwoConstructorArgumentsFirstOptional'
-               );
-               $this->assertInstanceOf(
-                       'TYPO3\\CMS\\Extbase\\Tests\\Unit\\Object\\Container\\Fixtures\\TwoConstructorArgumentsFirstOptional',
-                       $object
-               );
-               $this->assertNull($object->argumentTestClass);
-               $this->assertInstanceOf(
-                       'TYPO3\\CMS\\Extbase\\Tests\\Unit\\Object\\Container\\Fixtures\\ArgumentTestClass',
-                       $object->argumentTestClassTwo
-               );
-       }
-
        /**
         * test class TwoConstructorArgumentsFirstOptional
         *
@@ -689,7 +669,6 @@ class ContainerTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase {
                        'TYPO3\\CMS\\Extbase\\Tests\\Unit\\Object\\Container\\Fixtures\\TwoConstructorArgumentsFirstOptional',
                        $object
                );
-               $this->assertNull($object->argumentTestClass);
                $this->assertInstanceOf(
                        'TYPO3\\CMS\\Extbase\\Tests\\Unit\\Object\\Container\\Fixtures\\ArgumentTestClass',
                        $object->argumentTestClassTwo
@@ -764,7 +743,6 @@ class ContainerTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase {
                        'TYPO3\\CMS\\Extbase\\Tests\\Unit\\Object\\Container\\Fixtures\\TwoConstructorArgumentsFirstOptional',
                        $object
                );
-               $this->assertNull($object->argumentTestClass);
                $this->assertSame(
                        $second,
                        $object->argumentTestClassTwo
@@ -785,7 +763,6 @@ class ContainerTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase {
                        'TYPO3\\CMS\\Extbase\\Tests\\Unit\\Object\\Container\\Fixtures\\TwoConstructorArgumentsFirstOptional',
                        $object
                );
-               $this->assertNull($object->argumentTestClass);
                $this->assertInstanceOf(
                        'TYPO3\\CMS\\Extbase\\Tests\\Unit\\Object\\Container\\Fixtures\\ArgumentTestClass',
                        $object->argumentTestClassTwo
index 62c2f18..fc77d4e 100644 (file)
@@ -117,8 +117,13 @@ class TwoConstructorArgumentsFirstOptional {
        public $argumentTestClassTwo;
 
        /**
-        * This can not be handled correctly at the moment since the underlying
-        * reflection API of PHP marks the first parameter as required!
+        * The extbase container code uses PHP parameter reflection isOptional() to determine
+        * injection. PHP behaves differently in current supported core versions, in effect
+        * constructor injection of the first argument can not be relied on.
+        *
+        * The according unit tests currently do not check the value of first argument.
+        *
+        * @see https://bugs.php.net/bug.php?id=62715
         *
         * @param ArgumentTestClass $argumentTestClass
         * @param ArgumentTestClass $argumentTestClassTwo