2 declare(strict_types = 1);
25 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
40 $this->expectException(UnknownClassException::class);
41 $this->expectExceptionCode(1278450972);
42 $this->expectExceptionMessage(
'Class Foo\Bar\Not\Existing does not exist. Reflection failed.');
44 $reflectionService->getClassSchema(
'Foo\Bar\Not\Existing');
52 $this->expectException(UnknownClassException::class);
53 $this->expectExceptionCode(1278450972);
54 $this->expectExceptionMessage(
'Class Foo\Bar\Not\Found does not exist. Reflection failed.');
56 $reflectionService->getClassSchema(DummyClassWithInvalidTypeHint::class);
64 $class =
new class() {
68 $serialized = serialize($reflectionService);
69 unset($reflectionService);
71 $reflectionService = unserialize($serialized, [
'allowed_classes' => [ReflectionService::class]]);
73 self::assertInstanceOf(ReflectionService::class, $reflectionService);
74 self::assertInstanceOf(ClassSchema::class, $reflectionService->getClassSchema($class));
82 $cacheProphecy = $this->prophesize(FrontendInterface::class);
83 $cacheProphecy->get(
'ClassSchematas')->willReturn(
false);
84 $cacheManager = $this->prophesize(CacheManager::class);
85 $cacheManager->getCache(
'extbase_reflection')->willReturn($cacheProphecy->reveal());
87 $class =
new class() {
91 $serialized = serialize($reflectionService);
92 unset($reflectionService);
94 $reflectionService = unserialize($serialized, [
'allowed_classes' => [ReflectionService::class]]);
96 self::assertInstanceOf(ReflectionService::class, $reflectionService);
97 self::assertInstanceOf(ClassSchema::class, $reflectionService->getClassSchema($class));
105 $insecureString = file_get_contents(__DIR__ .
'/Fixture/InsecureSerializedReflectionService.txt');
106 $reflectionService = unserialize($insecureString);
108 $reflectionClass = new \ReflectionClass($reflectionService);
109 $classSchemaProperty = $reflectionClass->getProperty(
'classSchemata');
110 $classSchemaProperty->setAccessible(
true);
112 self::assertSame([], $classSchemaProperty->getValue($reflectionService));