[BUBFIX] Fix fatal error in Test
[Packages/TYPO3.CMS.git] / typo3 / sysext / extbase / Tests / Unit / Reflection / ServiceTest.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 ServiceTest 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 /**
40 * @test
41 */
42 public function getMethodTagsValues() {
43 $service = new \TYPO3\CMS\Extbase\Reflection\Service();
44 $tagsValues = $service->getMethodTagsValues('TYPO3\\CMS\\Extbase\\Tests\\Unit\\Reflection\\ServiceTest', 'fixtureMethodForMethodTagsValues');
45 $this->assertEquals(array(
46 'param' => array('array $foo The foo parameter'),
47 'return' => array('void')
48 ), $tagsValues);
49 }
50
51 /**
52 * @test
53 */
54 public function getMethodParameters() {
55 $service = new \TYPO3\CMS\Extbase\Reflection\Service();
56 $parameters = $service->getMethodParameters('TYPO3\\CMS\\Extbase\\Tests\\Unit\\Reflection\\ServiceTest', 'fixtureMethodForMethodTagsValues');
57 $this->assertEquals(array(
58 'foo' => array(
59 'position' => 0,
60 'byReference' => FALSE,
61 'array' => TRUE,
62 'optional' => FALSE,
63 'allowsNull' => FALSE,
64 'class' => NULL,
65 'type' => 'array'
66 )
67 ), $parameters);
68 }
69
70 /**
71 * @test
72 */
73 public function classSchemaForModelIsSetAggregateRootIfRepositoryClassIsFoundForNamespacedClasses() {
74 $className = uniqid('BazFixture');
75 eval ('
76 namespace Foo\\Bar\\Domain\\Model;
77 class ' . $className . ' extends \\TYPO3\\CMS\\Extbase\\DomainObject\\AbstractEntity {}
78 ');
79 eval ('
80 namespace Foo\\Bar\\Domain\\Repository;
81 class ' . $className . 'Repository {}
82 ');
83
84 $service = new \TYPO3\CMS\Extbase\Reflection\Service();
85 $service->injectObjectManager($this->objectManager);
86 $classSchema = $service->getClassSchema('Foo\\Bar\\Domain\\Model\\' . $className);
87 $this->assertTrue($classSchema->isAggregateRoot());
88 }
89
90 /**
91 * @test
92 */
93 public function classSchemaForModelIsSetAggregateRootIfRepositoryClassIsFoundForNotNamespacedClasses() {
94 $className = uniqid('BazFixture');
95 eval ('
96 class Foo_Bar_Domain_Model_' . $className . ' extends \\TYPO3\\CMS\\Extbase\\DomainObject\\AbstractEntity {}
97 ');
98 eval ('
99 class Foo_Bar_Domain_Repository_' . $className . 'Repository {}
100 ');
101
102 $service = new \TYPO3\CMS\Extbase\Reflection\Service();
103 $service->injectObjectManager($this->objectManager);
104 $classSchema = $service->getClassSchema('Foo_Bar_Domain_Model_' . $className);
105 $this->assertTrue($classSchema->isAggregateRoot());
106 }
107
108 }
109
110
111 ?>