[CLEANUP] Remove obsolete require_once from test files
[Packages/TYPO3.CMS.git] / typo3 / sysext / extbase / Tests / Unit / Object / Container / ClassInfoFactoryTest.php
1 <?php
2 namespace TYPO3\CMS\Extbase\Tests\Unit\Object\Container;
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 */
16
17 /**
18 * Test case
19 */
20 class ClassInfoFactoryTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
21
22 /**
23 * @var \TYPO3\CMS\Extbase\Object\Container\ClassInfoFactory
24 */
25 protected $classInfoFactory;
26
27 /**
28 * Set up
29 */
30 protected function setUp() {
31 $this->classInfoFactory = new \TYPO3\CMS\Extbase\Object\Container\ClassInfoFactory();
32 }
33
34 /**
35 * @test
36 * @expectedException \TYPO3\CMS\Extbase\Object\Container\Exception\UnknownObjectException
37 */
38 public function buildClassInfoFromClassNameThrowsExceptionIfGivenClassNameCantBeReflected() {
39 $this->classInfoFactory->buildClassInfoFromClassName('SomeNonExistingClass');
40 }
41
42 /**
43 * @test
44 */
45 public function buildClassInfoDoesNotIncludeInjectSettingsMethodInListOfInjectMethods() {
46 $classInfo = $this->classInfoFactory->buildClassInfoFromClassName('t3lib_object_tests_class_with_injectsettings');
47 $this->assertEquals(array('injectFoo' => 't3lib_object_tests_resolveablecyclic1'), $classInfo->getInjectMethods());
48 }
49
50 /**
51 * @test
52 */
53 public function buildClassInfoDetectsPropertiesToInjectByAnnotation() {
54 $classInfo = $this->classInfoFactory->buildClassInfoFromClassName(\TYPO3\CMS\Extbase\Tests\Fixture\ClassWithInjectProperties::class);
55 $this->assertEquals(array('secondDummyClass' => \TYPO3\CMS\Extbase\Tests\Fixture\SecondDummyClass::class), $classInfo->getInjectProperties());
56 }
57
58 /**
59 * @test
60 */
61 public function buildClassInfoReturnsCustomClassInfoForDateTime() {
62
63 /** @var \PHPUnit_Framework_MockObject_MockObject | \TYPO3\CMS\Extbase\Object\Container\ClassInfoFactory $classInfoFactory */
64 $classInfoFactory = $this->getMock(\TYPO3\CMS\Extbase\Object\Container\ClassInfoFactory::class, array('dummy'));
65 $classInfoFactory->expects($this->never())->method('getConstructorArguments');
66
67 $classInfo = $classInfoFactory->buildClassInfoFromClassName('DateTime');
68 $this->assertEquals(
69 new \TYPO3\CMS\Extbase\Object\Container\ClassInfo('DateTime', array(), array(), FALSE, FALSE, array()),
70 $classInfo
71 );
72 }
73
74 }