Skip to content

Commit 434e19f

Browse files
#255: Upgraded to PHPunit 10.5
1 parent 94bfde9 commit 434e19f

File tree

4 files changed

+28
-41
lines changed

4 files changed

+28
-41
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"phpstan/phpstan-doctrine": "^1.4",
2121
"phpstan/phpstan-phpunit": "^1.4",
2222
"phpstan/phpstan-symfony": "^1.4",
23-
"phpunit/phpunit": "^9.5",
23+
"phpunit/phpunit": "^10.5",
2424
"rector/rector": "^1.1"
2525
},
2626
"suggest": {

phpunit.xml.dist

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,29 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3-
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.6/phpunit.xsd"
3+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd"
44
bootstrap="vendor/autoload.php"
5-
cacheResultFile=".phpunit.cache/test-results"
5+
cacheDirectory=".phpunit.cache"
66
colors="true"
77
executionOrder="depends,defects"
8-
forceCoversAnnotation="true"
9-
beStrictAboutCoversAnnotation="true"
8+
requireCoverageMetadata="true"
9+
beStrictAboutCoverageMetadata="true"
1010
beStrictAboutOutputDuringTests="true"
1111
beStrictAboutTodoAnnotatedTests="true"
12-
convertDeprecationsToExceptions="true"
1312
failOnRisky="true"
14-
failOnWarning="true"
15-
verbose="true">
13+
failOnWarning="true">
1614

1715
<testsuites>
1816
<testsuite name="DarkWeb Design Symfony Add-on Transformers Test Suite">
1917
<directory>tests</directory>
2018
</testsuite>
2119
</testsuites>
2220

23-
<coverage cacheDirectory=".phpunit.cache/code-coverage"
24-
processUncoveredFiles="true">
21+
<source restrictDeprecations="true"
22+
restrictNotices="true"
23+
restrictWarnings="true">
2524
<include>
2625
<directory suffix=".php">src</directory>
2726
</include>
28-
</coverage>
27+
</source>
2928

3029
</phpunit>

tests/BooleanToValueTransformerTest.php

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,18 @@
2323
namespace DarkWebDesign\SymfonyAddonTransformers\Tests;
2424

2525
use DarkWebDesign\SymfonyAddonTransformers\BooleanToValueTransformer;
26+
use PHPUnit\Framework\Attributes\CoversClass;
27+
use PHPUnit\Framework\Attributes\DataProvider;
2628
use PHPUnit\Framework\TestCase;
2729
use Symfony\Component\Form\Exception\TransformationFailedException;
2830

2931
/**
30-
* @covers \DarkWebDesign\SymfonyAddonTransformers\BooleanToValueTransformer
31-
*
3232
* @internal
3333
*/
34+
#[CoversClass(BooleanToValueTransformer::class)]
3435
class BooleanToValueTransformerTest extends TestCase
3536
{
36-
/**
37-
* @dataProvider providerTrueFalseValue
38-
*/
37+
#[DataProvider('providerTrueFalseValue')]
3938
public function testTransform(mixed $trueValue, mixed $falseValue): void
4039
{
4140
$transformer = new BooleanToValueTransformer($trueValue, $falseValue);
@@ -58,9 +57,7 @@ public function testTransformNull(): void
5857
$this->assertNull($returnValue);
5958
}
6059

61-
/**
62-
* @dataProvider providerNoBool
63-
*/
60+
#[DataProvider('providerNoBool')]
6461
public function testTransformNoBool(mixed $value): void
6562
{
6663
$this->expectException(TransformationFailedException::class);
@@ -71,9 +68,7 @@ public function testTransformNoBool(mixed $value): void
7168
$transformer->transform($value);
7269
}
7370

74-
/**
75-
* @dataProvider providerTrueFalseValue
76-
*/
71+
#[DataProvider('providerTrueFalseValue')]
7772
public function testReverseTransform(mixed $trueValue, mixed $falseValue): void
7873
{
7974
$transformer = new BooleanToValueTransformer($trueValue, $falseValue);
@@ -106,9 +101,7 @@ public function testReverseTransformEmptyString(): void
106101
$this->assertNull($returnValue);
107102
}
108103

109-
/**
110-
* @dataProvider providerNoScalar
111-
*/
104+
#[DataProvider('providerNoScalar')]
112105
public function testReverseTransformNoScalar(mixed $value): void
113106
{
114107
$this->expectException(TransformationFailedException::class);
@@ -119,9 +112,7 @@ public function testReverseTransformNoScalar(mixed $value): void
119112
$transformer->reverseTransform($value);
120113
}
121114

122-
/**
123-
* @dataProvider providerTrueFalseValue
124-
*/
115+
#[DataProvider('providerTrueFalseValue')]
125116
public function testReverseTransformInvalidValue(mixed $trueValue, mixed $falseValue): void
126117
{
127118
$this->expectException(TransformationFailedException::class);
@@ -135,7 +126,7 @@ public function testReverseTransformInvalidValue(mixed $trueValue, mixed $falseV
135126
/**
136127
* @return array<string, array{mixed, mixed}>
137128
*/
138-
public function providerTrueFalseValue(): array
129+
public static function providerTrueFalseValue(): array
139130
{
140131
return [
141132
'true/false' => [true, false],
@@ -150,7 +141,7 @@ public function providerTrueFalseValue(): array
150141
/**
151142
* @return array<string, array{mixed}>
152143
*/
153-
public function providerNoBool(): array
144+
public static function providerNoBool(): array
154145
{
155146
return [
156147
'int' => [1],
@@ -166,7 +157,7 @@ public function providerNoBool(): array
166157
/**
167158
* @return array<string, array{mixed}>
168159
*/
169-
public function providerNoScalar(): array
160+
public static function providerNoScalar(): array
170161
{
171162
return [
172163
'array' => [['foo', 'bar']],

tests/EntityToIdentifierTransformerTest.php

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,16 @@
2929
use Doctrine\Persistence\Mapping\ClassMetadata;
3030
use Doctrine\Persistence\ObjectManager;
3131
use Doctrine\Persistence\ObjectRepository;
32+
use PHPUnit\Framework\Attributes\CoversClass;
33+
use PHPUnit\Framework\Attributes\DataProvider;
3234
use PHPUnit\Framework\MockObject\MockObject;
3335
use PHPUnit\Framework\TestCase;
3436
use Symfony\Component\Form\Exception\TransformationFailedException;
3537

3638
/**
37-
* @covers \DarkWebDesign\SymfonyAddonTransformers\EntityToIdentifierTransformer
38-
*
3939
* @internal
4040
*/
41+
#[CoversClass(EntityToIdentifierTransformer::class)]
4142
class EntityToIdentifierTransformerTest extends TestCase
4243
{
4344
private City $entity;
@@ -131,9 +132,7 @@ public function testTransformNull(): void
131132
$this->assertNull($identifier);
132133
}
133134

134-
/**
135-
* @dataProvider providerNoObject
136-
*/
135+
#[DataProvider('providerNoObject')]
137136
public function testTransformNoObject(mixed $value): void
138137
{
139138
$this->expectException(TransformationFailedException::class);
@@ -198,9 +197,7 @@ public function testReverseTransformEmptyString(): void
198197
$this->assertNull($entity);
199198
}
200199

201-
/**
202-
* @dataProvider providerNoScalar
203-
*/
200+
#[DataProvider('providerNoScalar')]
204201
public function testReverseTransformNoScalar(mixed $value): void
205202
{
206203
$this->expectException(TransformationFailedException::class);
@@ -226,7 +223,7 @@ public function testReverseTransformEntityNotFound(): void
226223
/**
227224
* @return array<string, array{mixed}>
228225
*/
229-
public function providerNoObject(): array
226+
public static function providerNoObject(): array
230227
{
231228
return [
232229
'bool' => [true],
@@ -242,7 +239,7 @@ public function providerNoObject(): array
242239
/**
243240
* @return array<string, array{mixed}>
244241
*/
245-
public function providerNoScalar(): array
242+
public static function providerNoScalar(): array
246243
{
247244
return [
248245
'array' => [['foo', 'bar']],

0 commit comments

Comments
 (0)