Commit cd4227e2 authored by Alexander Schnitzler's avatar Alexander Schnitzler Committed by Christian Kuhn
Browse files

[TASK] Test ClassSchema detects php 7.4 property types

Since TYPO3 11 requires php >= 7.4 and since symfony
components support php 7.4 type hint evaluations as
well, some tests have been added to verify that when
building ClassSchema instances, property types are
properly detected.

Releases: master
Resolves: #93037
Change-Id: Ia50934731838d2bdccc2e6bdb4cdebb3b1a096b9
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/67077


Tested-by: default avatarTYPO3com <noreply@typo3.com>
Tested-by: Oliver Bartsch's avatarOliver Bartsch <bo@cedev.de>
Tested-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Oliver Bartsch's avatarOliver Bartsch <bo@cedev.de>
Reviewed-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
parent d24489a7
......@@ -180,4 +180,26 @@ class PropertyTest extends UnitTestCase
$property->getValidators()
);
}
/**
* @test
*/
public function classSchemaDetectsTypeFromPropertyWithStringTypeHint(): void
{
$property = (new ClassSchema(DummyClassWithAllTypesOfProperties::class))
->getProperty('stringTypedProperty');
self::assertSame('string', $property->getType());
}
/**
* @test
*/
public function classSchemaDetectsTypeFromPropertyWithNullableStringTypeHint(): void
{
$property = (new ClassSchema(DummyClassWithAllTypesOfProperties::class))
->getProperty('nullableStringTypedProperty');
self::assertSame('string', $property->getType());
}
}
......@@ -72,6 +72,8 @@ class ClassSchemaTest extends UnitTestCase
'privateStaticProperty',
'publicPropertyWithDefaultValue',
'publicStaticPropertyWithDefaultValue',
'stringTypedProperty',
'nullableStringTypedProperty',
'propertyWithIgnoredTags',
'propertyWithInjectAnnotation',
'propertyWithTransientAnnotation',
......
......@@ -41,6 +41,10 @@ class DummyClassWithAllTypesOfProperties extends AbstractEntity
public static $publicStaticPropertyWithDefaultValue = 'foo';
public string $stringTypedProperty = '';
public ?string $nullableStringTypedProperty = null;
/**
* @license
* @copyright
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment