[TASK] Re-work/simplify copyright header in PHP files - Part 8
[Packages/TYPO3.CMS.git] / typo3 / sysext / extbase / Tests / Unit / Reflection / ClassSchemaTest.php
1 <?php
2 namespace TYPO3\CMS\Extbase\Tests\Unit\Reflection;
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 ClassSchemaTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
21
22 /**
23 * @test
24 */
25 public function classSchemaForModelIsSetAggregateRootIfRepositoryClassIsFoundForNamespacedClasses() {
26 $className = uniqid('BazFixture');
27 eval ('
28 namespace Foo\\Bar\\Domain\\Model;
29 class ' . $className . ' extends \\TYPO3\\CMS\\Extbase\\DomainObject\\AbstractEntity {}
30 ');
31 eval ('
32 namespace Foo\\Bar\\Domain\\Repository;
33 class ' . $className . 'Repository {}
34 ');
35
36 /** @var \TYPO3\CMS\Extbase\Object\ObjectManagerInterface|\PHPUnit_Framework_MockObject_MockObject $objectManager */
37 $objectManager = $this->getMock('TYPO3\\CMS\\Extbase\\Object\\ObjectManager');
38 $mockClassSchema = $this->getAccessibleMock('TYPO3\\CMS\\Extbase\\Reflection\\ClassSchema', array('dummy'), array('Foo\\Bar\\Domain\\Model\\' . $className));
39 $mockClassSchema->_set('typeHandlingService', $this->getMock('TYPO3\\CMS\\Extbase\\Service\\TypeHandlingService'));
40 $objectManager->expects($this->once())->method('get')->will($this->returnValue($mockClassSchema));
41
42 /** @var \TYPO3\CMS\Extbase\Reflection\ReflectionService $service */
43 $service = $this->getAccessibleMock('TYPO3\\CMS\\Extbase\\Reflection\\ReflectionService', array('dummy'));
44 $service->_set('objectManager', $objectManager);
45 $classSchema = $service->getClassSchema('Foo\\Bar\\Domain\\Model\\' . $className);
46 $this->assertTrue($classSchema->isAggregateRoot());
47 }
48
49 /**
50 * @test
51 */
52 public function classSchemaForModelIsSetAggregateRootIfRepositoryClassIsFoundForNotNamespacedClasses() {
53 $className = uniqid('BazFixture');
54 eval ('
55 class Foo_Bar_Domain_Model_' . $className . ' extends \\TYPO3\\CMS\\Extbase\\DomainObject\\AbstractEntity {}
56 ');
57 eval ('
58 class Foo_Bar_Domain_Repository_' . $className . 'Repository {}
59 ');
60
61 /** @var \TYPO3\CMS\Extbase\Object\ObjectManagerInterface|\PHPUnit_Framework_MockObject_MockObject $objectManager */
62 $objectManager = $this->getMock('TYPO3\\CMS\\Extbase\\Object\\ObjectManager');
63 $mockClassSchema = $this->getAccessibleMock('TYPO3\\CMS\\Extbase\\Reflection\\ClassSchema', array('dummy'), array('Foo_Bar_Domain_Model_' . $className));
64 $mockClassSchema->_set('typeHandlingService', $this->getMock('TYPO3\\CMS\\Extbase\\Service\\TypeHandlingService'));
65 $objectManager->expects($this->once())->method('get')->will($this->returnValue($mockClassSchema));
66
67 $service = $this->getAccessibleMock('TYPO3\CMS\Extbase\Reflection\ReflectionService', array('dummy'));
68 $service->_set('objectManager', $objectManager);
69 $classSchema = $service->getClassSchema('Foo_Bar_Domain_Model_' . $className);
70 $this->assertTrue($classSchema->isAggregateRoot());
71 }
72
73 }