Skip to content

Commit 7090efb

Browse files
authored
Fix argument count of data providers (#7076)
| Q | A |------------- | ----------- | Type | improvement | Fixed issues | Preparation for #7075 #### Summary In PHPUnit 12, we get a warning if a data provider provides more arguments than a test method consumes. Let's tackle this issue on our lower branches already in order to keep the diff small.
1 parent 3626601 commit 7090efb

File tree

1 file changed

+31
-14
lines changed

1 file changed

+31
-14
lines changed

tests/Platforms/PostgreSQLPlatformTest.php

Lines changed: 31 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Doctrine\DBAL\TransactionIsolationLevel;
1515
use Doctrine\DBAL\Types\Type;
1616
use Doctrine\DBAL\Types\Types;
17+
use Generator;
1718
use UnexpectedValueException;
1819

1920
use function sprintf;
@@ -427,9 +428,9 @@ protected function getQuotedColumnInForeignKeySQL(): array
427428
}
428429

429430
/**
430-
* @param string|bool $databaseValue
431+
* @param string|bool|null $databaseValue
431432
*
432-
* @dataProvider pgBooleanProvider
433+
* @dataProvider provideConvertBooleansAsLiteralStrings
433434
*/
434435
public function testConvertBooleanAsLiteralStrings(
435436
$databaseValue,
@@ -440,6 +441,14 @@ public function testConvertBooleanAsLiteralStrings(
440441
self::assertEquals($preparedStatementValue, $platform->convertBooleans($databaseValue));
441442
}
442443

444+
/** @return Generator<int, array{string|bool|null, string}> */
445+
public static function provideConvertBooleansAsLiteralStrings(): Generator
446+
{
447+
foreach (self::pgBooleanProvider() as $key => $params) {
448+
yield $key => [$params[0], $params[1]];
449+
}
450+
}
451+
443452
public function testConvertBooleanAsLiteralIntegers(): void
444453
{
445454
$platform = $this->createPlatform();
@@ -452,14 +461,8 @@ public function testConvertBooleanAsLiteralIntegers(): void
452461
self::assertEquals(0, $platform->convertBooleans('0'));
453462
}
454463

455-
/**
456-
* @param string|bool $databaseValue
457-
*
458-
* @dataProvider pgBooleanProvider
459-
*/
464+
/** @dataProvider provideConvertBooleanAsDatabaseValueStrings */
460465
public function testConvertBooleanAsDatabaseValueStrings(
461-
$databaseValue,
462-
string $preparedStatementValue,
463466
?int $integerValue,
464467
?bool $booleanValue
465468
): void {
@@ -468,6 +471,14 @@ public function testConvertBooleanAsDatabaseValueStrings(
468471
self::assertSame($integerValue, $platform->convertBooleansToDatabaseValue($booleanValue));
469472
}
470473

474+
/** @return Generator<int, array{int|null, bool|null}> */
475+
public static function provideConvertBooleanAsDatabaseValueStrings(): Generator
476+
{
477+
foreach (self::pgBooleanProvider() as $key => $params) {
478+
yield $key => [$params[2], $params[3]];
479+
}
480+
}
481+
471482
public function testConvertBooleanAsDatabaseValueIntegers(): void
472483
{
473484
$platform = $this->createPlatform();
@@ -478,21 +489,27 @@ public function testConvertBooleanAsDatabaseValueIntegers(): void
478489
}
479490

480491
/**
481-
* @param string|bool $databaseValue
492+
* @param string|bool|null $databaseValue
482493
*
483-
* @dataProvider pgBooleanProvider
494+
* @dataProvider provideConvertFromBoolean
484495
*/
485496
public function testConvertFromBoolean(
486497
$databaseValue,
487-
string $prepareStatementValue,
488-
?int $integerValue,
489498
?bool $booleanValue
490499
): void {
491500
$platform = $this->createPlatform();
492501

493502
self::assertSame($booleanValue, $platform->convertFromBoolean($databaseValue));
494503
}
495504

505+
/** @return Generator<int, array{string|bool|null, bool|null}> */
506+
public static function provideConvertFromBoolean(): Generator
507+
{
508+
foreach (self::pgBooleanProvider() as $key => $params) {
509+
yield $key => [$params[0], $params[3]];
510+
}
511+
}
512+
496513
public function testThrowsExceptionWithInvalidBooleanLiteral(): void
497514
{
498515
$platform = $this->createPlatform();
@@ -745,7 +762,7 @@ protected function getQuotedAlterTableRenameIndexSQL(): array
745762
/**
746763
* PostgreSQL boolean strings provider
747764
*
748-
* @return mixed[][]
765+
* @return list<array{string|bool|null, string, int|null, bool|null}>
749766
*/
750767
public static function pgBooleanProvider(): iterable
751768
{

0 commit comments

Comments
 (0)