e8447dda0d72f053f3400c9064faf6090defdb61
[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 eval ('
75 namespace Foo\\Bar\\Domain\\Model;
76 class BazFixture extends \\TYPO3\\CMS\\Extbase\\DomainObject\\AbstractEntity {}
77 ');
78 eval ('
79 namespace Foo\\Bar\\Domain\\Repository;
80 class BazFixtureRepository {}
81 ');
82
83 $service = new \TYPO3\CMS\Extbase\Reflection\Service();
84 $service->injectObjectManager($this->objectManager);
85 $classSchema = $service->getClassSchema('Foo\\Bar\\Domain\\Model\\BazFixture');
86 $this->assertTrue($classSchema->isAggregateRoot());
87 }
88
89 /**
90 * @test
91 */
92 public function classSchemaForModelIsSetAggregateRootIfRepositoryClassIsFoundForNotNamespacedClasses() {
93 eval ('
94 class Foo_Bar_Domain_Model_BazFixture extends \\TYPO3\\CMS\\Extbase\\DomainObject\\AbstractEntity {}
95 ');
96 eval ('
97 class Foo_Bar_Domain_Repository_BazFixtureRepository {}
98 ');
99
100 $service = new \TYPO3\CMS\Extbase\Reflection\Service();
101 $service->injectObjectManager($this->objectManager);
102 $classSchema = $service->getClassSchema('Foo_Bar_Domain_Model_BazFixture');
103 $this->assertTrue($classSchema->isAggregateRoot());
104 }
105
106 }
107
108
109 ?>