[+BUGFIX] Extbase (Tests): tweaked ObjectContainer tests. Tests are failing deliberat...
authorBastian Waidelich <bastian@typo3.org>
Tue, 30 Nov 2010 12:02:39 +0000 (12:02 +0000)
committerBastian Waidelich <bastian@typo3.org>
Tue, 30 Nov 2010 12:02:39 +0000 (12:02 +0000)
The DI implementation has to be rewritten, as discussed.

This relates to: #11160

typo3/sysext/extbase/Tests/Unit/Object/Container/ContainerTest.php
typo3/sysext/extbase/Tests/Unit/Object/Container/Fixtures/Testclasses.php

index c5a78dd..804bd9b 100644 (file)
@@ -52,9 +52,10 @@ class Tx_Extbase_Object_Container_ContainerTest extends Tx_Extbase_Tests_Unit_Ba
        /**
         * @test
         */
-       public function getInstanceReturnsInstanceOfAClassWithDependency() {
+       public function getInstanceReturnsInstanceOfAClassWithConstructorInjection() {
                $object = $this->container->getInstance('t3lib_object_tests_b');
                $this->assertType('t3lib_object_tests_b', $object);
+               $this->assertType('t3lib_object_tests_c', $object->c);
        }
 
        /**
@@ -63,22 +64,24 @@ class Tx_Extbase_Object_Container_ContainerTest extends Tx_Extbase_Tests_Unit_Ba
        public function getInstanceReturnsInstanceOfAClassWithTwoLevelDependency() {
                $object = $this->container->getInstance('t3lib_object_tests_a');
                $this->assertType('t3lib_object_tests_a', $object);
+               $this->assertType('t3lib_object_tests_c', $object->b->c);
        }
 
        /**
         * @test
         */
-       public function getInstanceReturnsInstanceOfAClassWithTwoLevelMixedArrayDependency() {
+       public function getInstanceReturnsInstanceOfAClassWithMixedSimpleTypeAndConstructorInjection() {
                $object = $this->container->getInstance('t3lib_object_tests_amixed_array');
                $this->assertType('t3lib_object_tests_amixed_array', $object);
+               $this->assertEquals(array('some' => 'default'), $object->myvalue);
        }
 
        /**
         * @test
+        * @expectedException Tx_Extbase_Object_Exception
         */
-       public function getInstanceReturnsInstanceOfAClassWithTwoLevelMixedStringDependency() {
-               $object = $this->container->getInstance('t3lib_object_tests_amixed_string');
-               $this->assertType('t3lib_object_tests_amixed_string', $object);
+       public function getInstanceThrowsExceptionWhenTryingToInstanciateASingletonWithConstructorParameters() {
+               $this->container->getInstance('t3lib_object_tests_amixed_array_singleton');
        }
 
        /**
@@ -114,7 +117,7 @@ class Tx_Extbase_Object_Container_ContainerTest extends Tx_Extbase_Tests_Unit_Ba
 
        /**
         * @test
-        * @expectedException Exception
+        * @expectedException Tx_Extbase_Object_Exception
         */
        public function getInstanceThrowsExceptionIfObjectContainsCyclicDependency() {
                $this->container->getInstance('t3lib_object_tests_cyclic1');
@@ -123,7 +126,7 @@ class Tx_Extbase_Object_Container_ContainerTest extends Tx_Extbase_Tests_Unit_Ba
 
        /**
         * @test
-        * @expectedException Exception
+        * @expectedException Tx_Extbase_Object_Exception
         */
        public function getInstanceThrowsExceptionIfClassWasNotFound() {
                $this->container->getInstance('nonextistingclass_bla');
@@ -153,7 +156,7 @@ class Tx_Extbase_Object_Container_ContainerTest extends Tx_Extbase_Tests_Unit_Ba
        public function test_canBuildCyclicDependenciesWithSetter() {
                $object = $this->container->getInstance('t3lib_object_tests_resolveablecyclic1');
                $this->assertType('t3lib_object_tests_resolveablecyclic1', $object);
-               $this->assertType('t3lib_object_tests_resolveablecyclic1', $object->o->o);
+               $this->assertType('t3lib_object_tests_resolveablecyclic1', $object->o2->o3->o1);
        }
 
 
index 6f09a01..fce57cf 100644 (file)
@@ -25,27 +25,40 @@ class t3lib_object_tests_a {
  * test class A that depends on B and C and has a third default parameter in constructor
  *
  */
-class t3lib_object_tests_amixed_array implements t3lib_Singleton {
-       public function __construct(t3lib_object_tests_b $b, t3lib_object_tests_c $c, array $myvalue=array()) {
-
+class t3lib_object_tests_amixed_array {
+       public $b;
+       public $c;
+       public $myvalue;
+       public function __construct(t3lib_object_tests_b $b, t3lib_object_tests_c $c, array $myvalue=array('some' => 'default')) {
+               $this->b = $b;
+               $this->c = $c;
+               $this->myvalue = $myvalue;
        }
 }
+
 /**
  * test class A that depends on B and C and has a third default parameter in constructor
  *
  */
-class t3lib_object_tests_amixed_string implements t3lib_Singleton {
-       public function __construct(t3lib_object_tests_b $b, t3lib_object_tests_c $c, $myvalue='test') {
-
+class t3lib_object_tests_amixed_array_singleton implements t3lib_Singleton {
+       public $b;
+       public $c;
+       public $myvalue;
+       public function __construct(t3lib_object_tests_b $b, t3lib_object_tests_c $c, array $myvalue=array('some' => 'default')) {
+               $this->b = $b;
+               $this->c = $c;
+               $this->myvalue = $myvalue;
        }
 }
+
 /**
  * test class B that depends on C
  *
  */
 class t3lib_object_tests_b implements t3lib_Singleton {
+       public $c;
        public function __construct(t3lib_object_tests_c $c) {
-
+               $this->c = $c;
        }
 }
 
@@ -146,9 +159,9 @@ class t3lib_object_tests_injectsettings {
  *
  */
 class t3lib_object_tests_resolveablecyclic1 implements t3lib_Singleton {
-       public $o;
+       public $o2;
        public function __construct(t3lib_object_tests_resolveablecyclic2 $cyclic2) {
-               $this->o = $cyclic2;
+               $this->o2 = $cyclic2;
        }
 }
 
@@ -157,9 +170,24 @@ class t3lib_object_tests_resolveablecyclic1 implements t3lib_Singleton {
  *
  */
 class t3lib_object_tests_resolveablecyclic2 implements t3lib_Singleton {
-       public $o;
-       public function injectCyclic1(t3lib_object_tests_resolveablecyclic1 $o) {
-               $this->o = $o;
+       public $o1;
+       public $o3;
+       public function injectCyclic1(t3lib_object_tests_resolveablecyclic1 $cyclic1) {
+               $this->o1 = $cyclic1;
+       }
+       public function injectCyclic3(t3lib_object_tests_resolveablecyclic3 $cyclic3) {
+               $this->o3 = $cyclic3;
+       }
+}
+
+/**
+ *
+ *
+ */
+class t3lib_object_tests_resolveablecyclic3 implements t3lib_Singleton {
+       public $o1;
+       public function injectCyclic1(t3lib_object_tests_resolveablecyclic1 $cyclic1) {
+               $this->o1 = $cyclic1;
        }
 }