TYPO3 CMS  TYPO3_8-7
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 
18 
25 class ReflectionServiceTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
26 {
31  public function fixtureMethodForMethodTagsValues(array $foo)
32  {
33  }
34 
39  public function fixtureMethodForMethodTagsValuesWithShortTypes($dummy, $foo)
40  {
41  }
42 
46  public function getClassTagsValues()
47  {
48  $service = new ReflectionService();
49  $classValues = $service->getClassTagsValues(get_class($this));
50  $this->assertEquals([
51  'firsttest' => ['test for reflection'],
52  'anothertest' => ['second test for reflection', 'second test for reflection with second value']
53  ], $classValues);
54  }
55 
59  public function getClassTagValues()
60  {
61  $service = new ReflectionService();
62  $classValues = $service->getClassTagValues(get_class($this), 'firsttest');
63  $this->assertEquals([
64  'test for reflection',
65  ], $classValues);
66  }
67 
71  public function hasMethod()
72  {
73  $service = new ReflectionService();
74  $this->assertTrue($service->hasMethod(get_class($this), 'fixtureMethodForMethodTagsValues'));
75  $this->assertFalse($service->hasMethod(get_class($this), 'notExistentMethod'));
76  }
77 
81  public function getMethodTagsValues()
82  {
83  $service = new ReflectionService();
84  $tagsValues = $service->getMethodTagsValues(get_class($this), 'fixtureMethodForMethodTagsValues');
85  $this->assertEquals([
86  'param' => ['array $foo The foo parameter'],
87  'return' => ['string']
88  ], $tagsValues);
89  }
90 
94  public function getMethodParameters()
95  {
96  $service = new ReflectionService();
97  $parameters = $service->getMethodParameters(get_class($this), 'fixtureMethodForMethodTagsValues');
98  $this->assertSame([
99  'foo' => [
100  'position' => 0,
101  'byReference' => false,
102  'array' => true,
103  'optional' => false,
104  'allowsNull' => false,
105  'class' => null,
106  'type' => 'array'
107  ]
108  ], $parameters);
109  }
110 
115  {
116  $service = new ReflectionService();
117  $parameters = $service->getMethodParameters(get_class($this), 'fixtureMethodForMethodTagsValuesWithShortTypes');
118  $this->assertSame([
119  'dummy' => [
120  'position' => 0,
121  'byReference' => false,
122  'array' => false,
123  'optional' => false,
124  'allowsNull' => true,
125  'class' => null,
126  'type' => 'boolean'
127  ],
128  'foo' => [
129  'position' => 1,
130  'byReference' => false,
131  'array' => false,
132  'optional' => false,
133  'allowsNull' => true,
134  'class' => null,
135  'type' => 'integer'
136  ]
137  ], $parameters);
138  }
139 }