Skip to content

Commit 20a1fc5

Browse files
author
Composite PHP
committed
Adapt tests to php 8.4
1 parent a869f6b commit 20a1fc5

10 files changed

+28
-38
lines changed

phpunit.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.1/phpunit.xsd" bootstrap="tests/bootstrap.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+
displayDetailsOnPhpunitDeprecations="true"
610
displayDetailsOnTestsThatTriggerWarnings="true"
711
beStrictAboutCoverageMetadata="true">
812
<testsuites>

tests/Attributes/PrimaryKeyAttributeTest.php

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

910
final class PrimaryKeyAttributeTest extends \PHPUnit\Framework\TestCase
1011
{
@@ -34,9 +35,7 @@ public function __construct(
3435
];
3536
}
3637

37-
/**
38-
* @dataProvider primaryKey_dataProvider
39-
*/
38+
#[DataProvider('primaryKey_dataProvider')]
4039
public function test_primaryKey(AbstractEntity $entity, array $expected): void
4140
{
4241
$schema = $entity::schema();

tests/Connection/ConnectionManagerTest.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use Composite\DB\ConnectionManager;
66
use Composite\DB\Exceptions\DbException;
77
use Doctrine\DBAL\Connection;
8+
use PHPUnit\Framework\Attributes\DataProvider;
89

910
final class ConnectionManagerTest extends \PHPUnit\Framework\TestCase
1011
{
@@ -42,9 +43,7 @@ public static function invalidConfig_dataProvider(): array
4243
];
4344
}
4445

45-
/**
46-
* @dataProvider invalidConfig_dataProvider
47-
*/
46+
#[DataProvider('invalidConfig_dataProvider')]
4847
public function test_invalidConfig(string $configPath): void
4948
{
5049
$reflection = new \ReflectionClass(ConnectionManager::class);

tests/MultiQuery/MultiInsertTest.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,11 @@
44

55
use Composite\DB\ConnectionManager;
66
use Composite\DB\MultiQuery\MultiInsert;
7+
use PHPUnit\Framework\Attributes\DataProvider;
78

89
class MultiInsertTest extends \PHPUnit\Framework\TestCase
910
{
10-
/**
11-
* @dataProvider multiInsertQuery_dataProvider
12-
*/
11+
#[DataProvider('multiInsertQuery_dataProvider')]
1312
public function test_multiInsertQuery($tableName, $rows, $expectedSql, $expectedParameters)
1413
{
1514
$connection = ConnectionManager::getConnection('sqlite');

tests/Table/AbstractCachedTableTest.php

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,12 @@
33
namespace Composite\DB\Tests\Table;
44

55
use Composite\DB\AbstractCachedTable;
6-
use Composite\DB\AbstractTable;
7-
use Composite\DB\Exceptions\DbException;
86
use Composite\DB\Tests\TestStand\Entities;
97
use Composite\DB\Tests\TestStand\Tables;
108
use Composite\DB\Where;
119
use Composite\Entity\AbstractEntity;
1210
use Composite\DB\Tests\Helpers;
11+
use PHPUnit\Framework\Attributes\DataProvider;
1312
use Ramsey\Uuid\Uuid;
1413

1514
final class AbstractCachedTableTest extends \PHPUnit\Framework\TestCase
@@ -43,9 +42,7 @@ public static function getOneCacheKey_dataProvider(): array
4342
];
4443
}
4544

46-
/**
47-
* @dataProvider getOneCacheKey_dataProvider
48-
*/
45+
#[DataProvider('getOneCacheKey_dataProvider')]
4946
public function test_getOneCacheKey(AbstractCachedTable $table, AbstractEntity $object, string $expected): void
5047
{
5148
$reflectionMethod = new \ReflectionMethod($table, 'getOneCacheKey');
@@ -88,9 +85,7 @@ public static function getCountCacheKey_dataProvider(): array
8885
];
8986
}
9087

91-
/**
92-
* @dataProvider getCountCacheKey_dataProvider
93-
*/
88+
#[DataProvider('getCountCacheKey_dataProvider')]
9489
public function test_getCountCacheKey(array|Where $where, string $expected): void
9590
{
9691
$table = new Tables\TestAutoincrementCachedTable(Helpers\CacheHelper::getCache());
@@ -159,9 +154,7 @@ public static function getListCacheKey_dataProvider(): array
159154
];
160155
}
161156

162-
/**
163-
* @dataProvider getListCacheKey_dataProvider
164-
*/
157+
#[DataProvider('getListCacheKey_dataProvider')]
165158
public function test_getListCacheKey(array|Where $where, array $orderBy, ?int $limit, string $expected): void
166159
{
167160
$table = new Tables\TestAutoincrementCachedTable(Helpers\CacheHelper::getCache());
@@ -197,9 +190,7 @@ public static function getCustomCacheKey_dataProvider(): array
197190
];
198191
}
199192

200-
/**
201-
* @dataProvider getCustomCacheKey_dataProvider
202-
*/
193+
#[DataProvider('getCustomCacheKey_dataProvider')]
203194
public function test_getCustomCacheKey(array $parts, string $expected): void
204195
{
205196
$table = new Tables\TestAutoincrementCachedTable(Helpers\CacheHelper::getCache());
@@ -253,9 +244,7 @@ public static function collectCacheKeysByEntity_dataProvider(): array
253244
];
254245
}
255246

