[TASK] Remove dummy files from ext:tstemplate_* extensions
[Packages/TYPO3.CMS.git] / typo3 / sysext / extbase / Tests / Unit / Reflection / ReflectionServiceTest.php
1 <?php
2 namespace TYPO3\CMS\Extbase\Tests\Unit\Reflection;
3
4 /***************************************************************
5 * Copyright notice
6 *
7 * (c) 2009 Christopher Hlubek <hlubek@networkteam.com>
8 * All rights reserved
9 *
10 * This script is part of the TYPO3 project. The TYPO3 project is
11 * free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * The GNU General Public License can be found at
17 * http://www.gnu.org/copyleft/gpl.html.
18 *
19 * This script is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * This copyright notice MUST APPEAR in all copies of the script!
25 ***************************************************************/
26 /**
27 * Some functional tests for the backport of the reflection service
28 */
29 class ReflectionServiceTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase {
30
31 /**
32 * @param array $foo The foo parameter
33 * @return void
34 */
35 public function fixtureMethodForMethodTagsValues(array $foo) {
36 }
37
38 /**
39 * @test
40 */
41 public function getMethodTagsValues() {
42 $service = new \TYPO3\CMS\Extbase\Reflection\ReflectionService();
43 $tagsValues = $service->getMethodTagsValues('TYPO3\\CMS\\Extbase\\Tests\\Unit\\Reflection\\ReflectionServiceTest', 'fixtureMethodForMethodTagsValues');
44 $this->assertEquals(array(
45 'param' => array('array $foo The foo parameter'),
46 'return' => array('void')
47 ), $tagsValues);
48 }
49
50 /**
51 * @test
52 */
53 public function getMethodParameters() {
54 $service = new \TYPO3\CMS\Extbase\Reflection\ReflectionService();
55 $parameters = $service->getMethodParameters('TYPO3\\CMS\\Extbase\\Tests\\Unit\\Reflection\\ReflectionServiceTest', 'fixtureMethodForMethodTagsValues');
56 $this->assertEquals(array(
57 'foo' => array(
58 'position' => 0,
59 'byReference' => FALSE,
60 'array' => TRUE,
61 'optional' => FALSE,
62 'allowsNull' => FALSE,
63 'class' => NULL,
64 'type' => 'array'
65 )
66 ), $parameters);
67 }
68
69 /**
70 * @test
71 */
72 public function classSchemaForModelIsSetAggregateRootIfRepositoryClassIsFoundForNamespacedClasses() {
73 $className = uniqid('BazFixture');
74 eval ('
75 namespace Foo\\Bar\\Domain\\Model;
76 class ' . $className . ' extends \\TYPO3\\CMS\\Extbase\\DomainObject\\AbstractEntity {}
77 ');
78 eval ('
79 namespace Foo\\Bar\\Domain\\Repository;
80 class ' . $className . 'Repository {}
81 ');
82
83 $service = new \TYPO3\CMS\Extbase\Reflection\ReflectionService();
84 $service->injectObjectManager($this->objectManager);
85 $classSchema = $service->getClassSchema('Foo\\Bar\\Domain\\Model\\' . $className);
86 $this->assertTrue($classSchema->isAggregateRoot());
87 }
88
89 /**
90 * @test
91 */
92 public function classSchemaForModelIsSetAggregateRootIfRepositoryClassIsFoundForNotNamespacedClasses() {
93 $className = uniqid('BazFixture');
94 eval ('
95 class Foo_Bar_Domain_Model_' . $className . ' extends \\TYPO3\\CMS\\Extbase\\DomainObject\\AbstractEntity {}
96 ');
97 eval ('
98 class Foo_Bar_Domain_Repository_' . $className . 'Repository {}
99 ');
100
101 $service = new \TYPO3\CMS\Extbase\Reflection\ReflectionService();
102 $service->injectObjectManager($this->objectManager);
103 $classSchema = $service->getClassSchema('Foo_Bar_Domain_Model_' . $className);
104 $this->assertTrue($classSchema->isAggregateRoot());
105 }
106 }
107
108 ?>