TYPO3 CMS  TYPO3_7-6
ReflectionServiceTest.php
Go to the documentation of this file.
1 <?php
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 
19 
27 {
32  public function fixtureMethodForMethodTagsValues(array $foo)
33  {
34  }
35 
41  public function fixtureMethodForMethodTagsValuesWithShortTypes($dummy, $foo)
42  {
43  }
44 
48  public function getClassTagsValues()
49  {
50  $service = new ReflectionService();
51  $classValues = $service->getClassTagsValues(get_class($this));
52  $this->assertEquals([
53  'firsttest' => ['test for reflection'],
54  'anothertest' => ['second test for reflection', 'second test for reflection with second value']
55  ], $classValues);
56  }
57 
61  public function getClassTagValues()
62  {
63  $service = new ReflectionService();
64  $classValues = $service->getClassTagValues(get_class($this), 'firsttest');
65  $this->assertEquals([
66  'test for reflection',
67  ], $classValues);
68  }
69 
73  public function hasMethod()
74  {
75  $service = new ReflectionService();
76  $this->assertTrue($service->hasMethod(get_class($this), 'fixtureMethodForMethodTagsValues'));
77  $this->assertFalse($service->hasMethod(get_class($this), 'notExistentMethod'));
78  }
79 
83  public function getMethodTagsValues()
84  {
85  $service = new ReflectionService();
86  $tagsValues = $service->getMethodTagsValues(get_class($this), 'fixtureMethodForMethodTagsValues');
87  $this->assertEquals([
88  'param' => ['array $foo The foo parameter'],
89  'return' => ['void']
90  ], $tagsValues);
91  }
92 
96  public function getMethodParameters()
97  {
98  $service = new ReflectionService();
99  $parameters = $service->getMethodParameters(get_class($this), 'fixtureMethodForMethodTagsValues');
100  $this->assertSame([
101  'foo' => [
102  'position' => 0,
103  'byReference' => false,
104  'array' => true,
105  'optional' => false,
106  'allowsNull' => false,
107  'class' => null,
108  'type' => 'array'
109  ]
110  ], $parameters);
111  }
112 
117  {
118  $service = new ReflectionService();
119  $parameters = $service->getMethodParameters(get_class($this), 'fixtureMethodForMethodTagsValuesWithShortTypes');
120  $this->assertSame([
121  'dummy' => [
122  'position' => 0,
123  'byReference' => false,
124  'array' => false,
125  'optional' => false,
126  'allowsNull' => true,
127  'class' => null,
128  'type' => 'boolean'
129  ],
130  'foo' => [
131  'position' => 1,
132  'byReference' => false,
133  'array' => false,
134  'optional' => false,
135  'allowsNull' => true,
136  'class' => null,
137  'type' => 'integer'
138  ]
139  ], $parameters);
140  }
141 }