Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita608e65

Browse files
committed
test(symfony): skip legacy type
1 parent57e0b1e commita608e65

8 files changed

+266
-220
lines changed

‎Tests/Validator/Metadata/Property/Restriction/PropertySchemaChoiceRestrictionTest.php‎

Lines changed: 76 additions & 69 deletions
Large diffs are not rendered by default.

‎Tests/Validator/Metadata/Property/Restriction/PropertySchemaGreaterThanOrEqualRestrictionTest.php‎

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,20 @@ protected function setUp(): void
4343
#[IgnoreDeprecations]
4444
publicfunctiontestSupports():void
4545
{
46-
foreach ($this->supportsProvider()as [$constraint,$propertyMetadata,$expectedResult]) {
46+
if (!class_exists(LegacyType::class)) {
47+
$this->markTestSkipped('symfony/property-info is not installed.');
48+
}
49+
50+
$cases = [
51+
'supported int/float with union types' => [newGreaterThanOrEqual(value:10), (newApiProperty())->withBuiltinTypes([newLegacyType(LegacyType::BUILTIN_TYPE_INT),newLegacyType(LegacyType::BUILTIN_TYPE_FLOAT)]),true],
52+
'supported int' => [newGreaterThanOrEqual(value:10), (newApiProperty())->withBuiltinTypes([newLegacyType(LegacyType::BUILTIN_TYPE_INT)]),true],
53+
'supported float' => [newGreaterThanOrEqual(value:10.99), (newApiProperty())->withBuiltinTypes([newLegacyType(LegacyType::BUILTIN_TYPE_FLOAT)]),true],
54+
'supported positive or zero' => [newPositiveOrZero(), (newApiProperty())->withBuiltinTypes([newLegacyType(LegacyType::BUILTIN_TYPE_INT)]),true],
55+
'not supported positive' => [newPositive(), (newApiProperty())->withBuiltinTypes([newLegacyType(LegacyType::BUILTIN_TYPE_INT)]),false],
56+
'not supported property path' => [newGreaterThanOrEqual(propertyPath:'greaterThanMe'), (newApiProperty())->withBuiltinTypes([newLegacyType(LegacyType::BUILTIN_TYPE_INT)]),false],
57+
];
58+
59+
foreach ($casesas [$constraint,$propertyMetadata,$expectedResult]) {
4760
self::assertSame($expectedResult,$this->propertySchemaGreaterThanOrEqualRestriction->supports($constraint,$propertyMetadata));
4861
}
4962
}
@@ -54,16 +67,6 @@ public function testSupportsWithNativeType(Constraint $constraint, ApiProperty $
5467
self::assertSame($expectedResult,$this->propertySchemaGreaterThanOrEqualRestriction->supports($constraint,$propertyMetadata));
5568
}
5669

57-
publicstaticfunctionsupportsProvider():\Generator
58-
{
59-
yield'supported int/float with union types' => [newGreaterThanOrEqual(value:10), (newApiProperty())->withBuiltinTypes([newLegacyType(LegacyType::BUILTIN_TYPE_INT),newLegacyType(LegacyType::BUILTIN_TYPE_FLOAT)]),true];
60-
yield'supported int' => [newGreaterThanOrEqual(value:10), (newApiProperty())->withBuiltinTypes([newLegacyType(LegacyType::BUILTIN_TYPE_INT)]),true];
61-
yield'supported float' => [newGreaterThanOrEqual(value:10.99), (newApiProperty())->withBuiltinTypes([newLegacyType(LegacyType::BUILTIN_TYPE_FLOAT)]),true];
62-
yield'supported positive or zero' => [newPositiveOrZero(), (newApiProperty())->withBuiltinTypes([newLegacyType(LegacyType::BUILTIN_TYPE_INT)]),true];
63-
yield'not supported positive' => [newPositive(), (newApiProperty())->withBuiltinTypes([newLegacyType(LegacyType::BUILTIN_TYPE_INT)]),false];
64-
yield'not supported property path' => [newGreaterThanOrEqual(propertyPath:'greaterThanMe'), (newApiProperty())->withBuiltinTypes([newLegacyType(LegacyType::BUILTIN_TYPE_INT)]),false];
65-
}
66-
6770
publicstaticfunctionsupportsProviderWithNativeType():\Generator
6871
{
6972
yield'native type: supported int/float with union types' => [newGreaterThanOrEqual(value:10), (newApiProperty())->withNativeType(Type::union(Type::int(), Type::float())),true];
@@ -77,6 +80,10 @@ public static function supportsProviderWithNativeType(): \Generator
7780
#[IgnoreDeprecations]
7881
publicfunctiontestCreate():void
7982
{
83+
if (!class_exists(LegacyType::class)) {
84+
$this->markTestSkipped('symfony/property-info is not installed.');
85+
}
86+
8087
self::assertEquals(['minimum' =>10],$this->propertySchemaGreaterThanOrEqualRestriction->create(newGreaterThanOrEqual(value:10), (newApiProperty())->withBuiltinTypes([newLegacyType(LegacyType::BUILTIN_TYPE_INT)])));
8188
}
8289

‎Tests/Validator/Metadata/Property/Restriction/PropertySchemaGreaterThanRestrictionTest.php‎

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,20 @@ protected function setUp(): void
4343
#[IgnoreDeprecations]
4444
publicfunctiontestSupports():void
4545
{
46-
foreach ($this->supportsProvider()as [$constraint,$propertyMetadata,$expectedResult]) {
46+
if (!class_exists(LegacyType::class)) {
47+
$this->markTestSkipped('symfony/property-info is not installed.');
48+
}
49+
50+
$cases = [
51+
'supported int/float with union types' => [newGreaterThan(value:10), (newApiProperty())->withBuiltinTypes([newLegacyType(LegacyType::BUILTIN_TYPE_INT),newLegacyType(LegacyType::BUILTIN_TYPE_FLOAT)]),true],
52+
'supported int' => [newGreaterThan(value:10), (newApiProperty())->withBuiltinTypes([newLegacyType(LegacyType::BUILTIN_TYPE_INT)]),true],
53+
'supported float' => [newGreaterThan(value:10.99), (newApiProperty())->withBuiltinTypes([newLegacyType(LegacyType::BUILTIN_TYPE_FLOAT)]),true],
54+
'supported positive' => [newPositive(), (newApiProperty())->withBuiltinTypes([newLegacyType(LegacyType::BUILTIN_TYPE_INT)]),true],
55+
'not supported positive or zero' => [newPositiveOrZero(), (newApiProperty())->withBuiltinTypes([newLegacyType(LegacyType::BUILTIN_TYPE_INT)]),false],
56+
'not supported property path' => [newGreaterThan(propertyPath:'greaterThanMe'), (newApiProperty())->withBuiltinTypes([newLegacyType(LegacyType::BUILTIN_TYPE_INT)]),false],
57+
];
58+
59+
foreach ($casesas [$constraint,$propertyMetadata,$expectedResult]) {
4760
self::assertSame($expectedResult,$this->propertySchemaGreaterThanRestriction->supports($constraint,$propertyMetadata));
4861
}
4962
}
@@ -54,16 +67,6 @@ public function testSupportsWithNativeType(Constraint $constraint, ApiProperty $
5467
self::assertSame($expectedResult,$this->propertySchemaGreaterThanRestriction->supports($constraint,$propertyMetadata));
5568
}
5669

57-
publicstaticfunctionsupportsProvider():\Generator
58-
{
59-
yield'supported int/float with union types' => [newGreaterThan(value:10), (newApiProperty())->withBuiltinTypes([newLegacyType(LegacyType::BUILTIN_TYPE_INT),newLegacyType(LegacyType::BUILTIN_TYPE_FLOAT)]),true];
60-
yield'supported int' => [newGreaterThan(value:10), (newApiProperty())->withBuiltinTypes([newLegacyType(LegacyType::BUILTIN_TYPE_INT)]),true];
61-
yield'supported float' => [newGreaterThan(value:10.99), (newApiProperty())->withBuiltinTypes([newLegacyType(LegacyType::BUILTIN_TYPE_FLOAT)]),true];
62-
yield'supported positive' => [newPositive(), (newApiProperty())->withBuiltinTypes([newLegacyType(LegacyType::BUILTIN_TYPE_INT)]),true];
63-
yield'not supported positive or zero' => [newPositiveOrZero(), (newApiProperty())->withBuiltinTypes([newLegacyType(LegacyType::BUILTIN_TYPE_INT)]),false];
64-
yield'not supported property path' => [newGreaterThan(propertyPath:'greaterThanMe'), (newApiProperty())->withBuiltinTypes([newLegacyType(LegacyType::BUILTIN_TYPE_INT)]),false];
65-
}
66-
6770
publicstaticfunctionsupportsProviderWithNativeType():\Generator
6871
{
6972
yield'native type: supported int/float with union types' => [newGreaterThan(value:10), (newApiProperty())->withNativeType(Type::union(Type::int(), Type::float())),true];
@@ -77,6 +80,10 @@ public static function supportsProviderWithNativeType(): \Generator
7780
#[IgnoreDeprecations]
7881
publicfunctiontestCreate():void
7982
{
83+
if (!class_exists(LegacyType::class)) {
84+
$this->markTestSkipped('symfony/property-info is not installed.');
85+
}
86+
8087
self::assertEquals([
8188
'exclusiveMinimum' =>10,
8289
'minimum' =>10,

‎Tests/Validator/Metadata/Property/Restriction/PropertySchemaLessThanOrEqualRestrictionTest.php‎

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,20 @@ protected function setUp(): void
4343
#[IgnoreDeprecations]
4444
publicfunctiontestSupports():void
4545
{
46-
foreach ($this->supportsProvider()as [$constraint,$propertyMetadata,$expectedResult]) {
46+
if (!class_exists(LegacyType::class)) {
47+
$this->markTestSkipped('symfony/property-info is not installed.');
48+
}
49+
50+
$cases = [
51+
'supported int/float with union types' => [newLessThanOrEqual(value:10), (newApiProperty())->withBuiltinTypes([newLegacyType(LegacyType::BUILTIN_TYPE_INT),newLegacyType(LegacyType::BUILTIN_TYPE_FLOAT)]),true],
52+
'supported int' => [newLessThanOrEqual(value:10), (newApiProperty())->withBuiltinTypes([newLegacyType(LegacyType::BUILTIN_TYPE_INT)]),true],
53+
'supported float' => [newLessThanOrEqual(value:10.99), (newApiProperty())->withBuiltinTypes([newLegacyType(LegacyType::BUILTIN_TYPE_FLOAT)]),true],
54+
'supported negative or zero' => [newNegativeOrZero(), (newApiProperty())->withBuiltinTypes([newLegacyType(LegacyType::BUILTIN_TYPE_INT)]),true],
55+
'not supported negative' => [newNegative(), (newApiProperty())->withBuiltinTypes([newLegacyType(LegacyType::BUILTIN_TYPE_INT)]),false],
56+
'not supported property path' => [newLessThanOrEqual(propertyPath:'greaterThanMe'), (newApiProperty())->withBuiltinTypes([newLegacyType(LegacyType::BUILTIN_TYPE_INT)]),false],
57+
];
58+
59+
foreach ($casesas [$constraint,$propertyMetadata,$expectedResult]) {
4760
self::assertSame($expectedResult,$this->propertySchemaLessThanOrEqualRestriction->supports($constraint,$propertyMetadata));
4861
}
4962
}
@@ -54,16 +67,6 @@ public function testSupportsWithNativeType(Constraint $constraint, ApiProperty $
5467
self::assertSame($expectedResult,$this->propertySchemaLessThanOrEqualRestriction->supports($constraint,$propertyMetadata));
5568
}
5669

57-
publicstaticfunctionsupportsProvider():\Generator
58-
{
59-
yield'supported int/float with union types' => [newLessThanOrEqual(value:10), (newApiProperty())->withBuiltinTypes([newLegacyType(LegacyType::BUILTIN_TYPE_INT),newLegacyType(LegacyType::BUILTIN_TYPE_FLOAT)]),true];
60-
yield'supported int' => [newLessThanOrEqual(value:10), (newApiProperty())->withBuiltinTypes([newLegacyType(LegacyType::BUILTIN_TYPE_INT)]),true];
61-
yield'supported float' => [newLessThanOrEqual(value:10.99), (newApiProperty())->withBuiltinTypes([newLegacyType(LegacyType::BUILTIN_TYPE_FLOAT)]),true];
62-
yield'supported negative or zero' => [newNegativeOrZero(), (newApiProperty())->withBuiltinTypes([newLegacyType(LegacyType::BUILTIN_TYPE_INT)]),true];
63-
yield'not supported negative' => [newNegative(), (newApiProperty())->withBuiltinTypes([newLegacyType(LegacyType::BUILTIN_TYPE_INT)]),false];
64-
yield'not supported property path' => [newLessThanOrEqual(propertyPath:'greaterThanMe'), (newApiProperty())->withBuiltinTypes([newLegacyType(LegacyType::BUILTIN_TYPE_INT)]),false];
65-
}
66-
6770
publicstaticfunctionsupportsProviderWithNativeType():\Generator
6871
{
6972
yield'native type: supported int/float with union types' => [newLessThanOrEqual(value:10), (newApiProperty())->withNativeType(Type::union(Type::int(), Type::float())),true];
@@ -77,6 +80,10 @@ public static function supportsProviderWithNativeType(): \Generator
7780
#[IgnoreDeprecations]
7881
publicfunctiontestCreate():void
7982
{
83+
if (!class_exists(LegacyType::class)) {
84+
$this->markTestSkipped('symfony/property-info is not installed.');
85+
}
86+
8087
self::assertEquals(['maximum' =>10],$this->propertySchemaLessThanOrEqualRestriction->create(newLessThanOrEqual(value:10), (newApiProperty())->withBuiltinTypes([newLegacyType(LegacyType::BUILTIN_TYPE_INT)])));
8188
}
8289

‎Tests/Validator/Metadata/Property/Restriction/PropertySchemaLessThanRestrictionTest.php‎

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,20 @@ protected function setUp(): void
4343
#[IgnoreDeprecations]
4444
publicfunctiontestSupports():void
4545
{
46-
foreach ($this->supportsProvider()as [$constraint,$propertyMetadata,$expectedResult]) {
46+
if (!class_exists(LegacyType::class)) {
47+
$this->markTestSkipped('symfony/property-info is not installed.');
48+
}
49+
50+
$cases = [
51+
'supported int/float with union types' => [newLessThan(value:10), (newApiProperty())->withBuiltinTypes([newLegacyType(LegacyType::BUILTIN_TYPE_INT),newLegacyType(LegacyType::BUILTIN_TYPE_FLOAT)]),true],
52+
'supported int' => [newLessThan(value:10), (newApiProperty())->withBuiltinTypes([newLegacyType(LegacyType::BUILTIN_TYPE_INT)]),true],
53+
'supported float' => [newLessThan(value:10.99), (newApiProperty())->withBuiltinTypes([newLegacyType(LegacyType::BUILTIN_TYPE_FLOAT)]),true],
54+
'supported negative' => [newNegative(), (newApiProperty())->withBuiltinTypes([newLegacyType(LegacyType::BUILTIN_TYPE_INT)]),true],
55+
'not supported negative or zero' => [newNegativeOrZero(), (newApiProperty())->withBuiltinTypes([newLegacyType(LegacyType::BUILTIN_TYPE_INT)]),false],
56+
'not supported property path' => [newLessThan(propertyPath:'greaterThanMe'), (newApiProperty())->withBuiltinTypes([newLegacyType(LegacyType::BUILTIN_TYPE_INT)]),false],
57+
];
58+
59+
foreach ($casesas [$constraint,$propertyMetadata,$expectedResult]) {
4760
self::assertSame($expectedResult,$this->propertySchemaLessThanRestriction->supports($constraint,$propertyMetadata));
4861
}
4962
}
@@ -54,16 +67,6 @@ public function testSupportsWithNativeType(Constraint $constraint, ApiProperty $
5467
self::assertSame($expectedResult,$this->propertySchemaLessThanRestriction->supports($constraint,$propertyMetadata));
5568
}
5669

57-
publicstaticfunctionsupportsProvider():\Generator
58-
{
59-
yield'supported int/float with union types' => [newLessThan(value:10), (newApiProperty())->withBuiltinTypes([newLegacyType(LegacyType::BUILTIN_TYPE_INT),newLegacyType(LegacyType::BUILTIN_TYPE_FLOAT)]),true];
60-
yield'supported int' => [newLessThan(value:10), (newApiProperty())->withBuiltinTypes([newLegacyType(LegacyType::BUILTIN_TYPE_INT)]),true];
61-
yield'supported float' => [newLessThan(value:10.99), (newApiProperty())->withBuiltinTypes([newLegacyType(LegacyType::BUILTIN_TYPE_FLOAT)]),true];
62-
yield'supported negative' => [newNegative(), (newApiProperty())->withBuiltinTypes([newLegacyType(LegacyType::BUILTIN_TYPE_INT)]),true];
63-
yield'not supported negative or zero' => [newNegativeOrZero(), (newApiProperty())->withBuiltinTypes([newLegacyType(LegacyType::BUILTIN_TYPE_INT)]),false];
64-
yield'not supported property path' => [newLessThan(propertyPath:'greaterThanMe'), (newApiProperty())->withBuiltinTypes([newLegacyType(LegacyType::BUILTIN_TYPE_INT)]),false];
65-
}
66-
6770
publicstaticfunctionsupportsProviderWithNativeType():\Generator
6871
{
6972
yield'native type: supported int/float with union types' => [newLessThan(value:10), (newApiProperty())->withNativeType(Type::union(Type::int(), Type::float())),true];
@@ -77,6 +80,10 @@ public static function supportsProviderWithNativeType(): \Generator
7780
#[IgnoreDeprecations]
7881
publicfunctiontestCreate():void
7982
{
83+
if (!class_exists(LegacyType::class)) {
84+
$this->markTestSkipped('symfony/property-info is not installed.');
85+
}
86+
8087
self::assertEquals([
8188
'exclusiveMaximum' =>10,
8289
'maximum' =>10,

‎Tests/Validator/Metadata/Property/Restriction/PropertySchemaOneOfRestrictionTest.php‎

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,18 @@ public static function supportsProviderWithNativeType(): \Generator
8383
#[IgnoreDeprecations]
8484
publicfunctiontestCreate():void
8585
{
86-
foreach ($this->createProvider()as [$constraint,$propertyMetadata,$expectedResult]) {
86+
if (!class_exists(LegacyType::class)) {
87+
$this->markTestSkipped('symfony/property-info is not installed.');
88+
}
89+
90+
$cases = [
91+
'not supported constraints' => [newAtLeastOneOf([newPositive(),newLength(min:3)]),newApiProperty(), []],
92+
'one supported constraint' => [newAtLeastOneOf([newPositive(),newLength(min:3)]), (newApiProperty())->withBuiltinTypes([newLegacyType(LegacyType::BUILTIN_TYPE_STRING)]), [
93+
'oneOf' => [['minLength' =>3]],
94+
]],
95+
];
96+
97+
foreach ($casesas [$constraint,$propertyMetadata,$expectedResult]) {
8798
self::assertSame($expectedResult,$this->propertySchemaOneOfRestriction->create($constraint,$propertyMetadata));
8899
}
89100
}
@@ -94,14 +105,6 @@ public function testCreateWithNativeType(AtLeastOneOf $constraint, ApiProperty $
94105
self::assertSame($expectedResult,$this->propertySchemaOneOfRestriction->create($constraint,$propertyMetadata));
95106
}
96107

97-
publicstaticfunctioncreateProvider():\Generator
98-
{
99-
yield'not supported constraints' => [newAtLeastOneOf([newPositive(),newLength(min:3)]),newApiProperty(), []];
100-
yield'one supported constraint' => [newAtLeastOneOf([newPositive(),newLength(min:3)]), (newApiProperty())->withBuiltinTypes([newLegacyType(LegacyType::BUILTIN_TYPE_STRING)]), [
101-
'oneOf' => [['minLength' =>3]],
102-
]];
103-
}
104-
105108
publicstaticfunctioncreateProviderWithNativeType():\Generator
106109
{
107110
yield'native type: not supported constraints' => [newAtLeastOneOf([newPositive(),newLength(min:3)]),newApiProperty(), []];

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp