[TASK] Nail down php 5.6 instantiation issues in tests 63/40163/3
authorChristian Kuhn <lolli@schwarzbu.ch>
Wed, 10 Jun 2015 14:54:57 +0000 (16:54 +0200)
committerHelmut Hummel <helmut.hummel@typo3.org>
Thu, 11 Jun 2015 10:21:09 +0000 (12:21 +0200)
We know PHP 5.6 has issues in 6.2 in extbase object creation.
The patch adds the unit test from the "instantiator" patch
of issue #66473. This test fails, so travis-ci is configured
with PHP 5.6 as known failure at the moment.

With the instantiator patch applied, initializeObject() was
no longer called in some PHP versions, another test is added
to verify this regression can not show up again.

The test bed currently ensures:
* PHP 5.6 fails with current version
* PHP 5.4, 5.5 and 5.6 would fail if only "instantiator" patch
from #66473 is applied
* PHP 5.3 fails with "initializeObject is called twice" if patch
from #67274 is applied

Later is to get 5.6 green again with no further failure in other
PHP versions with other patches in 6.2 without changing tests.

Resolves: #67408
Related: #66473
Related: #67274
Releases: 6.2
Change-Id: Id4e81877e696dd1abc5b39497a19fa20a702048c
Reviewed-on: http://review.typo3.org/40163
Reviewed-by: Helmut Hummel <helmut.hummel@typo3.org>
Tested-by: Helmut Hummel <helmut.hummel@typo3.org>
.travis.yml
typo3/sysext/extbase/Tests/Unit/Object/Container/ContainerTest.php
typo3/sysext/extbase/Tests/Unit/Object/Container/Fixtures/Testclasses.php

index e6746e1..83adac2 100644 (file)
@@ -1,12 +1,14 @@
 language: php
 
 matrix:
+  allow_failures:
+    - php: 5.6
   include:
     - php: 5.3
     - php: 5.4
     - php: 5.5
-    - php: 5.6
       env: SUBMODULE_TEST=yes
+    - php: 5.6
 
 services:
   - memcached
index 02303dd..10bb762 100644 (file)
@@ -202,6 +202,22 @@ class ContainerTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
        /**
         * @test
         */
+       public function getEmptyObjectInitializesObjects() {
+               $object = $this->container->getEmptyObject('t3lib_object_tests_initializable');
+               $this->assertTrue($object->isInitialized());
+       }
+
+       /**
+        * @test
+        */
+       public function getEmptyObjectReturnsInstanceOfClassImplementingSerializable() {
+               $object = $this->container->getEmptyObject('t3lib_object_tests_serializable');
+               $this->assertInstanceOf('t3lib_object_tests_serializable', $object);
+       }
+
+       /**
+        * @test
+        */
        public function test_canGetChildClass() {
                $object = $this->container->getInstance('t3lib_object_tests_b_child');
                $this->assertInstanceOf('t3lib_object_tests_b_child', $object);
index 28ed4ed..8d3040b 100644 (file)
@@ -131,6 +131,14 @@ interface t3lib_object_tests_someinterface extends \TYPO3\CMS\Core\SingletonInte
 }
 
 /**
+ * Test class D implementing Serializable
+ */
+class t3lib_object_tests_serializable implements \Serializable {
+       public function serialize() {}
+       public function unserialize($s) {}
+}
+
+/**
  * class which implements a Interface
  */
 class t3lib_object_tests_someimplementation implements \t3lib_object_tests_someinterface {
@@ -467,3 +475,28 @@ class t3lib_object_prototypeNeedsSingletonInConstructor {
                $this->dependency = $dependency;
        }
 }
+
+/**
+ * Class that needs initialization after instantiation
+ */
+class t3lib_object_tests_initializable extends \TYPO3\CMS\Extbase\DomainObject\AbstractDomainObject {
+       /**
+        * @var bool
+        */
+       protected $initialized = FALSE;
+
+       public function initializeObject() {
+               if ($this->initialized) {
+                       throw new \Exception('initializeObject was called a second time', 1433944932);
+               }
+               $this->initialized = TRUE;
+       }
+
+       /**
+        * @return boolean
+        */
+       public function isInitialized() {
+               return $this->initialized;
+       }
+
+}