[TASK] Add unit test for short data type support in ReflectionService
[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 * @param bool $dummy
36 * @param int $foo
37 * @return void
38 */
39 public function fixtureMethodForMethodTagsValuesWithShortTypes($dummy, $foo) {
40 }
41
42 /**
43 * @test
44 */
45 public function getClassTagsValues() {
46 $service = new ReflectionService();
47 $classValues = $service->getClassTagsValues(get_class($this));
48 $this->assertEquals(array(
49 'firsttest' => array('test for reflection'),
50 'anothertest' => array('second test for reflection', 'second test for reflection with second value')
51 ), $classValues);
52 }
53
54 /**
55 * @test
56 */
57 public function getClassTagValues() {
58 $service = new ReflectionService();
59 $classValues = $service->getClassTagValues(get_class($this), 'firsttest');
60 $this->assertEquals(array(
61 'test for reflection',
62 ), $classValues);
63 }
64
65 /**
66 * @test
67 */
68 public function hasMethod() {
69 $service = new ReflectionService();
70 $this->assertTrue($service->hasMethod(get_class($this), 'fixtureMethodForMethodTagsValues'));
71 $this->assertFalse($service->hasMethod(get_class($this), 'notExistentMethod'));
72 }
73
74 /**
75 * @test
76 */
77 public function getMethodTagsValues() {
78 $service = new ReflectionService();
79 $tagsValues = $service->getMethodTagsValues(get_class($this), 'fixtureMethodForMethodTagsValues');
80 $this->assertEquals(array(
81 'param' => array('array $foo The foo parameter'),
82 'return' => array('void')
83 ), $tagsValues);
84 }
85
86 /**
87 * @test
88 */
89 public function getMethodParameters() {
90 $service = new ReflectionService();
91 $parameters = $service->getMethodParameters(get_class($this), 'fixtureMethodForMethodTagsValues');
92 $this->assertSame(array(
93 'foo' => array(
94 'position' => 0,
95 'byReference' => FALSE,
96 'array' => TRUE,
97 'optional' => FALSE,
98 'allowsNull' => FALSE,
99 'class' => NULL,
100 'type' => 'array'
101 )
102 ), $parameters);
103 }
104
105 /**
106 * @test
107 */
108 public function getMethodParametersWithShortTypeNames() {
109 $service = new ReflectionService();
110 $parameters = $service->getMethodParameters(get_class($this), 'fixtureMethodForMethodTagsValuesWithShortTypes');
111 $this->assertSame(array(
112 'dummy' => array(
113 'position' => 0,
114 'byReference' => FALSE,
115 'array' => FALSE,
116 'optional' => FALSE,
117 'allowsNull' => TRUE,
118 'class' => NULL,
119 'type' => 'boolean'
120 ),
121 'foo' => array(
122 'position' => 1,
123 'byReference' => FALSE,
124 'array' => FALSE,
125 'optional' => FALSE,
126 'allowsNull' => TRUE,
127 'class' => NULL,
128 'type' => 'integer'
129 )
130 ), $parameters);
131 }
132 }