[TASK] Improve extbase object creation tests 61/40161/2
authorChristian Kuhn <lolli@schwarzbu.ch>
Wed, 10 Jun 2015 22:17:36 +0000 (00:17 +0200)
committerHelmut Hummel <helmut.hummel@typo3.org>
Thu, 11 Jun 2015 10:13:31 +0000 (12:13 +0200)
The patch is a follow-up to the "initializeObject() no longer
called after instatiation was fixed" patch with commit ec4f49f69f.
It makes the tests a bit more picky and does some minor cleanups.

Patch is for master only, 6.2 will receive different patch sets.

Resolves: #67407
Related: #67272
Releases: master
Change-Id: Iee371a6a62d66613b35623af55ac5ca4595eb947
Reviewed-on: http://review.typo3.org/40161
Reviewed-by: Stefan Neufeind <typo3.neufeind@speedpartner.de>
Reviewed-by: Helmut Hummel <helmut.hummel@typo3.org>
Tested-by: Helmut Hummel <helmut.hummel@typo3.org>
typo3/sysext/extbase/Classes/Object/Container/Container.php
typo3/sysext/extbase/Tests/Unit/Object/Container/ContainerTest.php
typo3/sysext/extbase/Tests/Unit/Object/Container/Fixtures/Testclasses.php

index 6d6441c..8d9147e 100644 (file)
@@ -242,7 +242,7 @@ class Container implements \TYPO3\CMS\Core\SingletonInterface {
        }
 
        /**
-        * Initialize $instance after injecting all dependencies
+        * Call object initializer if present in object
         *
         * @param object $instance
         * @param \TYPO3\CMS\Extbase\Object\Container\ClassInfo $classInfo
@@ -358,4 +358,5 @@ class Container implements \TYPO3\CMS\Core\SingletonInterface {
        public function isPrototype($className) {
                return !$this->isSingleton($className);
        }
+
 }
index 9eadf13..9670bbb 100644 (file)
@@ -185,7 +185,7 @@ class ContainerTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
         */
        public function getInstanceInitializesObjects() {
                $instance = $this->container->getInstance('t3lib_object_tests_initializable');
-               $this->assertTrue($instance->isInitialized(), 't3lib_object_tests_initializable was not completely initialized');
+               $this->assertTrue($instance->isInitialized());
        }
 
        /**
@@ -220,7 +220,7 @@ class ContainerTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
         */
        public function getEmptyObjectInitializesObjects() {
                $object = $this->container->getEmptyObject('t3lib_object_tests_initializable');
-               $this->assertTrue($object->isInitialized(), 't3lib_object_tests_initializable was not completely initialized');
+               $this->assertTrue($object->isInitialized());
        }
 
        /**
index ee37cf3..1c75ea6 100644 (file)
@@ -480,13 +480,16 @@ class t3lib_object_prototypeNeedsSingletonInConstructor {
 /**
  * Class that needs initialization after instantiation
  */
-class t3lib_object_tests_initializable {
+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;
        }
 
@@ -496,4 +499,5 @@ class t3lib_object_tests_initializable {
        public function isInitialized() {
                return $this->initialized;
        }
+
 }