Skip to content

Commit 6def72b

Browse files
committed
Adapt tests to php 8.4
1 parent 9ea89dd commit 6def72b

19 files changed

+90
-167
lines changed

phpunit.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.1/phpunit.xsd" bootstrap="vendor/autoload.php"
44
executionOrder="depends,defects" beStrictAboutOutputDuringTests="true" failOnRisky="true" failOnWarning="true"
55
colors="true" cacheDirectory=".phpunit.cache" requireCoverageMetadata="false"
6+
displayDetailsOnTestsThatTriggerDeprecations="true"
7+
displayDetailsOnTestsThatTriggerErrors="true"
8+
displayDetailsOnTestsThatTriggerNotices="true"
9+
displayDetailsOnTestsThatTriggerWarnings="true"
10+
displayDetailsOnPhpunitDeprecations="true"
611
beStrictAboutCoverageMetadata="true">
712
<testsuites>
813
<testsuite name="default">

tests/AbstractEntityTest.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use Composite\Entity\AbstractEntity;
66
use Composite\Entity\Helpers\DateTimeHelper;
77
use Composite\Entity\Tests\TestStand\TestSubEntity;
8+
use PHPUnit\Framework\Attributes\DataProvider;
89

910
final class AbstractEntityTest extends \PHPUnit\Framework\TestCase
1011
{
@@ -76,9 +77,7 @@ public function __construct(
7677
];
7778
}
7879

79-
/**
80-
* @dataProvider hydration_dataProvider
81-
*/
80+
#[DataProvider('hydration_dataProvider')]
8281
public function test_hydration(AbstractEntity $entity, array $expected): void
8382
{
8483
$actual = $entity->toArray();
@@ -131,9 +130,7 @@ public static function changedColumns_dataProvider(): array
131130
];
132131
}
133132

134-
/**
135-
* @dataProvider changedColumns_dataProvider
136-
*/
133+
#[DataProvider('changedColumns_dataProvider')]
137134
public function test_changedColumns(array $createData, array $expectedChangedColumns): void
138135
{
139136
$entity = TestStand\TestAutoIncrementEntity::fromArray($createData);

tests/ColumnBuilderTest.php

Lines changed: 27 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Composite\Entity\Attributes\SkipSerialization;
88
use Composite\Entity\Columns\AbstractColumn;
99
use Composite\Entity\Tests\TestStand\TestSubEntity;
10+
use PHPUnit\Framework\Attributes\DataProvider;
1011

1112
final class ColumnBuilderTest extends \PHPUnit\Framework\TestCase
1213
{
@@ -51,9 +52,7 @@ public function __construct(
5152
];
5253
}
5354

54-
/**
55-
* @dataProvider visibility_dataProvider
56-
*/
55+
#[DataProvider('visibility_dataProvider')]
5756
public function test_visibility(AbstractEntity $entity, array $expected): void
5857
{
5958
$schema = $entity::schema();
@@ -90,9 +89,7 @@ public static function type_dataProvider(): array
9089
];
9190
}
9291

93-
/**
94-
* @dataProvider type_dataProvider
95-
*/
92+
#[DataProvider('type_dataProvider')]
9693
public function test_type(AbstractEntity $entity, array $expected): void
9794
{
9895
$schema = $entity::schema();
@@ -124,9 +121,7 @@ public function __construct(
124121
];
125122
}
126123

127-
/**
128-
* @dataProvider hasDefaultValue_dataProvider
129-
*/
124+
#[DataProvider('hasDefaultValue_dataProvider')]
130125
public function test_hasDefaultValue(AbstractEntity $class, array $expected): void
131126
{
132127
$schema = $class::schema();
@@ -168,9 +163,7 @@ public static function defaultValue_dataProvider(): array
168163
];
169164
}
170165

171-
/**
172-
* @dataProvider defaultValue_dataProvider
173-
*/
166+
#[DataProvider('defaultValue_dataProvider')]
174167
public function test_defaultValue(AbstractEntity $entity, array $expected): void
175168
{
176169
$schema = $entity::schema();
@@ -214,9 +207,7 @@ public function __construct(
214207
];
215208
}
216209

217-
/**
218-
* @dataProvider isNullable_dataProvider
219-
*/
210+
#[DataProvider('isNullable_dataProvider')]
220211
public function test_isNullable(AbstractEntity $class, array $expected): void
221212
{
222213
$schema = $class::schema();
@@ -226,29 +217,6 @@ public function test_isNullable(AbstractEntity $class, array $expected): void
226217
}
227218
}
228219

