‪TYPO3CMS  10.4
ContainerTest.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the TYPO3 CMS project.
5  *
6  * It is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU General Public License, either version 2
8  * of the License, or any later version.
9  *
10  * For the full copyright and license information, please read the
11  * LICENSE.txt file that was distributed with this source code.
12  *
13  * The TYPO3 project - inspiring people to share!
14  */
15 
17 
18 use Psr\Container\ContainerInterface;
19 use Psr\Container\NotFoundExceptionInterface;
20 use Psr\Log\LoggerInterface;
39 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
40 
44 class ‪ContainerTest extends UnitTestCase
45 {
49  protected ‪$resetSingletonInstances = true;
50 
54  protected ‪$subject;
55 
59  protected ‪$logger;
60 
61  protected function ‪setUp(): void
62  {
63  parent::setUp();
64  $this->logger = $this->getMockBuilder(Logger::class)
65  ->setMethods(['notice'])
66  ->disableOriginalConstructor()
67  ->getMock();
68  $reflectionService = new ‪ReflectionService();
69 
70  $notFoundException = new class() extends \‪Exception implements NotFoundExceptionInterface {
71  };
72 
73  $psrContainer = $this->getMockBuilder(ContainerInterface::class)
74  ->setMethods(['has', 'get'])
75  ->getMock();
76  $psrContainer->expects(self::any())->method('has')->willReturn(false);
77  $psrContainer->expects(self::any())->method('get')->will(self::throwException($notFoundException));
78 
79  $this->subject = $this->getMockBuilder(Container::class)
80  ->setConstructorArgs([$psrContainer])
81  ->setMethods(['getLogger', 'getReflectionService'])
82  ->getMock();
83  $this->subject->setLogger($this->logger);
84  $this->subject->expects(self::any())->method('getReflectionService')->willReturn($reflectionService);
85  }
86 
91  {
92  $object = $this->subject->getInstance('t3lib_object_tests_c');
93  self::assertInstanceOf('t3lib_object_tests_c', $object);
94  }
95 
100  {
101  $object = $this->subject->getInstance(NamespacedClass::class);
102  self::assertInstanceOf(NamespacedClass::class, $object);
103  }
104 
109  {
110  $object = $this->subject->getInstance('t3lib_object_tests_b');
111  self::assertInstanceOf('t3lib_object_tests_b', $object);
112  self::assertInstanceOf('t3lib_object_tests_c', $object->c);
113  }
114 
119  {
120  $object = $this->subject->getInstance('t3lib_object_tests_a');
121  self::assertInstanceOf('t3lib_object_tests_a', $object);
122  self::assertInstanceOf('t3lib_object_tests_c', $object->b->c);
123  }
124 
129  {
130  $object = $this->subject->getInstance('t3lib_object_tests_amixed_array');
131  self::assertInstanceOf('t3lib_object_tests_amixed_array', $object);
132  self::assertEquals(['some' => 'default'], $object->myvalue);
133  }
134 
139  {
140  $object = $this->subject->getInstance('t3lib_object_tests_amixed_null');
141  self::assertInstanceOf('t3lib_object_tests_amixed_null', $object);
142  self::assertNull($object->myvalue);
143  }
144 
149  {
150  $this->expectException(Exception::class);
151  $this->expectExceptionCode(1292858051);
152  $this->subject->getInstance('t3lib_object_tests_amixed_array_singleton', ['somevalue']);
153  }
154 
159  {
160  $object = $this->subject->getInstance('t3lib_object_tests_amixed_array');
161  self::assertInstanceOf('t3lib_object_tests_b', $object->b);
162  self::assertInstanceOf('t3lib_object_tests_c', $object->c);
163  self::assertEquals(['some' => 'default'], $object->myvalue);
164  }
165 
170  {
171  $mockObject = $this->createMock('t3lib_object_tests_c');
172  $object = $this->subject->getInstance('t3lib_object_tests_a', [$mockObject]);
173  self::assertInstanceOf('t3lib_object_tests_a', $object);
174  self::assertSame($mockObject, $object->c);
175  }
176 
181  {
182  $object1 = $this->subject->getInstance('t3lib_object_tests_a');
183  $object2 = $this->subject->getInstance('t3lib_object_tests_a');
184  self::assertNotSame($object1, $object2);
185  }
186 
191  {
192  $object1 = $this->subject->getInstance('t3lib_object_tests_singleton');
193  $object2 = $this->subject->getInstance('t3lib_object_tests_singleton');
194  self::assertSame($object1, $object2);
195  }
196 
201  {
202  $this->expectException(CannotBuildObjectException::class);
203  $this->expectExceptionCode(1295611406);
204  $this->subject->getInstance('t3lib_object_tests_cyclic1WithSetterDependency');
205  }
206 
211  {
212  $this->expectException(CannotBuildObjectException::class);
213  $this->expectExceptionCode(1295611406);
214  $this->subject->getInstance('t3lib_object_tests_cyclic1');
215  }
216 
221  {
222  $this->expectException(UnknownClassException::class);
223  $this->expectExceptionCode(1278450972);
224  $this->subject->getInstance('nonextistingclass_bla');
225  }
226 
230  public function ‪getInstanceInitializesObjects()
231  {
232  $instance = $this->subject->getInstance('t3lib_object_tests_initializable');
233  self::assertTrue($instance->isInitialized());
234  }
235 
240  {
241  $object = $this->subject->getEmptyObject('t3lib_object_tests_c');
242  self::assertInstanceOf('t3lib_object_tests_c', $object);
243  }
244 
249  {
250  $object = $this->subject->getEmptyObject('t3lib_object_tests_serializable');
251  self::assertInstanceOf('t3lib_object_tests_serializable', $object);
252  }
253 
257  public function ‪getEmptyObjectInitializesObjects()
258  {
259  $object = $this->subject->getEmptyObject('t3lib_object_tests_initializable');
260  self::assertTrue($object->isInitialized());
261  }
262 
266  public function ‪test_canGetChildClass()
267  {
268  $object = $this->subject->getInstance('t3lib_object_tests_b_child');
269  self::assertInstanceOf('t3lib_object_tests_b_child', $object);
270  }
271 
275  public function ‪test_canInjectInterfaceInClass()
276  {
277  $this->subject->registerImplementation('t3lib_object_tests_someinterface', 't3lib_object_tests_someimplementation');
278  $object = $this->subject->getInstance('t3lib_object_tests_needsinterface');
279  self::assertInstanceOf('t3lib_object_tests_needsinterface', $object);
280  self::assertInstanceOf('t3lib_object_tests_someinterface', $object->dependency);
281  self::assertInstanceOf('t3lib_object_tests_someimplementation', $object->dependency);
282  }
283 
288  {
289  $object = $this->subject->getInstance('t3lib_object_tests_resolveablecyclic1');
290  self::assertInstanceOf('t3lib_object_tests_resolveablecyclic1', $object);
291  self::assertInstanceOf('t3lib_object_tests_resolveablecyclic1', $object->o2->o3->o1);
292  }
293 
298  {
299  $this->logger->expects(self::once())->method('notice')->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.');
300  $object = $this->subject->getInstance('t3lib_object_singletonNeedsPrototype');
301  self::assertInstanceOf('t3lib_object_prototype', $object->dependency);
302  }
303 
308  {
309  $this->logger->expects(self::never())->method('notice');
310  $object = $this->subject->getInstance('t3lib_object_singletonNeedsSingleton');
311  self::assertInstanceOf('t3lib_object_singleton', $object->dependency);
312  }
313 
318  {
319  $this->logger->expects(self::never())->method('notice');
320  $object = $this->subject->getInstance('t3lib_object_prototypeNeedsPrototype');
321  self::assertInstanceOf('t3lib_object_prototype', $object->dependency);
322  }
323 
328  {
329  $this->logger->expects(self::never())->method('notice');
330  $object = $this->subject->getInstance('t3lib_object_prototypeNeedsSingleton');
331  self::assertInstanceOf('t3lib_object_singleton', $object->dependency);
332  }
333 
338  {
339  $this->logger->expects(self::once())->method('notice')->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.');
340  $object = $this->subject->getInstance('t3lib_object_singletonNeedsPrototypeInConstructor');
341  self::assertInstanceOf('t3lib_object_prototype', $object->dependency);
342  }
343 
348  {
349  $this->logger->expects(self::never())->method('notice');
350  $object = $this->subject->getInstance('t3lib_object_singletonNeedsSingletonInConstructor');
351  self::assertInstanceOf('t3lib_object_singleton', $object->dependency);
352  }
353 
358  {
359  $this->logger->expects(self::never())->method('notice');
360  $object = $this->subject->getInstance('t3lib_object_prototypeNeedsPrototypeInConstructor');
361  self::assertInstanceOf('t3lib_object_prototype', $object->dependency);
362  }
363 
368  {
369  $this->logger->expects(self::never())->method('notice');
370  $object = $this->subject->getInstance('t3lib_object_prototypeNeedsSingletonInConstructor');
371  self::assertInstanceOf('t3lib_object_singleton', $object->dependency);
372  }
373 
374  /************************************************
375  * Test regarding constructor argument injection
376  ************************************************/
377 
383  {
384  $object = $this->subject->getInstance(
385  SimpleTypeConstructorArgument::class,
386  [true]
387  );
388  self::assertTrue($object->foo);
389  }
390 
396  {
397  $object = $this->subject->getInstance(
398  SimpleTypeConstructorArgument::class
399  );
400  self::assertFalse($object->foo);
401  }
402 
408  {
409  $argumentTestClass = new ‪ArgumentTestClass();
410  $object = $this->subject->getInstance(
411  MandatoryConstructorArgument::class,
412  [$argumentTestClass]
413  );
414  self::assertInstanceOf(
415  MandatoryConstructorArgument::class,
416  $object
417  );
418  self::assertSame($argumentTestClass, $object->argumentTestClass);
419  }
420 
426  {
427  $object = $this->subject->getInstance(
428  MandatoryConstructorArgument::class
429  );
430  self::assertInstanceOf(
431  MandatoryConstructorArgument::class,
432  $object
433  );
434  self::assertInstanceOf(
435  ArgumentTestClass::class,
436  $object->argumentTestClass
437  );
438  }
439 
445  {
446  $object = $this->subject->getInstance(
447  OptionalConstructorArgument::class
448  );
449  self::assertInstanceOf(
450  OptionalConstructorArgument::class,
451  $object
452  );
453  self::assertNull($object->argumentTestClass);
454  }
455 
461  {
462  $object = $this->subject->getInstance(
463  OptionalConstructorArgument::class,
464  [null]
465  );
466  self::assertInstanceOf(
467  OptionalConstructorArgument::class,
468  $object
469  );
470  self::assertNull($object->argumentTestClass);
471  }
472 
478  {
479  $argumentTestClass = new ‪ArgumentTestClass();
480  $object = $this->subject->getInstance(
481  OptionalConstructorArgument::class,
482  [$argumentTestClass]
483  );
484  self::assertInstanceOf(
485  OptionalConstructorArgument::class,
486  $object
487  );
488  self::assertSame($argumentTestClass, $object->argumentTestClass);
489  }
490 
496  {
497  $firstArgument = new ‪ArgumentTestClass();
498  $secondArgument = new ‪ArgumentTestClass();
499  $object = $this->subject->getInstance(
500  MandatoryConstructorArgumentTwo::class,
501  [$firstArgument, $secondArgument]
502  );
503  self::assertInstanceOf(
504  MandatoryConstructorArgumentTwo::class,
505  $object
506  );
507  self::assertSame(
508  $firstArgument,
509  $object->argumentTestClass
510  );
511  self::assertSame(
512  $secondArgument,
513  $object->argumentTestClassTwo
514  );
515  }
516 
522  {
523  $object = $this->subject->getInstance(
524  MandatoryConstructorArgumentTwo::class
525  );
526  self::assertInstanceOf(
527  MandatoryConstructorArgumentTwo::class,
528  $object
529  );
530  self::assertInstanceOf(
531  ArgumentTestClass::class,
532  $object->argumentTestClass
533  );
534  self::assertInstanceOf(
535  ArgumentTestClass::class,
536  $object->argumentTestClassTwo
537  );
538  self::assertNotSame(
539  $object->argumentTestClass,
540  $object->argumentTestClassTwo
541  );
542  }
543 
549  {
550  $firstArgument = new ‪ArgumentTestClass();
551  $object = $this->subject->getInstance(
552  MandatoryConstructorArgumentTwo::class,
553  [$firstArgument]
554  );
555  self::assertInstanceOf(
556  MandatoryConstructorArgumentTwo::class,
557  $object
558  );
559  self::assertSame(
560  $firstArgument,
561  $object->argumentTestClass
562  );
563  self::assertInstanceOf(
564  ArgumentTestClass::class,
565  $object->argumentTestClassTwo
566  );
567  self::assertNotSame(
568  $object->argumentTestClass,
569  $object->argumentTestClassTwo
570  );
571  }
572 
578  {
579  $secondArgument = new ‪ArgumentTestClass();
580  $object = $this->subject->getInstance(
581  MandatoryConstructorArgumentTwo::class,
582  [null, $secondArgument]
583  );
584  self::assertInstanceOf(
585  MandatoryConstructorArgumentTwo::class,
586  $object
587  );
588  self::assertInstanceOf(
589  ArgumentTestClass::class,
590  $object->argumentTestClass
591  );
592  self::assertInstanceOf(
593  ArgumentTestClass::class,
594  $object->argumentTestClassTwo
595  );
596  self::assertSame(
597  $secondArgument,
598  $object->argumentTestClassTwo
599  );
600  self::assertNotSame(
601  $object->argumentTestClass,
602  $object->argumentTestClassTwo
603  );
604  }
605 
611  {
612  $firstArgument = new ‪ArgumentTestClass();
613  $secondArgument = new ‪ArgumentTestClass();
614  $object = $this->subject->getInstance(
615  TwoConstructorArgumentsSecondOptional::class,
616  [$firstArgument, $secondArgument]
617  );
618  self::assertInstanceOf(
619  TwoConstructorArgumentsSecondOptional::class,
620  $object
621  );
622  self::assertSame(
623  $firstArgument,
624  $object->argumentTestClass
625  );
626  self::assertSame(
627  $secondArgument,
628  $object->argumentTestClassTwo
629  );
630  }
631 
637  {
638  $object = $this->subject->getInstance(
639  TwoConstructorArgumentsSecondOptional::class
640  );
641  self::assertInstanceOf(
642  TwoConstructorArgumentsSecondOptional::class,
643  $object
644  );
645  self::assertInstanceOf(
646  ArgumentTestClass::class,
647  $object->argumentTestClass
648  );
649  self::assertNull($object->argumentTestClassTwo);
650  }
651 
657  {
658  $object = $this->subject->getInstance(
659  TwoConstructorArgumentsSecondOptional::class,
660  [null, null]
661  );
662  self::assertInstanceOf(
663  TwoConstructorArgumentsSecondOptional::class,
664  $object
665  );
666  self::assertInstanceOf(
667  ArgumentTestClass::class,
668  $object->argumentTestClass
669  );
670  self::assertNull($object->argumentTestClassTwo);
671  }
672 
678  {
679  $firstArgument = new ‪ArgumentTestClass();
680  $object = $this->subject->getInstance(
681  TwoConstructorArgumentsSecondOptional::class,
682  [$firstArgument]
683  );
684  self::assertInstanceOf(
685  TwoConstructorArgumentsSecondOptional::class,
686  $object
687  );
688  self::assertSame(
689  $firstArgument,
690  $object->argumentTestClass
691  );
692  self::assertNull($object->argumentTestClassTwo);
693  }
694 
700  {
701  $firstArgument = new ‪ArgumentTestClass();
702  $object = $this->subject->getInstance(
703  TwoConstructorArgumentsSecondOptional::class,
704  [$firstArgument, null]
705  );
706  self::assertInstanceOf(
707  TwoConstructorArgumentsSecondOptional::class,
708  $object
709  );
710  self::assertSame(
711  $firstArgument,
712  $object->argumentTestClass
713  );
714  self::assertNull($object->argumentTestClassTwo);
715  }
716 
723  {
724  $object = $this->subject->getInstance(
725  TwoConstructorArgumentsFirstOptional::class,
726  [null]
727  );
728  self::assertInstanceOf(
729  TwoConstructorArgumentsFirstOptional::class,
730  $object
731  );
732  self::assertInstanceOf(
733  ArgumentTestClass::class,
734  $object->argumentTestClassTwo
735  );
736  }
737 
743  {
744  $first = new ‪ArgumentTestClass();
745  $second = new ‪ArgumentTestClass();
746  $object = $this->subject->getInstance(
747  TwoConstructorArgumentsFirstOptional::class,
748  [$first, $second]
749  );
750  self::assertInstanceOf(
751  TwoConstructorArgumentsFirstOptional::class,
752  $object
753  );
754  self::assertSame(
755  $first,
756  $object->argumentTestClass
757  );
758  self::assertSame(
759  $second,
760  $object->argumentTestClassTwo
761  );
762  }
763 
769  {
770  $first = new ‪ArgumentTestClass();
771  $object = $this->subject->getInstance(
772  TwoConstructorArgumentsFirstOptional::class,
773  [$first]
774  );
775  self::assertInstanceOf(
776  TwoConstructorArgumentsFirstOptional::class,
777  $object
778  );
779  self::assertSame(
780  $first,
781  $object->argumentTestClass
782  );
783  self::assertInstanceOf(
784  ArgumentTestClass::class,
785  $object->argumentTestClassTwo
786  );
787  self::assertNotSame(
788  $object->argumentTestClass,
789  $object->argumentTestClassTwo
790  );
791  }
792 
799  {
800  $second = new ‪ArgumentTestClass();
801  $object = $this->subject->getInstance(
802  TwoConstructorArgumentsFirstOptional::class,
803  [null, $second]
804  );
805  self::assertInstanceOf(
806  TwoConstructorArgumentsFirstOptional::class,
807  $object
808  );
809  self::assertSame(
810  $second,
811  $object->argumentTestClassTwo
812  );
813  }
814 
821  {
822  $object = $this->subject->getInstance(
823  TwoConstructorArgumentsFirstOptional::class,
824  [null, null]
825  );
826  self::assertInstanceOf(
827  TwoConstructorArgumentsFirstOptional::class,
828  $object
829  );
830  self::assertInstanceOf(
831  ArgumentTestClass::class,
832  $object->argumentTestClassTwo
833  );
834  }
835 
841  {
842  $first = new ‪ArgumentTestClass();
843  $second = new ‪ArgumentTestClass();
844  $object = $this->subject->getInstance(
845  TwoConstructorArgumentsBothOptional::class,
846  [$first, $second]
847  );
848  self::assertInstanceOf(
849  TwoConstructorArgumentsBothOptional::class,
850  $object
851  );
852  self::assertSame(
853  $first,
854  $object->argumentTestClass
855  );
856  self::assertSame(
857  $second,
858  $object->argumentTestClassTwo
859  );
860  }
861 
867  {
868  $object = $this->subject->getInstance(
869  TwoConstructorArgumentsBothOptional::class,
870  [null, null]
871  );
872  self::assertInstanceOf(
873  TwoConstructorArgumentsBothOptional::class,
874  $object
875  );
876  self::assertNull($object->argumentTestClass);
877  self::assertNull($object->argumentTestClassTwo);
878  }
879 
885  {
886  $object = $this->subject->getInstance(
887  TwoConstructorArgumentsBothOptional::class
888  );
889  self::assertInstanceOf(
890  TwoConstructorArgumentsBothOptional::class,
891  $object
892  );
893  self::assertNull($object->argumentTestClass);
894  self::assertNull($object->argumentTestClassTwo);
895  }
896 
902  {
903  $first = new ‪ArgumentTestClass();
904  $object = $this->subject->getInstance(
905  TwoConstructorArgumentsBothOptional::class,
906  [$first]
907  );
908  self::assertInstanceOf(
909  TwoConstructorArgumentsBothOptional::class,
910  $object
911  );
912  self::assertSame(
913  $first,
914  $object->argumentTestClass
915  );
916  self::assertNull($object->argumentTestClassTwo);
917  }
918 
924  {
925  $first = new ‪ArgumentTestClass();
926  $object = $this->subject->getInstance(
927  TwoConstructorArgumentsBothOptional::class,
928  [$first, null]
929  );
930  self::assertInstanceOf(
931  TwoConstructorArgumentsBothOptional::class,
932  $object
933  );
934  self::assertSame(
935  $first,
936  $object->argumentTestClass
937  );
938  self::assertNull($object->argumentTestClassTwo);
939  }
940 
946  {
947  $second = new ‪ArgumentTestClass();
948  $object = $this->subject->getInstance(
949  TwoConstructorArgumentsBothOptional::class,
950  [null, $second]
951  );
952  self::assertInstanceOf(
953  TwoConstructorArgumentsBothOptional::class,
954  $object
955  );
956  self::assertNull($object->argumentTestClass);
957  self::assertSame(
958  $second,
959  $object->argumentTestClassTwo
960  );
961  }
962 
966  public function ‪getInstanceInjectsPublicProperties()
967  {
968  $object = $this->subject->getInstance(PublicPropertyInjectClass::class);
969  self::assertInstanceOf(ArgumentTestClassForPublicPropertyInjection::class, $object->foo);
970  }
971 
976  {
977  $object = $this->subject->getInstance(ProtectedPropertyInjectClass::class);
978  self::assertInstanceOf(ArgumentTestClassForPublicPropertyInjection::class, $object->getFoo());
979  }
980 }
‪TYPO3\CMS\Extbase\Tests\Unit\Object\Container\ContainerTest\getInstanceOnTwoOptionalGivesNoArgumentsToConstructorIfArgumentsAreNull
‪getInstanceOnTwoOptionalGivesNoArgumentsToConstructorIfArgumentsAreNull()
Definition: ContainerTest.php:863
‪TYPO3\CMS\Extbase\Tests\Unit\Object\Container\Fixtures\MandatoryConstructorArgument
Definition: ContainerConstructorInjectionTestFixtures.php:38
‪TYPO3\CMS\Extbase\Tests\Unit\Object\Container\ContainerTest\singletonWhichRequiresSingletonViaConstructorInjectionWorks
‪singletonWhichRequiresSingletonViaConstructorInjectionWorks()
Definition: ContainerTest.php:344
‪TYPO3\CMS\Extbase\Tests\Unit\Object\Container\ContainerTest\getInstanceOnFirstOptionalAndSecondMandatoryInjectsSecondArgumentIfFirstIsGivenAsNull
‪getInstanceOnFirstOptionalAndSecondMandatoryInjectsSecondArgumentIfFirstIsGivenAsNull()
Definition: ContainerTest.php:719
‪TYPO3\CMS\Extbase\Tests\Unit\Object\Container\ContainerTest\getInstanceGivesExistingConstructorArgumentToClassInstance
‪getInstanceGivesExistingConstructorArgumentToClassInstance()
Definition: ContainerTest.php:404
‪TYPO3\CMS\Extbase\Tests\Unit\Object\Container\Fixtures\ProtectedPropertyInjectClass
Definition: ContainerPropertyInjectionTestClasses.php:35
‪TYPO3\CMS\Extbase\Tests\Unit\Object\Container\ContainerTest\prototypeWhichRequiresPrototypeViaConstructorInjectionWorks
‪prototypeWhichRequiresPrototypeViaConstructorInjectionWorks()
Definition: ContainerTest.php:354
‪TYPO3\CMS\Extbase\Tests\Unit\Object\Container\ContainerTest\getInstanceDoesNotInfluenceSimpleTypeConstructorArgumentIfNotGiven
‪getInstanceDoesNotInfluenceSimpleTypeConstructorArgumentIfNotGiven()
Definition: ContainerTest.php:392
‪TYPO3\CMS\Extbase\Object\Container\Container
Definition: Container.php:39
‪TYPO3\CMS\Extbase\Tests\Unit\Object\Container\ContainerTest\getInstanceInjectsSecondMandatoryArgumentIfFirstIsGiven
‪getInstanceInjectsSecondMandatoryArgumentIfFirstIsGiven()
Definition: ContainerTest.php:545
‪TYPO3\CMS\Extbase\Tests\Unit\Object\Container\ContainerTest\getInstanceThrowsExceptionWhenTryingToInstanciateASingletonWithConstructorParameters
‪getInstanceThrowsExceptionWhenTryingToInstanciateASingletonWithConstructorParameters()
Definition: ContainerTest.php:145
‪TYPO3\CMS\Extbase\Tests\Unit\Object\Container\ContainerTest\getInstanceOnTwoOptionalGivesNoArgumentsToConstructorIfNoneAreGiven
‪getInstanceOnTwoOptionalGivesNoArgumentsToConstructorIfNoneAreGiven()
Definition: ContainerTest.php:881
‪TYPO3\CMS\Extbase\Tests\Unit\Object\Container\ContainerTest\getInstanceReturnsAFreshInstanceIfObjectIsNoSingleton
‪getInstanceReturnsAFreshInstanceIfObjectIsNoSingleton()
Definition: ContainerTest.php:177
‪TYPO3\CMS\Extbase\Tests\Unit\Object\Container
Definition: ContainerTest.php:16
‪TYPO3\CMS\Extbase\Tests\Unit\Object\Container\ContainerTest\getInstanceInjectsTwoMandatoryArguments
‪getInstanceInjectsTwoMandatoryArguments()
Definition: ContainerTest.php:518
‪TYPO3\CMS\Extbase\Tests\Unit\Object\Container\ContainerTest\getInstanceOnTwoOptionalGivesOneArgumentToConstructorIfFirstIsNullAndSecondIsObject
‪getInstanceOnTwoOptionalGivesOneArgumentToConstructorIfFirstIsNullAndSecondIsObject()
Definition: ContainerTest.php:942
‪TYPO3\CMS\Extbase\Tests\Unit\Object\Container\ContainerTest\getInstanceOnFirstOptionalAndSecondMandatoryGivesSecondArgumentAsIsIfFirstIsGivenAsNullAndSecondIsGiven
‪getInstanceOnFirstOptionalAndSecondMandatoryGivesSecondArgumentAsIsIfFirstIsGivenAsNullAndSecondIsGiven()
Definition: ContainerTest.php:795
‪TYPO3\CMS\Extbase\Tests\Unit\Object\Container\ContainerTest\getInstanceThrowsExceptionIfClassWasNotFound
‪getInstanceThrowsExceptionIfClassWasNotFound()
Definition: ContainerTest.php:217
‪TYPO3\CMS\Extbase\Tests\Unit\Object\Container\ContainerTest\getInstanceOnTwoOptionalGivesOneArgumentToConstructorIfFirstIsObjectAndSecondIsNull
‪getInstanceOnTwoOptionalGivesOneArgumentToConstructorIfFirstIsObjectAndSecondIsNull()
Definition: ContainerTest.php:920
‪TYPO3\CMS\Extbase\Tests\Unit\Object\Container\ContainerTest\getInstanceDoesNotInjectAnOptionalArgumentIfGivenArgumentIsNull
‪getInstanceDoesNotInjectAnOptionalArgumentIfGivenArgumentIsNull()
Definition: ContainerTest.php:457
‪TYPO3\CMS\Extbase\Tests\Unit\Object\Container\Fixtures\TwoConstructorArgumentsSecondOptional
Definition: ContainerConstructorInjectionTestFixtures.php:94
‪TYPO3\CMS\Extbase\Tests\Unit\Object\Container\ContainerTest\$subject
‪Container $subject
Definition: ContainerTest.php:52
‪TYPO3\CMS\Extbase\Tests\Unit\Object\Container\ContainerTest\getInstancePassesGivenParameterToTheNewObject
‪getInstancePassesGivenParameterToTheNewObject()
Definition: ContainerTest.php:166
‪TYPO3\CMS\Extbase\Tests\Unit\Object\Container\ContainerTest\getInstanceReturnsInstanceOfAClassWithConstructorInjectionAndDefaultConstructorParameters
‪getInstanceReturnsInstanceOfAClassWithConstructorInjectionAndDefaultConstructorParameters()
Definition: ContainerTest.php:155
‪TYPO3\CMS\Extbase\Tests\Unit\Object\Container\ContainerTest\getInstanceInjectsPublicProperties
‪getInstanceInjectsPublicProperties()
Definition: ContainerTest.php:963
‪TYPO3\CMS\Extbase\Tests\Unit\Object\Container\ContainerTest\getInstanceGivesTwoArgumentsToClassConstructorIfSecondIsOptional
‪getInstanceGivesTwoArgumentsToClassConstructorIfSecondIsOptional()
Definition: ContainerTest.php:607
‪TYPO3\CMS\Extbase\Object\Exception\CannotBuildObjectException
Definition: CannotBuildObjectException.php:26
‪TYPO3\CMS\Extbase\Tests\Unit\Object\Container\ContainerTest\getInstanceOnFirstOptionalAndSecondMandatoryInjectsSecondArgumentIfFirstIsGiven
‪getInstanceOnFirstOptionalAndSecondMandatoryInjectsSecondArgumentIfFirstIsGiven()
Definition: ContainerTest.php:765
‪TYPO3\CMS\Extbase\Tests\Unit\Object\Container\ContainerTest\getInstanceDoesNotInjectAnOptionalArgumentIfNotGiven
‪getInstanceDoesNotInjectAnOptionalArgumentIfNotGiven()
Definition: ContainerTest.php:441
‪TYPO3\CMS\Extbase\Tests\Unit\Object\Container\ContainerTest\getInstanceInitializesObjects
‪getInstanceInitializesObjects()
Definition: ContainerTest.php:227
‪TYPO3\CMS\Extbase\Reflection\ReflectionService
Definition: ReflectionService.php:31
‪TYPO3\CMS\Extbase\Tests\Unit\Object\Container\ContainerTest\test_canInjectInterfaceInClass
‪test_canInjectInterfaceInClass()
Definition: ContainerTest.php:272
‪TYPO3\CMS\Extbase\Tests\Unit\Object\Container\ContainerTest\singletonWhichRequiresPrototypeViaSetterInjectionWorksAndAddsDebugMessage
‪singletonWhichRequiresPrototypeViaSetterInjectionWorksAndAddsDebugMessage()
Definition: ContainerTest.php:294
‪TYPO3\CMS\Extbase\Tests\Unit\Object\Container\ContainerTest\getInstanceGivesFirstArgumentToConstructorIfSecondIsOptionalFirstIsGivenAndSecondIsGivenNull
‪getInstanceGivesFirstArgumentToConstructorIfSecondIsOptionalFirstIsGivenAndSecondIsGivenNull()
Definition: ContainerTest.php:696
‪TYPO3\CMS\Extbase\Tests\Unit\Object\Container\ContainerTest\getInstanceThrowsExceptionIfPrototypeObjectsWiredViaSetterInjectionContainCyclicDependencies
‪getInstanceThrowsExceptionIfPrototypeObjectsWiredViaSetterInjectionContainCyclicDependencies()
Definition: ContainerTest.php:207
‪TYPO3\CMS\Extbase\Tests\Unit\Object\Container\ContainerTest\getInstanceOnTwoOptionalGivesTwoGivenArgumentsToConstructor
‪getInstanceOnTwoOptionalGivesTwoGivenArgumentsToConstructor()
Definition: ContainerTest.php:837
‪TYPO3\CMS\Extbase\Tests\Unit\Object\Container\ContainerTest\getInstanceThrowsExceptionIfPrototypeObjectsWiredViaConstructorInjectionContainCyclicDependencies
‪getInstanceThrowsExceptionIfPrototypeObjectsWiredViaConstructorInjectionContainCyclicDependencies()
Definition: ContainerTest.php:197
‪TYPO3\CMS\Extbase\Tests\Unit\Object\Container\ContainerTest\getInstanceReturnsInstanceOfAClassWithMixedSimpleTypeAndConstructorInjectionWithNullDefaultValue
‪getInstanceReturnsInstanceOfAClassWithMixedSimpleTypeAndConstructorInjectionWithNullDefaultValue()
Definition: ContainerTest.php:135
‪TYPO3\CMS\Extbase\Tests\Unit\Object\Container\ContainerTest\getInstanceReturnsInstanceOfAClassWithMixedSimpleTypeAndConstructorInjection
‪getInstanceReturnsInstanceOfAClassWithMixedSimpleTypeAndConstructorInjection()
Definition: ContainerTest.php:125
‪TYPO3\CMS\Extbase\Tests\Unit\Object\Container\Fixtures\NamespacedClass
Definition: NamespacedClass.php:22
‪TYPO3\CMS\Extbase\Tests\Unit\Object\Container\ContainerTest\getInstanceOnFirstOptionalAndSecondMandatoryInjectsSecondArgumentIfFirstIsGivenAsNullAndSecondIsNull
‪getInstanceOnFirstOptionalAndSecondMandatoryInjectsSecondArgumentIfFirstIsGivenAsNullAndSecondIsNull()
Definition: ContainerTest.php:817
‪TYPO3\CMS\Extbase\Tests\Unit\Object\Container\Fixtures\MandatoryConstructorArgumentTwo
Definition: ContainerConstructorInjectionTestFixtures.php:73
‪TYPO3\CMS\Extbase\Reflection\Exception\UnknownClassException
Definition: UnknownClassException.php:26
‪TYPO3\CMS\Extbase\Object\Exception
Definition: CannotBuildObjectException.php:18
‪TYPO3\CMS\Extbase\Tests\Unit\Object\Container\ContainerTest\getInstanceInjectsFirstMandatoryArgumentIfSecondIsOptionalAndNoneAreGiven
‪getInstanceInjectsFirstMandatoryArgumentIfSecondIsOptionalAndNoneAreGiven()
Definition: ContainerTest.php:633
‪TYPO3\CMS\Extbase\Tests\Unit\Object\Container\ContainerTest\getEmptyObjectReturnsInstanceOfClassImplementingSerializable
‪getEmptyObjectReturnsInstanceOfClassImplementingSerializable()
Definition: ContainerTest.php:245
‪TYPO3\CMS\Extbase\Tests\Unit\Object\Container\Fixtures\SimpleTypeConstructorArgument
Definition: ContainerConstructorInjectionTestFixtures.php:19
‪TYPO3\CMS\Extbase\Tests\Unit\Object\Container\ContainerTest\singletonWhichRequiresPrototypeViaConstructorInjectionWorksAndAddsDebugMessage
‪singletonWhichRequiresPrototypeViaConstructorInjectionWorksAndAddsDebugMessage()
Definition: ContainerTest.php:334
‪TYPO3\CMS\Extbase\Tests\Unit\Object\Container\ContainerTest\getInstanceReturnsSameInstanceInstanceIfObjectIsSingleton
‪getInstanceReturnsSameInstanceInstanceIfObjectIsSingleton()
Definition: ContainerTest.php:187
‪TYPO3\CMS\Extbase\Tests\Unit\Object\Container\Fixtures\PublicPropertyInjectClass
Definition: ContainerPropertyInjectionTestClasses.php:23
‪TYPO3\CMS\Extbase\Tests\Unit\Object\Container\ContainerTest\setUp
‪setUp()
Definition: ContainerTest.php:58
‪TYPO3\CMS\Extbase\Tests\Unit\Object\Container\ContainerTest\getEmptyObjectReturnsInstanceOfSimpleClass
‪getEmptyObjectReturnsInstanceOfSimpleClass()
Definition: ContainerTest.php:236
‪TYPO3\CMS\Extbase\Tests\Unit\Object\Container\ContainerTest\test_canGetChildClass
‪test_canGetChildClass()
Definition: ContainerTest.php:263
‪TYPO3\CMS\Extbase\Tests\Unit\Object\Container\ContainerTest\$resetSingletonInstances
‪bool $resetSingletonInstances
Definition: ContainerTest.php:48
‪TYPO3\CMS\Extbase\Tests\Unit\Object\Container\ContainerTest\test_canBuildCyclicDependenciesOfSingletonsWithSetter
‪test_canBuildCyclicDependenciesOfSingletonsWithSetter()
Definition: ContainerTest.php:284
‪TYPO3\CMS\Extbase\Tests\Unit\Object\Container\ContainerTest
Definition: ContainerTest.php:45
‪TYPO3\CMS\Extbase\Tests\Unit\Object\Container\ContainerTest\getInstanceReturnsInstanceOfSimpleNamespacedClass
‪getInstanceReturnsInstanceOfSimpleNamespacedClass()
Definition: ContainerTest.php:96
‪TYPO3\CMS\Extbase\Tests\Unit\Object\Container\Fixtures\ArgumentTestClass
Definition: ContainerConstructorInjectionTestFixtures.php:34
‪TYPO3\CMS\Extbase\Tests\Unit\Object\Container\ContainerTest\getInstanceInjectsFirstMandatoryArgumentIfSecondIsOptionalAndBothAreGivenAsNull
‪getInstanceInjectsFirstMandatoryArgumentIfSecondIsOptionalAndBothAreGivenAsNull()
Definition: ContainerTest.php:653
‪TYPO3\CMS\Extbase\Object\Exception
Definition: Exception.php:26
‪TYPO3\CMS\Extbase\Tests\Unit\Object\Container\ContainerTest\$logger
‪LoggerInterface PHPUnit Framework MockObject MockObject $logger
Definition: ContainerTest.php:56
‪TYPO3\CMS\Extbase\Tests\Unit\Object\Container\Fixtures\OptionalConstructorArgument
Definition: ContainerConstructorInjectionTestFixtures.php:58
‪TYPO3\CMS\Extbase\Tests\Unit\Object\Container\Fixtures\TwoConstructorArgumentsFirstOptional
Definition: ContainerConstructorInjectionTestFixtures.php:115
‪TYPO3\CMS\Extbase\Tests\Unit\Object\Container\ContainerTest\prototypeWhichRequiresSingletonViaConstructorInjectionWorks
‪prototypeWhichRequiresSingletonViaConstructorInjectionWorks()
Definition: ContainerTest.php:364
‪TYPO3\CMS\Extbase\Tests\Unit\Object\Container\ContainerTest\getInstanceGivesSimpleConstructorArgumentToClassInstance
‪getInstanceGivesSimpleConstructorArgumentToClassInstance()
Definition: ContainerTest.php:379
‪TYPO3\CMS\Extbase\Tests\Unit\Object\Container\ContainerTest\prototypeWhichRequiresSingletonViaSetterInjectionWorks
‪prototypeWhichRequiresSingletonViaSetterInjectionWorks()
Definition: ContainerTest.php:324
‪TYPO3\CMS\Core\Log\Logger
Definition: Logger.php:27
‪TYPO3\CMS\Extbase\Tests\Unit\Object\Container\ContainerTest\getInstanceGivesExistingConstructorArgumentToClassInstanceIfArgumentIsGiven
‪getInstanceGivesExistingConstructorArgumentToClassInstanceIfArgumentIsGiven()
Definition: ContainerTest.php:474
‪TYPO3\CMS\Extbase\Tests\Unit\Object\Container\ContainerTest\getEmptyObjectInitializesObjects
‪getEmptyObjectInitializesObjects()
Definition: ContainerTest.php:254
‪TYPO3\CMS\Extbase\Tests\Unit\Object\Container\ContainerTest\getInstanceGivesFirstArgumentToConstructorIfSecondIsOptionalAndFirstIsGiven
‪getInstanceGivesFirstArgumentToConstructorIfSecondIsOptionalAndFirstIsGiven()
Definition: ContainerTest.php:674
‪TYPO3\CMS\Extbase\Tests\Unit\Object\Container\ContainerTest\getInstanceOnFirstOptionalAndSecondMandatoryGivesTwoGivenArgumentsToConstructor
‪getInstanceOnFirstOptionalAndSecondMandatoryGivesTwoGivenArgumentsToConstructor()
Definition: ContainerTest.php:739
‪TYPO3\CMS\Extbase\Tests\Unit\Object\Container\Fixtures\TwoConstructorArgumentsBothOptional
Definition: ContainerConstructorInjectionTestFixtures.php:144
‪TYPO3\CMS\Extbase\Tests\Unit\Object\Container\Fixtures\ArgumentTestClassForPublicPropertyInjection
Definition: ContainerPropertyInjectionTestClasses.php:31
‪TYPO3\CMS\Extbase\Tests\Unit\Object\Container\ContainerTest\getInstanceReturnsInstanceOfSimpleClass
‪getInstanceReturnsInstanceOfSimpleClass()
Definition: ContainerTest.php:87
‪TYPO3\CMS\Extbase\Tests\Unit\Object\Container\ContainerTest\singletonWhichRequiresSingletonViaSetterInjectionWorks
‪singletonWhichRequiresSingletonViaSetterInjectionWorks()
Definition: ContainerTest.php:304
‪TYPO3\CMS\Extbase\Tests\Unit\Object\Container\ContainerTest\getInstanceReturnsInstanceOfAClassWithConstructorInjection
‪getInstanceReturnsInstanceOfAClassWithConstructorInjection()
Definition: ContainerTest.php:105
‪TYPO3\CMS\Extbase\Tests\Unit\Object\Container\ContainerTest\getInstanceOnTwoOptionalGivesOneArgumentToConstructorIfFirstIsObjectAndSecondIsNotGiven
‪getInstanceOnTwoOptionalGivesOneArgumentToConstructorIfFirstIsObjectAndSecondIsNotGiven()
Definition: ContainerTest.php:898
‪TYPO3\CMS\Extbase\Tests\Unit\Object\Container\ContainerTest\getInstanceInjectsProtectedProperties
‪getInstanceInjectsProtectedProperties()
Definition: ContainerTest.php:972
‪TYPO3\CMS\Extbase\Tests\Unit\Object\Container\ContainerTest\getInstanceInjectsNewInstanceOfClassToClassIfArgumentIsMandatory
‪getInstanceInjectsNewInstanceOfClassToClassIfArgumentIsMandatory()
Definition: ContainerTest.php:422
‪TYPO3\CMS\Extbase\Tests\Unit\Object\Container\ContainerTest\getInstanceReturnsInstanceOfAClassWithTwoLevelDependency
‪getInstanceReturnsInstanceOfAClassWithTwoLevelDependency()
Definition: ContainerTest.php:115
‪TYPO3\CMS\Extbase\Tests\Unit\Object\Container\ContainerTest\getInstanceGivesTwoArgumentsToClassConstructor
‪getInstanceGivesTwoArgumentsToClassConstructor()
Definition: ContainerTest.php:492
‪TYPO3\CMS\Extbase\Tests\Unit\Object\Container\ContainerTest\getInstanceInjectsFirstMandatoryArgumentIfSecondIsGiven
‪getInstanceInjectsFirstMandatoryArgumentIfSecondIsGiven()
Definition: ContainerTest.php:574
‪TYPO3\CMS\Extbase\Tests\Unit\Object\Container\ContainerTest\prototypeWhichRequiresPrototypeViaSetterInjectionWorks
‪prototypeWhichRequiresPrototypeViaSetterInjectionWorks()
Definition: ContainerTest.php:314