TYPO3 CMS  TYPO3_6-2
ContainerTest.php
Go to the documentation of this file.
1 <?php
3 
17 require_once 'Fixtures/Testclasses.php';
18 require_once 'Fixtures/ContainerConstructorInjectionTestFixtures.php';
19 
24 
28  protected $container;
29 
33  protected $cachedClassInfo;
34 
35  public function setUp() {
36  // The mocked cache will always indicate that he has nothing in the cache to force that we get the real class info
37  $mockedCache = $this->getMock('TYPO3\\CMS\\Extbase\\Object\\Container\\ClassInfoCache', array('get', 'set'));
38  $mockedCache->expects($this->any())->method('get')->will($this->returnValue(FALSE));
39  $mockedCache->expects($this->never())->method('has');
40  $this->container = $this->getMock('TYPO3\\CMS\\Extbase\\Object\\Container\\Container', array('log', 'getClassInfoCache'));
41  $this->container->expects($this->any())->method('getClassInfoCache')->will($this->returnValue($mockedCache));
42  }
43 
48  $object = $this->container->getInstance('t3lib_object_tests_c');
49  $this->assertInstanceOf('t3lib_object_tests_c', $object);
50  }
51 
56  $object = $this->container->getInstance('TYPO3\\CMS\\Extbase\\Tests\\Unit\\Object\\Container\\Fixtures\\NamespacedClass');
57  $this->assertInstanceOf('TYPO3\\CMS\\Extbase\\Tests\\Unit\\Object\\Container\\Fixtures\\NamespacedClass', $object);
58  }
59 
64  $object = $this->container->getInstance('t3lib_object_tests_b');
65  $this->assertInstanceOf('t3lib_object_tests_b', $object);
66  $this->assertInstanceOf('t3lib_object_tests_c', $object->c);
67  }
68 
73  $object = $this->container->getInstance('t3lib_object_tests_a');
74  $this->assertInstanceOf('t3lib_object_tests_a', $object);
75  $this->assertInstanceOf('t3lib_object_tests_c', $object->b->c);
76  }
77 
82  $object = $this->container->getInstance('t3lib_object_tests_amixed_array');
83  $this->assertInstanceOf('t3lib_object_tests_amixed_array', $object);
84  $this->assertEquals(array('some' => 'default'), $object->myvalue);
85  }
86 
91  $object = $this->container->getInstance('t3lib_object_tests_amixed_null');
92  $this->assertInstanceOf('t3lib_object_tests_amixed_null', $object);
93  $this->assertNull($object->myvalue);
94  }
95 
101  $this->container->getInstance('t3lib_object_tests_amixed_array_singleton', array('somevalue'));
102  }
103 
108  $object = $this->container->getInstance('t3lib_object_tests_amixed_array');
109  $this->assertInstanceOf('t3lib_object_tests_b', $object->b);
110  $this->assertInstanceOf('t3lib_object_tests_c', $object->c);
111  $this->assertEquals(array('some' => 'default'), $object->myvalue);
112  }
113 
118  $mockObject = $this->getMock('t3lib_object_tests_c');
119  $object = $this->container->getInstance('t3lib_object_tests_a', array($mockObject));
120  $this->assertInstanceOf('t3lib_object_tests_a', $object);
121  $this->assertSame($mockObject, $object->c);
122  }
123 
128  $object1 = $this->container->getInstance('t3lib_object_tests_a');
129  $object2 = $this->container->getInstance('t3lib_object_tests_a');
130  $this->assertNotSame($object1, $object2);
131  }
132 
137  $object1 = $this->container->getInstance('t3lib_object_tests_singleton');
138  $object2 = $this->container->getInstance('t3lib_object_tests_singleton');
139  $this->assertSame($object1, $object2);
140  }
141 
147  $this->container->getInstance('t3lib_object_tests_cyclic1WithSetterDependency');
148  }
149 
155  $this->container->getInstance('t3lib_object_tests_cyclic1');
156  }
157 
163  $this->container->getInstance('nonextistingclass_bla');
164  }
165 
170  $className = 'TYPO3\\CMS\\Extbase\\Tests\\Unit\\Object\\Container\\Fixtures\\NamespacedClass';
171  $classNameHash = md5($className);
172  $mockedCache = $this->getMock('TYPO3\\CMS\\Extbase\\Object\\Container\\ClassInfoCache', array('has', 'set', 'get'));
173  $container = $this->getMock('TYPO3\\CMS\\Extbase\\Object\\Container\\Container', array('log', 'getClassInfoCache'));
174  $container->expects($this->any())->method('getClassInfoCache')->will($this->returnValue($mockedCache));
175  $mockedCache->expects($this->never())->method('has');
176  $mockedCache->expects($this->once())->method('get')->with($classNameHash)->will($this->returnValue(FALSE));
177  $mockedCache->expects($this->once())->method('set')->with($classNameHash, $this->anything())->will($this->returnCallback(array($this, 'setClassInfoCacheCallback')));
178  $container->getInstance($className);
179  $this->assertInstanceOf('TYPO3\\CMS\\Extbase\\Object\\Container\\ClassInfo', $this->cachedClassInfo);
180  $this->assertEquals($className, $this->cachedClassInfo->getClassName());
181  }
182 
190  public function setClassInfoCacheCallback($id, \TYPO3\CMS\Extbase\Object\Container\ClassInfo $value) {
191  $this->cachedClassInfo = $value;
192  }
193 
198  $object = $this->container->getEmptyObject('t3lib_object_tests_c');
199  $this->assertInstanceOf('t3lib_object_tests_c', $object);
200  }
201 
206  $object = $this->container->getEmptyObject('t3lib_object_tests_initializable');
207  $this->assertTrue($object->isInitialized());
208  }
209 
214  $object = $this->container->getEmptyObject('t3lib_object_tests_serializable');
215  $this->assertInstanceOf('t3lib_object_tests_serializable', $object);
216  }
217 
221  public function test_canGetChildClass() {
222  $object = $this->container->getInstance('t3lib_object_tests_b_child');
223  $this->assertInstanceOf('t3lib_object_tests_b_child', $object);
224  }
225 
229  public function test_canInjectInterfaceInClass() {
230  $this->container->registerImplementation('t3lib_object_tests_someinterface', 't3lib_object_tests_someimplementation');
231  $object = $this->container->getInstance('t3lib_object_tests_needsinterface');
232  $this->assertInstanceOf('t3lib_object_tests_needsinterface', $object);
233  $this->assertInstanceOf('t3lib_object_tests_someinterface', $object->dependency);
234  $this->assertInstanceOf('t3lib_object_tests_someimplementation', $object->dependency);
235  }
236 
241  $object = $this->container->getInstance('t3lib_object_tests_resolveablecyclic1');
242  $this->assertInstanceOf('t3lib_object_tests_resolveablecyclic1', $object);
243  $this->assertInstanceOf('t3lib_object_tests_resolveablecyclic1', $object->o2->o3->o1);
244  }
245 
250  $this->container->expects($this->once())->method('log')->with('The singleton "t3lib_object_singletonNeedsPrototype" needs a prototype in "injectDependency". This is often a bad code smell; often you rather want to inject a singleton.', 1);
251  $object = $this->container->getInstance('t3lib_object_singletonNeedsPrototype');
252  $this->assertInstanceOf('t3lib_object_prototype', $object->dependency);
253  }
254 
259  $this->container->expects($this->never())->method('log');
260  $object = $this->container->getInstance('t3lib_object_singletonNeedsSingleton');
261  $this->assertInstanceOf('t3lib_object_singleton', $object->dependency);
262  }
263 
268  $this->container->expects($this->never())->method('log');
269  $object = $this->container->getInstance('t3lib_object_prototypeNeedsPrototype');
270  $this->assertInstanceOf('t3lib_object_prototype', $object->dependency);
271  }
272 
277  $this->container->expects($this->never())->method('log');
278  $object = $this->container->getInstance('t3lib_object_prototypeNeedsSingleton');
279  $this->assertInstanceOf('t3lib_object_singleton', $object->dependency);
280  }
281 
286  $this->container->expects($this->once())->method('log')->with('The singleton "t3lib_object_singletonNeedsPrototypeInConstructor" needs a prototype in the constructor. This is often a bad code smell; often you rather want to inject a singleton.', 1);
287  $object = $this->container->getInstance('t3lib_object_singletonNeedsPrototypeInConstructor');
288  $this->assertInstanceOf('t3lib_object_prototype', $object->dependency);
289  }
290 
295  $this->container->expects($this->never())->method('log');
296  $object = $this->container->getInstance('t3lib_object_singletonNeedsSingletonInConstructor');
297  $this->assertInstanceOf('t3lib_object_singleton', $object->dependency);
298  }
299 
304  $this->container->expects($this->never())->method('log');
305  $object = $this->container->getInstance('t3lib_object_prototypeNeedsPrototypeInConstructor');
306  $this->assertInstanceOf('t3lib_object_prototype', $object->dependency);
307  }
308 
313  $this->container->expects($this->never())->method('log');
314  $object = $this->container->getInstance('t3lib_object_prototypeNeedsSingletonInConstructor');
315  $this->assertInstanceOf('t3lib_object_singleton', $object->dependency);
316  }
317 
322  $this->assertTrue($this->container->isSingleton('TYPO3\CMS\Extbase\Object\Container\Container'));
323  $this->assertFalse($this->container->isSingleton('TYPO3\CMS\Extbase\Core\Bootstrap'));
324  }
325 
330  $this->assertFalse($this->container->isPrototype('TYPO3\CMS\Extbase\Object\Container\Container'));
331  $this->assertTrue($this->container->isPrototype('TYPO3\CMS\Extbase\Core\Bootstrap'));
332  }
333 
334  /************************************************
335  * Test regarding constructor argument injection
336  ************************************************/
337 
343  $object = $this->container->getInstance(
344  'TYPO3\\CMS\\Extbase\\Tests\\Unit\\Object\\Container\\Fixtures\\SimpleTypeConstructorArgument',
345  array(TRUE)
346  );
347  $this->assertTrue($object->foo);
348  }
349 
355  $object = $this->container->getInstance(
356  'TYPO3\\CMS\\Extbase\\Tests\\Unit\\Object\\Container\\Fixtures\\SimpleTypeConstructorArgument'
357  );
358  $this->assertFalse($object->foo);
359  }
360 
366  $argumentTestClass = new Fixtures\ArgumentTestClass();
367  $object = $this->container->getInstance(
368  'TYPO3\\CMS\\Extbase\\Tests\\Unit\\Object\\Container\\Fixtures\\MandatoryConstructorArgument',
369  array($argumentTestClass)
370  );
371  $this->assertInstanceOf(
372  'TYPO3\\CMS\\Extbase\\Tests\\Unit\\Object\\Container\\Fixtures\\MandatoryConstructorArgument',
373  $object
374  );
375  $this->assertSame($argumentTestClass, $object->argumentTestClass);
376  }
377 
383  $object = $this->container->getInstance(
384  'TYPO3\\CMS\\Extbase\\Tests\\Unit\\Object\\Container\\Fixtures\\MandatoryConstructorArgument'
385  );
386  $this->assertInstanceOf(
387  'TYPO3\\CMS\\Extbase\\Tests\\Unit\\Object\\Container\\Fixtures\\MandatoryConstructorArgument',
388  $object
389  );
390  $this->assertInstanceOf(
391  'TYPO3\\CMS\\Extbase\\Tests\\Unit\\Object\\Container\\Fixtures\\ArgumentTestClass',
392  $object->argumentTestClass
393  );
394  }
395 
401  $object = $this->container->getInstance(
402  'TYPO3\\CMS\\Extbase\\Tests\\Unit\\Object\\Container\\Fixtures\\OptionalConstructorArgument'
403  );
404  $this->assertInstanceOf(
405  'TYPO3\\CMS\\Extbase\\Tests\\Unit\\Object\\Container\\Fixtures\\OptionalConstructorArgument',
406  $object
407  );
408  $this->assertNull($object->argumentTestClass);
409  }
410 
416  $object = $this->container->getInstance(
417  'TYPO3\\CMS\\Extbase\\Tests\\Unit\\Object\\Container\\Fixtures\\OptionalConstructorArgument',
418  array(NULL)
419  );
420  $this->assertInstanceOf(
421  'TYPO3\\CMS\\Extbase\\Tests\\Unit\\Object\\Container\\Fixtures\\OptionalConstructorArgument',
422  $object
423  );
424  $this->assertNull($object->argumentTestClass);
425  }
426 
432  $argumentTestClass = new Fixtures\ArgumentTestClass();
433  $object = $this->container->getInstance(
434  'TYPO3\\CMS\\Extbase\\Tests\\Unit\\Object\\Container\\Fixtures\\OptionalConstructorArgument',
435  array($argumentTestClass)
436  );
437  $this->assertInstanceOf(
438  'TYPO3\\CMS\\Extbase\\Tests\\Unit\\Object\\Container\\Fixtures\\OptionalConstructorArgument',
439  $object
440  );
441  $this->assertSame($argumentTestClass, $object->argumentTestClass);
442  }
443 
449  $firstArgument = new Fixtures\ArgumentTestClass();
450  $secondArgument = new Fixtures\ArgumentTestClass();
451  $object = $this->container->getInstance(
452  'TYPO3\\CMS\\Extbase\\Tests\\Unit\\Object\\Container\\Fixtures\\MandatoryConstructorArgumentTwo',
453  array($firstArgument, $secondArgument)
454  );
455  $this->assertInstanceOf(
456  'TYPO3\\CMS\\Extbase\\Tests\\Unit\\Object\\Container\\Fixtures\\MandatoryConstructorArgumentTwo',
457  $object
458  );
459  $this->assertSame(
460  $firstArgument,
461  $object->argumentTestClass
462  );
463  $this->assertSame(
464  $secondArgument,
465  $object->argumentTestClassTwo
466  );
467  }
468 
474  $object = $this->container->getInstance(
475  'TYPO3\\CMS\\Extbase\\Tests\\Unit\\Object\\Container\\Fixtures\\MandatoryConstructorArgumentTwo'
476  );
477  $this->assertInstanceOf(
478  'TYPO3\\CMS\\Extbase\\Tests\\Unit\\Object\\Container\\Fixtures\\MandatoryConstructorArgumentTwo',
479  $object
480  );
481  $this->assertInstanceOf(
482  'TYPO3\\CMS\\Extbase\\Tests\\Unit\\Object\\Container\\Fixtures\\ArgumentTestClass',
483  $object->argumentTestClass
484  );
485  $this->assertInstanceOf(
486  'TYPO3\\CMS\\Extbase\\Tests\\Unit\\Object\\Container\\Fixtures\\ArgumentTestClass',
487  $object->argumentTestClassTwo
488  );
489  $this->assertNotSame(
490  $object->argumentTestClass,
491  $object->argumentTestClassTwo
492  );
493  }
494 
500  $firstArgument = new Fixtures\ArgumentTestClass();
501  $object = $this->container->getInstance(
502  'TYPO3\\CMS\\Extbase\\Tests\\Unit\\Object\\Container\\Fixtures\\MandatoryConstructorArgumentTwo',
503  array($firstArgument)
504  );
505  $this->assertInstanceOf(
506  'TYPO3\\CMS\\Extbase\\Tests\\Unit\\Object\\Container\\Fixtures\\MandatoryConstructorArgumentTwo',
507  $object
508  );
509  $this->assertSame(
510  $firstArgument,
511  $object->argumentTestClass
512  );
513  $this->assertInstanceOf(
514  'TYPO3\\CMS\\Extbase\\Tests\\Unit\\Object\\Container\\Fixtures\\ArgumentTestClass',
515  $object->argumentTestClassTwo
516  );
517  $this->assertNotSame(
518  $object->argumentTestClass,
519  $object->argumentTestClassTwo
520  );
521  }
522 
528  $secondArgument = new Fixtures\ArgumentTestClass();
529  $object = $this->container->getInstance(
530  'TYPO3\\CMS\\Extbase\\Tests\\Unit\\Object\\Container\\Fixtures\\MandatoryConstructorArgumentTwo',
531  array(NULL, $secondArgument)
532  );
533  $this->assertInstanceOf(
534  'TYPO3\\CMS\\Extbase\\Tests\\Unit\\Object\\Container\\Fixtures\\MandatoryConstructorArgumentTwo',
535  $object
536  );
537  $this->assertInstanceOf(
538  'TYPO3\\CMS\\Extbase\\Tests\\Unit\\Object\\Container\\Fixtures\\ArgumentTestClass',
539  $object->argumentTestClass
540  );
541  $this->assertInstanceOf(
542  'TYPO3\\CMS\\Extbase\\Tests\\Unit\\Object\\Container\\Fixtures\\ArgumentTestClass',
543  $object->argumentTestClassTwo
544  );
545  $this->assertSame(
546  $secondArgument,
547  $object->argumentTestClassTwo
548  );
549  $this->assertNotSame(
550  $object->argumentTestClass,
551  $object->argumentTestClassTwo
552  );
553  }
554 
560  $firstArgument = new Fixtures\ArgumentTestClass();
561  $secondArgument = new Fixtures\ArgumentTestClass();
562  $object = $this->container->getInstance(
563  'TYPO3\\CMS\\Extbase\\Tests\\Unit\\Object\\Container\\Fixtures\\TwoConstructorArgumentsSecondOptional',
564  array($firstArgument, $secondArgument)
565  );
566  $this->assertInstanceOf(
567  'TYPO3\\CMS\\Extbase\\Tests\\Unit\\Object\\Container\\Fixtures\\TwoConstructorArgumentsSecondOptional',
568  $object
569  );
570  $this->assertSame(
571  $firstArgument,
572  $object->argumentTestClass
573  );
574  $this->assertSame(
575  $secondArgument,
576  $object->argumentTestClassTwo
577  );
578  }
579 
585  $object = $this->container->getInstance(
586  'TYPO3\\CMS\\Extbase\\Tests\\Unit\\Object\\Container\\Fixtures\\TwoConstructorArgumentsSecondOptional'
587  );
588  $this->assertInstanceOf(
589  'TYPO3\\CMS\\Extbase\\Tests\\Unit\\Object\\Container\\Fixtures\\TwoConstructorArgumentsSecondOptional',
590  $object
591  );
592  $this->assertInstanceOf(
593  'TYPO3\\CMS\\Extbase\\Tests\\Unit\\Object\\Container\\Fixtures\\ArgumentTestClass',
594  $object->argumentTestClass
595  );
596  $this->assertNull($object->argumentTestClassTwo);
597  }
598 
604  $object = $this->container->getInstance(
605  'TYPO3\\CMS\\Extbase\\Tests\\Unit\\Object\\Container\\Fixtures\\TwoConstructorArgumentsSecondOptional',
606  array(NULL, NULL)
607  );
608  $this->assertInstanceOf(
609  'TYPO3\\CMS\\Extbase\\Tests\\Unit\\Object\\Container\\Fixtures\\TwoConstructorArgumentsSecondOptional',
610  $object
611  );
612  $this->assertInstanceOf(
613  'TYPO3\\CMS\\Extbase\\Tests\\Unit\\Object\\Container\\Fixtures\\ArgumentTestClass',
614  $object->argumentTestClass
615  );
616  $this->assertNull($object->argumentTestClassTwo);
617  }
618 
624  $firstArgument = new Fixtures\ArgumentTestClass();
625  $object = $this->container->getInstance(
626  'TYPO3\\CMS\\Extbase\\Tests\\Unit\\Object\\Container\\Fixtures\\TwoConstructorArgumentsSecondOptional',
627  array($firstArgument)
628  );
629  $this->assertInstanceOf(
630  'TYPO3\\CMS\\Extbase\\Tests\\Unit\\Object\\Container\\Fixtures\\TwoConstructorArgumentsSecondOptional',
631  $object
632  );
633  $this->assertSame(
634  $firstArgument,
635  $object->argumentTestClass
636  );
637  $this->assertNull($object->argumentTestClassTwo);
638  }
639 
645  $firstArgument = new Fixtures\ArgumentTestClass();
646  $object = $this->container->getInstance(
647  'TYPO3\\CMS\\Extbase\\Tests\\Unit\\Object\\Container\\Fixtures\\TwoConstructorArgumentsSecondOptional',
648  array($firstArgument, NULL)
649  );
650  $this->assertInstanceOf(
651  'TYPO3\\CMS\\Extbase\\Tests\\Unit\\Object\\Container\\Fixtures\\TwoConstructorArgumentsSecondOptional',
652  $object
653  );
654  $this->assertSame(
655  $firstArgument,
656  $object->argumentTestClass
657  );
658  $this->assertNull($object->argumentTestClassTwo);
659  }
660 
667  $object = $this->container->getInstance(
668  'TYPO3\\CMS\\Extbase\\Tests\\Unit\\Object\\Container\\Fixtures\\TwoConstructorArgumentsFirstOptional',
669  array(NULL)
670  );
671  $this->assertInstanceOf(
672  'TYPO3\\CMS\\Extbase\\Tests\\Unit\\Object\\Container\\Fixtures\\TwoConstructorArgumentsFirstOptional',
673  $object
674  );
675  $this->assertInstanceOf(
676  'TYPO3\\CMS\\Extbase\\Tests\\Unit\\Object\\Container\\Fixtures\\ArgumentTestClass',
677  $object->argumentTestClassTwo
678  );
679  }
680 
686  $first = new Fixtures\ArgumentTestClass();
687  $second = new Fixtures\ArgumentTestClass();
688  $object = $this->container->getInstance(
689  'TYPO3\\CMS\\Extbase\\Tests\\Unit\\Object\\Container\\Fixtures\\TwoConstructorArgumentsFirstOptional',
690  array($first, $second)
691  );
692  $this->assertInstanceOf(
693  'TYPO3\\CMS\\Extbase\\Tests\\Unit\\Object\\Container\\Fixtures\\TwoConstructorArgumentsFirstOptional',
694  $object
695  );
696  $this->assertSame(
697  $first,
698  $object->argumentTestClass
699  );
700  $this->assertSame(
701  $second,
702  $object->argumentTestClassTwo
703  );
704  }
705 
711  $first = new Fixtures\ArgumentTestClass();
712  $object = $this->container->getInstance(
713  'TYPO3\\CMS\\Extbase\\Tests\\Unit\\Object\\Container\\Fixtures\\TwoConstructorArgumentsFirstOptional',
714  array($first)
715  );
716  $this->assertInstanceOf(
717  'TYPO3\\CMS\\Extbase\\Tests\\Unit\\Object\\Container\\Fixtures\\TwoConstructorArgumentsFirstOptional',
718  $object
719  );
720  $this->assertSame(
721  $first,
722  $object->argumentTestClass
723  );
724  $this->assertInstanceOf(
725  'TYPO3\\CMS\\Extbase\\Tests\\Unit\\Object\\Container\\Fixtures\\ArgumentTestClass',
726  $object->argumentTestClassTwo
727  );
728  $this->assertNotSame(
729  $object->argumentTestClass,
730  $object->argumentTestClassTwo
731  );
732  }
733 
740  $second = new Fixtures\ArgumentTestClass();
741  $object = $this->container->getInstance(
742  'TYPO3\\CMS\\Extbase\\Tests\\Unit\\Object\\Container\\Fixtures\\TwoConstructorArgumentsFirstOptional',
743  array(NULL, $second)
744  );
745  $this->assertInstanceOf(
746  'TYPO3\\CMS\\Extbase\\Tests\\Unit\\Object\\Container\\Fixtures\\TwoConstructorArgumentsFirstOptional',
747  $object
748  );
749  $this->assertSame(
750  $second,
751  $object->argumentTestClassTwo
752  );
753  }
754 
761  $object = $this->container->getInstance(
762  'TYPO3\\CMS\\Extbase\\Tests\\Unit\\Object\\Container\\Fixtures\\TwoConstructorArgumentsFirstOptional',
763  array(NULL, NULL)
764  );
765  $this->assertInstanceOf(
766  'TYPO3\\CMS\\Extbase\\Tests\\Unit\\Object\\Container\\Fixtures\\TwoConstructorArgumentsFirstOptional',
767  $object
768  );
769  $this->assertInstanceOf(
770  'TYPO3\\CMS\\Extbase\\Tests\\Unit\\Object\\Container\\Fixtures\\ArgumentTestClass',
771  $object->argumentTestClassTwo
772  );
773  }
774 
780  $first = new Fixtures\ArgumentTestClass();
781  $second = new Fixtures\ArgumentTestClass();
782  $object = $this->container->getInstance(
783  'TYPO3\\CMS\\Extbase\\Tests\\Unit\\Object\\Container\\Fixtures\\TwoConstructorArgumentsBothOptional',
784  array($first, $second)
785  );
786  $this->assertInstanceOf(
787  'TYPO3\\CMS\\Extbase\\Tests\\Unit\\Object\\Container\\Fixtures\\TwoConstructorArgumentsBothOptional',
788  $object
789  );
790  $this->assertSame(
791  $first,
792  $object->argumentTestClass
793  );
794  $this->assertSame(
795  $second,
796  $object->argumentTestClassTwo
797  );
798  }
799 
805  $object = $this->container->getInstance(
806  'TYPO3\\CMS\\Extbase\\Tests\\Unit\\Object\\Container\\Fixtures\\TwoConstructorArgumentsBothOptional',
807  array(NULL, NULL)
808  );
809  $this->assertInstanceOf(
810  'TYPO3\\CMS\\Extbase\\Tests\\Unit\\Object\\Container\\Fixtures\\TwoConstructorArgumentsBothOptional',
811  $object
812  );
813  $this->assertNull($object->argumentTestClass);
814  $this->assertNull($object->argumentTestClassTwo);
815  }
816 
822  $object = $this->container->getInstance(
823  'TYPO3\\CMS\\Extbase\\Tests\\Unit\\Object\\Container\\Fixtures\\TwoConstructorArgumentsBothOptional');
824  $this->assertInstanceOf(
825  'TYPO3\\CMS\\Extbase\\Tests\\Unit\\Object\\Container\\Fixtures\\TwoConstructorArgumentsBothOptional',
826  $object
827  );
828  $this->assertNull($object->argumentTestClass);
829  $this->assertNull($object->argumentTestClassTwo);
830  }
831 
837  $first = new Fixtures\ArgumentTestClass();
838  $object = $this->container->getInstance(
839  'TYPO3\\CMS\\Extbase\\Tests\\Unit\\Object\\Container\\Fixtures\\TwoConstructorArgumentsBothOptional',
840  array($first)
841  );
842  $this->assertInstanceOf(
843  'TYPO3\\CMS\\Extbase\\Tests\\Unit\\Object\\Container\\Fixtures\\TwoConstructorArgumentsBothOptional',
844  $object
845  );
846  $this->assertSame(
847  $first,
848  $object->argumentTestClass
849  );
850  $this->assertNull($object->argumentTestClassTwo);
851  }
852 
858  $first = new Fixtures\ArgumentTestClass();
859  $object = $this->container->getInstance(
860  'TYPO3\\CMS\\Extbase\\Tests\\Unit\\Object\\Container\\Fixtures\\TwoConstructorArgumentsBothOptional',
861  array($first, NULL)
862  );
863  $this->assertInstanceOf(
864  'TYPO3\\CMS\\Extbase\\Tests\\Unit\\Object\\Container\\Fixtures\\TwoConstructorArgumentsBothOptional',
865  $object
866  );
867  $this->assertSame(
868  $first,
869  $object->argumentTestClass
870  );
871  $this->assertNull($object->argumentTestClassTwo);
872  }
873 
879  $second = new Fixtures\ArgumentTestClass();
880  $object = $this->container->getInstance(
881  'TYPO3\\CMS\\Extbase\\Tests\\Unit\\Object\\Container\\Fixtures\\TwoConstructorArgumentsBothOptional',
882  array(NULL, $second)
883  );
884  $this->assertInstanceOf(
885  'TYPO3\\CMS\\Extbase\\Tests\\Unit\\Object\\Container\\Fixtures\\TwoConstructorArgumentsBothOptional',
886  $object
887  );
888  $this->assertNull($object->argumentTestClass);
889  $this->assertSame(
890  $second,
891  $object->argumentTestClassTwo
892  );
893  }
894 }
setClassInfoCacheCallback($id, \TYPO3\CMS\Extbase\Object\Container\ClassInfo $value)