Skip to content

Commit af0b6b3

Browse files
committed
Upgrade PHPUnit
1 parent c64a3d2 commit af0b6b3

8 files changed

Lines changed: 33 additions & 56 deletions

File tree

.php-cs-fixer.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
->setRules([
55
'@Symfony' => true,
66
'@Symfony:risky' => true,
7-
'@PHP82Migration' => true,
8-
'@PHP82Migration:risky' => true,
9-
'@PHPUnit91Migration:risky' => true,
7+
'@PHP8x2Migration' => true,
8+
'@PHP8x2Migration:risky' => true,
9+
'@PHPUnit10x0Migration:risky' => true,
1010
'array_syntax' => ['syntax' => 'short'],
1111
'blank_line_after_opening_tag' => false,
1212
'fopen_flags' => false,

composer.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,14 @@
1919
"doctrine/orm": "^2.19 || ^3.0",
2020
"jms/serializer": "^3.28",
2121
"jms/serializer-bundle": "^5.4",
22-
"matthiasnoback/symfony-dependency-injection-test": "^5.0",
22+
"matthiasnoback/symfony-dependency-injection-test": "^6.1",
2323
"phpstan/extension-installer": "^1.4",
2424
"phpstan/phpstan": "2.1.31",
2525
"phpstan/phpstan-phpunit": "2.0.7",
2626
"phpstan/phpstan-symfony": "2.0.8",
27-
"phpunit/phpunit": "9.6.29",
27+
"phpunit/phpunit": "11.5.42",
2828
"symfony/form": "^6.4 || ^7.3",
2929
"symfony/intl": "^6.4 || ^7.3",
30-
"symfony/phpunit-bridge": "^6.4 || ^7.3",
3130
"symfony/property-access": "^6.4 || ^7.3",
3231
"symfony/serializer": "^6.4 || ^7.3",
3332
"symfony/twig-bundle": "^6.4 || ^7.3",

phpunit.xml.dist

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,14 @@
1111
</testsuite>
1212
</testsuites>
1313

14-
<coverage processUncoveredFiles="true">
14+
<source>
1515
<include>
16-
<directory suffix=".php">./src</directory>
16+
<directory>./src</directory>
1717
</include>
18-
</coverage>
19-
20-
<listeners>
21-
<listener class="Symfony\Bridge\PhpUnit\SymfonyTestsListener"/>
22-
</listeners>
23-
24-
<php>
25-
<!-- Ignore deprecations from lowest stable -->
26-
<env name="SYMFONY_DEPRECATIONS_HELPER" value="max[direct]=7&amp;max[indirect]=14"/>
27-
</php>
18+
<deprecationTrigger>
19+
<function>trigger_deprecation</function>
20+
<method>Doctrine\Deprecations\Deprecation::trigger</method>
21+
<method>Doctrine\Deprecations\Deprecation::delegateTriggerToBackend</method>
22+
</deprecationTrigger>
23+
</source>
2824
</phpunit>

tests/Factory/FormatterFactoryTest.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Money\Formatter\DecimalMoneyFormatter;
1111
use Money\Formatter\IntlLocalizedDecimalFormatter;
1212
use Money\Formatter\IntlMoneyFormatter;
13+
use PHPUnit\Framework\Attributes\RequiresPhpExtension;
1314
use PHPUnit\Framework\TestCase;
1415

1516
final class FormatterFactoryTest extends TestCase
@@ -39,17 +40,13 @@ public function testDecimalFormatterIsCreated(): void
3940
self::assertInstanceOf(DecimalMoneyFormatter::class, $this->factory->createFormatter(Format::DECIMAL));
4041
}
4142

42-
/**
43-
* @requires extension intl
44-
*/
43+
#[RequiresPhpExtension('intl')]
4544
public function testIntlLocalizedDecimalFormatterIsCreated(): void
4645
{
4746
self::assertInstanceOf(IntlLocalizedDecimalFormatter::class, $this->factory->createFormatter(Format::INTL_LOCALIZED_DECIMAL));
4847
}
4948

50-
/**
51-
* @requires extension intl
52-
*/
49+
#[RequiresPhpExtension('intl')]
5350
public function testIntlMoneyFormatterIsCreated(): void
5451
{
5552
self::assertInstanceOf(IntlMoneyFormatter::class, $this->factory->createFormatter(Format::INTL_MONEY));

tests/Factory/ParserFactoryTest.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Money\Parser\DecimalMoneyParser;
1111
use Money\Parser\IntlLocalizedDecimalParser;
1212
use Money\Parser\IntlMoneyParser;
13+
use PHPUnit\Framework\Attributes\RequiresPhpExtension;
1314
use PHPUnit\Framework\TestCase;
1415

1516
final class ParserFactoryTest extends TestCase
@@ -39,17 +40,13 @@ public function testDecimalParserIsCreated(): void
3940
self::assertInstanceOf(DecimalMoneyParser::class, $this->factory->createParser(Format::DECIMAL));
4041
}
4142

42-
/**
43-
* @requires extension intl
44-
*/
43+
#[RequiresPhpExtension('intl')]
4544
public function testIntlLocalizedDecimalParserIsCreated(): void
4645
{
4746
self::assertInstanceOf(IntlLocalizedDecimalParser::class, $this->factory->createParser(Format::INTL_LOCALIZED_DECIMAL));
4847
}
4948

50-
/**
51-
* @requires extension intl
52-
*/
49+
#[RequiresPhpExtension('intl')]
5350
public function testIntlMoneyParserIsCreated(): void
5451
{
5552
self::assertInstanceOf(IntlMoneyParser::class, $this->factory->createParser(Format::INTL_MONEY));

tests/Form/Type/MoneyTypeTest.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use BabDev\MoneyBundle\Form\Type\MoneyType;
88
use Money\Currency;
99
use Money\Money;
10+
use PHPUnit\Framework\Attributes\DataProvider;
1011
use Symfony\Component\Form\PreloadedExtension;
1112
use Symfony\Component\Form\Test\TypeTestCase;
1213
use Symfony\Component\Intl\Util\IntlTestHelper;
@@ -40,17 +41,15 @@ protected function tearDown(): void
4041
\Locale::setDefault($this->defaultLocale);
4142
}
4243

43-
public function dataPassMoneyPatternToView(): \Generator
44+
public static function dataPassMoneyPatternToView(): \Generator
4445
{
4546
yield 'USD with en_US locale' => ['$ {{ widget }}', 'en_US', new Currency('USD')];
4647
yield 'EUR with en_US locale' => ['€ {{ widget }}', 'en_US', new Currency('EUR')];
4748
yield 'USD with de_DE locale' => ['{{ widget }} $', 'de_DE', new Currency('USD')];
4849
yield 'EUR with de_DE locale' => ['{{ widget }} €', 'de_DE', new Currency('EUR')];
4950
}
5051

51-
/**
52-
* @dataProvider dataPassMoneyPatternToView
53-
*/
52+
#[DataProvider('dataPassMoneyPatternToView')]
5453
public function testPassMoneyPatternToView(string $expected, string $locale, Currency $currency): void
5554
{
5655
\Locale::setDefault($locale);

tests/Serializer/Normalizer/MoneyNormalizerTest.php

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use BabDev\MoneyBundle\Serializer\Normalizer\MoneyNormalizer;
66
use Money\Currency;
77
use Money\Money;
8+
use PHPUnit\Framework\Attributes\DataProvider;
89
use PHPUnit\Framework\TestCase;
910
use Symfony\Component\Serializer\Exception\InvalidArgumentException;
1011
use Symfony\Component\Serializer\Exception\NotNormalizableValueException;
@@ -28,15 +29,13 @@ public function testNormalizeOnlyAcceptsMoneyInstances(): void
2829
(new MoneyNormalizer())->normalize(new \stdClass());
2930
}
3031

31-
public function dataSupportsNormalization(): \Generator
32+
public static function dataSupportsNormalization(): \Generator
3233
{
3334
yield 'Supported' => [new Money(100, new Currency('USD')), true];
3435
yield 'Not Supported' => [new \stdClass(), false];
3536
}
3637

37-
/**
38-
* @dataProvider dataSupportsNormalization
39-
*/
38+
#[DataProvider('dataSupportsNormalization')]
4039
public function testSupportsNormalization(mixed $data, bool $supported): void
4140
{
4241
self::assertSame($supported, (new MoneyNormalizer())->supportsNormalization($data));
@@ -73,15 +72,13 @@ public function testDenormalizeConvertsExceptionsCreatingMoneyInstances(): void
7372
(new MoneyNormalizer())->denormalize(['amount' => '9.99', 'currency' => 'USD'], Money::class);
7473
}
7574

76-
public function dataSupportsDenormalization(): \Generator
75+
public static function dataSupportsDenormalization(): \Generator
7776
{
7877
yield 'Supported' => [new \stdClass(), Money::class, true];
7978
yield 'Not Supported' => [new \stdClass(), \stdClass::class, false];
8079
}
8180

82-
/**
83-
* @dataProvider dataSupportsDenormalization
84-
*/
81+
#[DataProvider('dataSupportsDenormalization')]
8582
public function testSupportsDenormalization(mixed $data, string $type, bool $supported): void
8683
{
8784
self::assertSame($supported, (new MoneyNormalizer())->supportsDenormalization($data, $type));

tests/Validator/Constraints/AbstractMoneyComparisonValidatorTestCase.php

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use BabDev\MoneyBundle\Validator\Constraints\AbstractMoneyComparisonValidator;
77
use Money\Money;
88
use Money\Number;
9+
use PHPUnit\Framework\Attributes\DataProvider;
910
use Symfony\Component\Validator\Exception\ConstraintDefinitionException;
1011
use Symfony\Component\Validator\Exception\InvalidArgumentException;
1112
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
@@ -77,9 +78,8 @@ public static function provideInvalidConstraintOptions(): \Generator
7778

7879
/**
7980
* @param array<string, mixed>|null $options
80-
*
81-
* @dataProvider provideInvalidConstraintOptions
8281
*/
82+
#[DataProvider('provideInvalidConstraintOptions')]
8383
public function testThrowsConstraintExceptionIfNoValueOrPropertyPath(?array $options): void
8484
{
8585
$this->expectException(ConstraintDefinitionException::class);
@@ -97,19 +97,15 @@ public function testThrowsConstraintExceptionIfBothValueAndPropertyPath(): void
9797
]);
9898
}
9999

