‪TYPO3CMS  11.5
ReflectionServiceTest.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 
20 use Prophecy\PhpUnit\ProphecyTrait;
26 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
27 
34 class ‪ReflectionServiceTest extends UnitTestCase
35 {
36  use ProphecyTrait;
37 
42  {
43  $this->expectException(UnknownClassException::class);
44  $this->expectExceptionCode(1278450972);
45  $this->expectExceptionMessageMatches('/^.*Reflection failed\.$/');
46  $reflectionService = new ‪ReflectionService(new ‪NullFrontend('extbase'), 'ClassSchemata');
47  $reflectionService->getClassSchema('Foo\Bar\Not\Existing');
48  }
49 
54  {
55  $this->expectException(UnknownClassException::class);
56  $this->expectExceptionCode(1278450972);
57  $this->expectExceptionMessageMatches('/^.*Reflection failed\.$/');
58  $reflectionService = new ‪ReflectionService(new ‪NullFrontend('extbase'), 'ClassSchemata');
59  $reflectionService->getClassSchema(DummyClassWithInvalidTypeHint::class);
60  }
61 
66  {
67  $class = new class () {};
68 
69  $reflectionService = new ‪ReflectionService(new ‪NullFrontend('extbase'), 'ClassSchemata');
70  $serialized = serialize($reflectionService);
71  unset($reflectionService);
72 
73  $reflectionService = unserialize($serialized, ['allowed_classes' => [ReflectionService::class]]);
74 
75  self::assertInstanceOf(ReflectionService::class, $reflectionService);
76  self::assertInstanceOf(ClassSchema::class, $reflectionService->getClassSchema($class));
77  }
78 
83  {
84  $class = new class () {};
85 
86  $reflectionService = new ‪ReflectionService(new ‪NullFrontend('extbase'), 'ClassSchemata');
87  $serialized = serialize($reflectionService);
88  unset($reflectionService);
89 
90  $reflectionService = unserialize($serialized, ['allowed_classes' => [ReflectionService::class]]);
91 
92  self::assertInstanceOf(ReflectionService::class, $reflectionService);
93  self::assertInstanceOf(ClassSchema::class, $reflectionService->getClassSchema($class));
94  }
95 }
‪TYPO3\CMS\Extbase\Tests\Unit\Reflection\ReflectionServiceTest\getClassSchemaThrowsExceptionIfClassIsNotFound
‪getClassSchemaThrowsExceptionIfClassIsNotFound()
Definition: ReflectionServiceTest.php:40
‪TYPO3\CMS\Extbase\Tests\Unit\Reflection\ReflectionServiceTest
Definition: ReflectionServiceTest.php:35
‪TYPO3\CMS\Core\Cache\Frontend\NullFrontend
Definition: NullFrontend.php:29
‪TYPO3\CMS\Extbase\Reflection\ReflectionService
Definition: ReflectionService.php:28
‪TYPO3\CMS\Extbase\Reflection\ClassSchema
‪TYPO3\CMS\Extbase\Reflection\Exception\UnknownClassException
Definition: UnknownClassException.php:25
‪TYPO3\CMS\Extbase\Tests\Unit\Reflection\ReflectionServiceTest\reflectionServiceCanBeSerializedAndUnserialized
‪reflectionServiceCanBeSerializedAndUnserialized()
Definition: ReflectionServiceTest.php:64
‪TYPO3\CMS\Extbase\Tests\Unit\Reflection\ReflectionServiceTest\reflectionServiceCanBeSerializedAndUnserializedWithCacheManager
‪reflectionServiceCanBeSerializedAndUnserializedWithCacheManager()
Definition: ReflectionServiceTest.php:81
‪TYPO3\CMS\Extbase\Tests\Unit\Reflection\Fixture\DummyClassWithInvalidTypeHint
Definition: DummyClassWithInvalidTypeHint.php:24
‪TYPO3\CMS\Extbase\Tests\Unit\Reflection
‪TYPO3\CMS\Extbase\Tests\Unit\Reflection\ReflectionServiceTest\getClassSchemaThrowsExceptionIfTypeHintedClassWasNotFound
‪getClassSchemaThrowsExceptionIfTypeHintedClassWasNotFound()
Definition: ReflectionServiceTest.php:52