229-
public static function isReadOnly_dataProvider(): array
230-
{
231-
return [
232-
[
233-
'class' => new class extends AbstractEntity {
234-
public string $foo2 = 'foo';
235-
public readonly ?string $bar2;
236-
237-
public function __construct(
238-
public string $foo1 = 'foo',
239-
public readonly ?string $bar1 = null,
240-
) {}
241-
},
242-
'expected' => [
243-
'foo1' => false,
244-
'bar1' => true,
245-
'foo2' => false,
246-
'bar2' => true,
247-
]
248-
],
249-
];
250-
}
251-
252220
public static function isConstructorPromoted_dataProvider(): array
253221
{
254222
return [
@@ -272,9 +240,7 @@ public function __construct(
272240
];
273241
}
274242

275-
/**
276-
* @dataProvider isConstructorPromoted_dataProvider
277-
*/
243+
#[DataProvider('isConstructorPromoted_dataProvider')]
278244
public function test_isConstructorPromoted(AbstractEntity $entity, array $expected): void
279245
{
280246
$schema = $entity::schema();
@@ -284,11 +250,26 @@ public function test_isConstructorPromoted(AbstractEntity $entity, array $expect
284250
}
285251
}
286252

287-
/**
288-
* @dataProvider isReadOnly_dataProvider
289-
*/
290-
public function test_isReadOnly(AbstractEntity $entity, array $expected): void
253+
public function test_isReadOnly(): void
291254
{
255+
$entity = new class extends AbstractEntity {
256+
public string $foo2 = 'foo';
257+
public readonly ?string $bar2;
258+
259+
public function __construct(
260+
public string $foo1 = 'foo',
261+
public readonly ?string $bar1 = null,
262+
) {
263+
}
264+
};
265+
266+
$expected = [
267+
'foo1' => false,
268+
'bar1' => true,
269+
'foo2' => false,
270+
'bar2' => true,
271+
];
272+
292273
$schema = $entity::schema();
293274
foreach ($expected as $name => $expectedIsReadOnly) {
294275
$this->assertNotNull($schema->getColumn($name));
@@ -321,9 +302,7 @@ public static function notSupported_dataProvider(): array
321302
];
322303
}
323304

324-
/**
325-
* @dataProvider notSupported_dataProvider
326-
*/
305+
#[DataProvider('notSupported_dataProvider')]
327306
public function test_notSupported(AbstractEntity $entity): void
328307
{
329308
try {

tests/Columns/ArrayColumnTest.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Composite\Entity\AbstractEntity;
66
use Composite\Entity\Exceptions\EntityException;
7+
use PHPUnit\Framework\Attributes\DataProvider;
78

89
final class ArrayColumnTest extends \PHPUnit\Framework\TestCase
910
{
@@ -45,9 +46,7 @@ public static function cast_dataProvider(): array
4546
];
4647
}
4748

48-
/**
49-
* @dataProvider cast_dataProvider
50-
*/
49+
#[DataProvider('cast_dataProvider')]
5150
public function test_cast(mixed $value, ?array $expected): void
5251
{
5352
$class = new class extends AbstractEntity {
@@ -81,9 +80,7 @@ public static function uncast_dataProvider(): array
8180
];
8281
}
8382

84-
/**
85-
* @dataProvider uncast_dataProvider
86-
*/
83+
#[DataProvider('uncast_dataProvider')]
8784
public function test_uncast(mixed $value, mixed $expected): void
8885
{
8986
$entity = new class($value) extends AbstractEntity {

tests/Columns/BackedEnumColumnTest.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Composite\Entity\AbstractEntity;
66
use Composite\Entity\Tests\TestStand\TestBackedStringEnum;
7+
use PHPUnit\Framework\Attributes\DataProvider;
78

89
final class BackedEnumColumnTest extends \PHPUnit\Framework\TestCase
910
{
@@ -41,9 +42,7 @@ public static function cast_dataProvider(): array
4142
];
4243
}
4344

44-
/**
45-
* @dataProvider cast_dataProvider
46-
*/
45+
#[DataProvider('cast_dataProvider')]
4746
public function test_cast(mixed $value, ?TestBackedStringEnum $expected): void
4847
{
4948
$class = new class extends AbstractEntity {
@@ -73,9 +72,7 @@ public static function uncast_dataProvider(): array
7372
];
7473
}
7574

76-
/**
77-
* @dataProvider uncast_dataProvider
78-
*/
75+
#[DataProvider('uncast_dataProvider')]
7976
public function test_uncast(mixed $value, mixed $expected): void
8077
{
8178
$entity = new class($value) extends AbstractEntity {

tests/Columns/BackedIntEnumColumnTest.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Composite\Entity\AbstractEntity;
66
use Composite\Entity\Tests\TestStand\TestBackedIntEnum;
7+
use PHPUnit\Framework\Attributes\DataProvider;
78

89
final class BackedIntEnumColumnTest extends \PHPUnit\Framework\TestCase
910
{
@@ -45,9 +46,7 @@ public static function cast_dataProvider(): array
4546
];
4647
}
4748

48-
/**
49-
* @dataProvider cast_dataProvider
50-
*/
49+
#[DataProvider('cast_dataProvider')]
5150
public function test_cast(mixed $value, ?TestBackedIntEnum $expected): void
5251
{
5352
$class = new class extends AbstractEntity {
@@ -77,9 +76,7 @@ public static function uncast_dataProvider(): array
7776
];
7877
}
7978

80-
/**
81-
* @dataProvider uncast_dataProvider
82-
*/
79+
#[DataProvider('uncast_dataProvider')]
8380
public function test_uncast(mixed $value, mixed $expected): void
8481
{
8582
$entity = new class($value) extends AbstractEntity {

tests/Columns/BackedStringEnumColumnTest.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Composite\Entity\AbstractEntity;
66
use Composite\Entity\Tests\TestStand\TestBackedStringEnum;
7+
use PHPUnit\Framework\Attributes\DataProvider;
78

89
final class BackedStringEnumColumnTest extends \PHPUnit\Framework\TestCase
910
{
@@ -45,9 +46,7 @@ public static function cast_dataProvider(): array
4546
];
4647
}
4748

48-
/**
49-
* @dataProvider cast_dataProvider
50-
*/
49+
#[DataProvider('cast_dataProvider')]
5150
public function test_cast(mixed $value, ?TestBackedStringEnum $expected): void
5251
{
5352
$class = new class extends AbstractEntity {
@@ -77,9 +76,7 @@ public static function uncast_dataProvider(): array
7776
];
7877
}
7978

80-
/**
81-
* @dataProvider uncast_dataProvider
82-
*/
79+
#[DataProvider('uncast_dataProvider')]
8380
public function test_uncast(mixed $value, mixed $expected): void
8481
{
8582
$entity = new class($value) extends AbstractEntity {

tests/Columns/BoolColumnTest.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Composite\Entity\Tests\Columns;
44

55
use Composite\Entity\AbstractEntity;
6+
use PHPUnit\Framework\Attributes\DataProvider;
67

78
final class BoolColumnTest extends \PHPUnit\Framework\TestCase
89
{
@@ -60,9 +61,7 @@ public static function cast_dataProvider(): array
6061
];
6162
}
6263

63-
/**
64-
* @dataProvider cast_dataProvider
65-
*/
64+
#[DataProvider('cast_dataProvider')]
6665
public function test_cast(mixed $value, ?bool $expected): void
6766
{
6867
$class = new class extends AbstractEntity {
@@ -92,9 +91,7 @@ public static function uncast_dataProvider(): array
9291
];
9392
}
9493

95-
/**
96-
* @dataProvider uncast_dataProvider
97-
*/
94+
#[DataProvider('uncast_dataProvider')]
9895
public function test_uncast(mixed $value, mixed $expected): void
9996
{
10097
$entity = new class($value) extends AbstractEntity {

tests/Columns/CastableColumnTest.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Composite\Entity\AbstractEntity;
66
use Composite\Entity\Tests\TestStand\TestCastableIntObject;
7+
use PHPUnit\Framework\Attributes\DataProvider;
78

89
final class CastableColumnTest extends \PHPUnit\Framework\TestCase
910
{
@@ -35,9 +36,7 @@ public static function cast_dataProvider(): array
3536
];
3637
}
3738

38-
/**
39-
* @dataProvider cast_dataProvider
40-
*/
39+
#[DataProvider('cast_dataProvider')]
4140
public function test_cast(mixed $value, ?TestCastableIntObject $expected): void
4241
{
4342
$class = new class extends AbstractEntity {
@@ -65,9 +64,7 @@ public static function uncast_dataProvider(): array
6564
];
6665
}
6766

68-
/**
69-
* @dataProvider uncast_dataProvider
70-
*/
67+
#[DataProvider('uncast_dataProvider')]
7168
public function test_uncast(mixed $value, mixed $expected): void
7269
{
7370
$entity = new class($value) extends AbstractEntity {

0 commit comments

Comments
 (0)