‪TYPO3CMS  10.4
MethodTest.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
22 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
23 
27 class ‪MethodTest extends UnitTestCase
28 {
33  {
34  $classSchema = new ‪ClassSchema(DummyClassWithAllTypesOfMethods::class);
35 
36  $methodDefinition = $classSchema->getMethod('publicMethod');
37  self::assertTrue($methodDefinition->isPublic());
38  self::assertFalse($methodDefinition->isProtected());
39  self::assertFalse($methodDefinition->isPrivate());
40 
41  $methodDefinition = $classSchema->getMethod('protectedMethod');
42  self::assertFalse($methodDefinition->isPublic());
43  self::assertTrue($methodDefinition->isProtected());
44  self::assertFalse($methodDefinition->isPrivate());
45 
46  $methodDefinition = $classSchema->getMethod('privateMethod');
47  self::assertFalse($methodDefinition->isPublic());
48  self::assertFalse($methodDefinition->isProtected());
49  self::assertTrue($methodDefinition->isPrivate());
50  }
51 
56  {
57  $classSchema = new ‪ClassSchema(DummyClassWithAllTypesOfMethods::class);
58  self::assertTrue($classSchema->hasInjectMethods());
59 
60  $methodDefinition = $classSchema->getMethod('injectSettings');
61  self::assertFalse($methodDefinition->isInjectMethod());
62 
63  $methodDefinition = $classSchema->getMethod('injectMethodWithoutParam');
64  self::assertFalse($methodDefinition->isInjectMethod());
65 
66  $methodDefinition = $classSchema->getMethod('injectMethodThatIsProtected');
67  self::assertFalse($methodDefinition->isInjectMethod());
68 
69  $methodDefinition = $classSchema->getMethod('injectFoo');
70  self::assertTrue($methodDefinition->isInjectMethod());
71 
72  ‪$injectMethods = $classSchema->getInjectMethods();
73  self::assertArrayHasKey('injectFoo', ‪$injectMethods);
74  }
75 
80  {
81  self::assertTrue(
82  (new ‪ClassSchema(DummyClassWithAllTypesOfMethods::class))
83  ->‪getMethod('staticMethod')
84  ->isStatic()
85  );
86  }
87 }
‪TYPO3\CMS\Extbase\Reflection\ClassSchema\getMethod
‪Method getMethod(string $methodName)
Definition: ClassSchema.php:541
‪TYPO3\CMS\Extbase\Reflection\ClassSchema
‪TYPO3\CMS\Extbase\Tests\Unit\Reflection\ClassSchema\MethodTest
Definition: MethodTest.php:28
‪TYPO3\CMS\Extbase\Tests\Unit\Reflection\ClassSchema\MethodTest\classSchemaDetectsInjectMethods
‪classSchemaDetectsInjectMethods()
Definition: MethodTest.php:55
‪TYPO3\CMS\Extbase\Tests\Unit\Reflection\ClassSchema\MethodTest\classSchemaDetectsStaticMethods
‪classSchemaDetectsStaticMethods()
Definition: MethodTest.php:79
‪TYPO3\CMS\Extbase\Tests\Unit\Reflection\ClassSchema\MethodTest\classSchemaDetectsMethodVisibility
‪classSchemaDetectsMethodVisibility()
Definition: MethodTest.php:32
‪TYPO3\CMS\Extbase\Reflection\ClassSchema
Definition: ClassSchema.php:55
‪TYPO3\CMS\Extbase\Tests\Unit\Reflection\ClassSchema
Definition: MethodParameterTest.php:18
‪TYPO3\CMS\Extbase\Tests\Unit\Reflection\Fixture\DummyClassWithAllTypesOfMethods
Definition: DummyClassWithAllTypesOfMethods.php:22
‪TYPO3\CMS\Extbase\Reflection\ClassSchema\$injectMethods
‪array $injectMethods
Definition: ClassSchema.php:95