256-
/**
257-
* @dataProvider collectCacheKeysByEntity_dataProvider
258-
*/
247+
#[DataProvider('collectCacheKeysByEntity_dataProvider')]
259248
public function test_collectCacheKeysByEntity(AbstractEntity $entity, AbstractCachedTable $table, array $expected): void
260249
{
261250
$reflectionMethod = new \ReflectionMethod($table, 'collectCacheKeysByEntity');

tests/Table/AbstractTableTest.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Composite\DB\Tests\TestStand\Tables;
88
use Composite\Entity\AbstractEntity;
99
use Composite\Entity\Exceptions\EntityException;
10+
use PHPUnit\Framework\Attributes\DataProvider;
1011
use Ramsey\Uuid\Uuid;
1112
use Ramsey\Uuid\UuidInterface;
1213

@@ -54,9 +55,7 @@ public static function getPkCondition_dataProvider(): array
5455
];
5556
}
5657

57-
/**
58-
* @dataProvider getPkCondition_dataProvider
59-
*/
58+
#[DataProvider('getPkCondition_dataProvider')]
6059
public function test_getPkCondition(AbstractTable $table, int|string|array|AbstractEntity|UuidInterface $object, array $expected): void
6160
{
6261
$reflectionMethod = new \ReflectionMethod($table, 'getPkCondition');
@@ -95,9 +94,7 @@ public function test_illegalCreateEntity(): void
9594
$this->assertEmpty($empty);
9695
}
9796

98-
/**
99-
* @dataProvider buildWhere_dataProvider
100-
*/
97+
#[DataProvider('buildWhere_dataProvider')]
10198
public function test_buildWhere($where, $expectedSQL, $expectedParams): void
10299
{
103100
$table = new Tables\TestStrictTable();

tests/Table/AutoIncrementTableTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use Composite\DB\Tests\TestStand\Tables;
1010
use Composite\DB\Tests\TestStand\Entities;
1111
use Composite\DB\Tests\TestStand\Interfaces\IAutoincrementTable;
12+
use PHPUnit\Framework\Attributes\DataProvider;
1213

1314
final class AutoIncrementTableTest extends \PHPUnit\Framework\TestCase
1415
{
@@ -36,8 +37,8 @@ public static function crud_dataProvider(): array
3637

3738
/**
3839
* @param class-string<Entities\TestAutoincrementEntity|Entities\TestAutoincrementSdEntity> $class
39-
* @dataProvider crud_dataProvider
4040
*/
41+
#[DataProvider('crud_dataProvider')]
4142
public function test_crud(AbstractTable&IAutoincrementTable $table, string $class): void
4243
{
4344
$table->truncate();

tests/Table/CombinedTransactionTest.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Composite\DB\Tests\TestStand\Entities;
88
use Composite\DB\Tests\TestStand\Tables;
99
use Composite\DB\Tests\Helpers;
10+
use PHPUnit\Framework\Attributes\DataProvider;
1011

1112
final class CombinedTransactionTest extends \PHPUnit\Framework\TestCase
1213
{
@@ -185,9 +186,7 @@ public function test_lock(): void
185186
$this->assertNotEmpty($table->findByPk($e2->id));
186187
}
187188

188-
/**
189-
* @dataProvider buildLockKey_dataProvider
190-
*/
189+
#[DataProvider('buildLockKey_dataProvider')]
191190
public function test_buildLockKey($keyParts, $expectedResult)
192191
{
193192
$reflection = new \ReflectionClass(CombinedTransaction::class);

tests/Table/CompositeTableTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use Composite\DB\Tests\TestStand\Tables;
1010
use Composite\DB\Tests\TestStand\Entities;
1111
use Composite\DB\Tests\TestStand\Interfaces\ICompositeTable;
12+
use PHPUnit\Framework\Attributes\DataProvider;
1213

1314
final class CompositeTableTest extends \PHPUnit\Framework\TestCase
1415
{
@@ -28,8 +29,9 @@ public static function crud_dataProvider(): array
2829

2930
/**
3031
* @param class-string<Entities\TestCompositeEntity> $class
31-
* @dataProvider crud_dataProvider
32+
* @throws \Throwable
3233
*/
34+
#[DataProvider('crud_dataProvider')]
3335
public function test_crud(AbstractTable&ICompositeTable $table, string $class): void
3436
{
3537
$table->truncate();

tests/Table/UniqueTableTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Composite\DB\Tests\TestStand\Entities;
88
use Composite\DB\Tests\TestStand\Tables;
99
use Composite\DB\Tests\TestStand\Interfaces\IUniqueTable;
10+
use PHPUnit\Framework\Attributes\DataProvider;
1011
use Ramsey\Uuid\Uuid;
1112

1213
final class UniqueTableTest extends \PHPUnit\Framework\TestCase
@@ -27,8 +28,8 @@ public static function crud_dataProvider(): array
2728

2829
/**
2930
* @param class-string<Entities\TestUniqueEntity> $class
30-
* @dataProvider crud_dataProvider
3131
*/
32+
#[DataProvider('crud_dataProvider')]
3233
public function test_crud(AbstractTable&IUniqueTable $table, string $class): void
3334
{
3435
$table->truncate();

0 commit comments

Comments
 (0)