100-
/**
101-
* @dataProvider provideValidComparisons
102-
*/
100+
#[DataProvider('provideValidComparisons')]
103101
public function testValidComparisonToValue(Money|float|int|string|null $dirtyValue, Money|float|int|string|null $comparisonValue): void
104102
{
105103
$this->validator->validate($dirtyValue, $this->createConstraint(['value' => $comparisonValue]));
106104

107105
$this->assertNoViolation();
108106
}
109107

110-
/**
111-
* @dataProvider provideValidComparisonsToPropertyPath
112-
*/
108+
#[DataProvider('provideValidComparisonsToPropertyPath')]
113109
public function testValidComparisonToPropertyPath(Money|float|int|string|null $comparedValue): void
114110
{
115111
$this->setObject($this->createValueObject(Money::USD(500)));
@@ -164,9 +160,7 @@ public function testInvalidValueAsBadlyFormattedFloat(): void
164160
$this->validator->validate(500, $this->createConstraint(['value' => 500.4925]));
165161
}
166162

167-
/**
168-
* @dataProvider provideInvalidComparisons
169-
*/
163+
#[DataProvider('provideInvalidComparisons')]
170164
public function testInvalidComparisonToValue(Money|float|int|string|null $dirtyValue, string $dirtyValueAsString, Money|float|int|string|null $comparedValue, string $comparedValueString, string $comparedValueType): void
171165
{
172166
$constraint = $this->createConstraint(['value' => $comparedValue]);
@@ -202,9 +196,7 @@ public function testInvalidComparisonToPropertyPathAddsPathAsParameter(): void
202196
->assertRaised();
203197
}
204198

205-
/**
206-
* @dataProvider provideComparisonsToNullValueAtPropertyPath
207-
*/
199+
#[DataProvider('provideComparisonsToNullValueAtPropertyPath')]
208200
public function testCompareWithNullValueAtPropertyAt(Money|float|int|string|null $dirtyValue, string $dirtyValueAsString, bool $isValid): void
209201
{
210202
$constraint = $this->createConstraint(['propertyPath' => 'value']);

0 commit comments

Comments
 (0)