Commit 089cc564 authored by Christian Kuhn's avatar Christian Kuhn Committed by Helmut Hummel
Browse files

[TASK] Improve extbase object creation tests

The patch is a follow-up to the "initializeObject() no longer
called after instatiation was fixed" patch with commit ec4f49f6.
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: default avatarStefan Neufeind <typo3.neufeind@speedpartner.de>
Reviewed-by: default avatarHelmut Hummel <helmut.hummel@typo3.org>
Tested-by: default avatarHelmut Hummel <helmut.hummel@typo3.org>
parent d19fdf94
......@@ -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);
}
}
......@@ -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());
}
/**
......
......@@ -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;
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment