TYPO3 CMS  TYPO3_8-7
ClassInfoFactoryTest.php
Go to the documentation of this file.
1 <?php
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
17 
21 class ClassInfoFactoryTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
22 {
26  protected $classInfoFactory;
27 
31  protected function setUp()
32  {
33  $this->classInfoFactory = new \TYPO3\CMS\Extbase\Object\Container\ClassInfoFactory();
34  }
35 
40  {
41  $this->expectException(UnknownObjectException::class);
42  $this->expectExceptionCode(1289386765);
43  $this->classInfoFactory->buildClassInfoFromClassName('SomeNonExistingClass');
44  }
45 
50  {
51  $classInfo = $this->classInfoFactory->buildClassInfoFromClassName('t3lib_object_tests_class_with_injectsettings');
52  $this->assertEquals(['injectFoo' => 't3lib_object_tests_resolveablecyclic1'], $classInfo->getInjectMethods());
53  }
54 
59  {
60  $classInfo = $this->classInfoFactory->buildClassInfoFromClassName(\TYPO3\CMS\Extbase\Tests\Fixture\ClassWithInjectProperties::class);
61  $this->assertEquals(['secondDummyClass' => \TYPO3\CMS\Extbase\Tests\Fixture\SecondDummyClass::class], $classInfo->getInjectProperties());
62  }
63 
67  public function buildClassInfoReturnsCustomClassInfoForDateTime()
68  {
70  $classInfoFactory = $this->getMockBuilder(\TYPO3\CMS\Extbase\Object\Container\ClassInfoFactory::class)
71  ->setMethods(['getConstructorArguments'])
72  ->getMock();
73  $classInfoFactory->expects($this->never())->method('getConstructorArguments');
74 
75  $classInfo = $classInfoFactory->buildClassInfoFromClassName('DateTime');
76  $this->assertEquals(
77  new \TYPO3\CMS\Extbase\Object\Container\ClassInfo('DateTime', [], [], false, false, []),
78  $classInfo
79  );
80  }
81 }