2da992be6d86849ec62f3d5c434e78bb6bc20251
[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 * 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 use TYPO3\CMS\Core\Tests\UnitTestCase;
17 use TYPO3\CMS\Extbase\Reflection\ReflectionService;
18
19 /**
20 * Test case
21 * @firsttest test for reflection
22 * @anothertest second test for reflection
23 * @anothertest second test for reflection with second value
24 */
25 class ReflectionServiceTest extends UnitTestCase {
26
27 /**
28 * @param array $foo The foo parameter
29 * @return void
30 */
31 public function fixtureMethodForMethodTagsValues(array $foo) {
32 }
33
34 /**
35 * @test
36 */
37 public function getClassTagsValues() {
38 $service = new ReflectionService();
39 $classValues = $service->getClassTagsValues(get_class($this));
40 $this->assertEquals(array(
41 'firsttest' => array('test for reflection'),
42 'anothertest' => array('second test for reflection', 'second test for reflection with second value')
43 ), $classValues);
44 }
45
46 /**
47 * @test
48 */
49 public function getClassTagValues() {
50 $service = new ReflectionService();
51 $classValues = $service->getClassTagValues(get_class($this), 'firsttest');
52 $this->assertEquals(array(
53 'test for reflection',
54 ), $classValues);
55 }
56
57 /**
58 * @test
59 */
60 public function hasMethod() {
61 $service = new ReflectionService();
62 $this->assertTrue($service->hasMethod(get_class($this), 'fixtureMethodForMethodTagsValues'));
63 $this->assertFalse($service->hasMethod(get_class($this), 'notExistentMethod'));
64 }
65
66 /**
67 * @test
68 */
69 public function getMethodTagsValues() {
70 $service = new ReflectionService();
71 $tagsValues = $service->getMethodTagsValues(get_class($this), 'fixtureMethodForMethodTagsValues');
72 $this->assertEquals(array(
73 'param' => array('array $foo The foo parameter'),
74 'return' => array('void')
75 ), $tagsValues);
76 }
77
78 /**
79 * @test
80 */
81 public function getMethodParameters() {
82 $service = new ReflectionService();
83 $parameters = $service->getMethodParameters(get_class($this), 'fixtureMethodForMethodTagsValues');
84 $this->assertEquals(array(
85 'foo' => array(
86 'position' => 0,
87 'byReference' => FALSE,
88 'array' => TRUE,
89 'optional' => FALSE,
90 'allowsNull' => FALSE,
91 'class' => NULL,
92 'type' => 'array'
93 )
94 ), $parameters);
95 }
96 }