Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 21 additions & 6 deletions tests/Platform/QueryResultTypeWalkerFetchTypeMatrixTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,12 @@
use PHPUnit\Framework\Constraint\IsIdentical;
use Psr\Log\LoggerInterface;
use Throwable;
use function assert;
use function class_exists;
use function floor;
use function getenv;
use function in_array;
use function is_string;
use function method_exists;
use function reset;
use function sprintf;
Expand All @@ -65,6 +67,9 @@
/**
* This test ensures our query type inferring never differs from actual result types produced by PHP, Database drivers and Doctrine (with various versions and configurations).
*
* @phpstan-type Driver 'ibm_db2'|'mysqli'|'oci8'|'pdo_mysql'|'pdo_oci'|'pdo_pgsql'|'pdo_sqlite'|'pdo_sqlsrv'|'pgsql'|'sqlite3'|'sqlsrv'
* @phpstan-import-type Params from DriverManager
*
* @group platform
*/
final class QueryResultTypeWalkerFetchTypeMatrixTest extends PHPStanTestCase
Expand Down Expand Up @@ -4432,6 +4437,7 @@ public static function provideCases(): iterable
}

/**
* @param Driver $driver
* @param mixed $expectedFirstResult
* @param array<string, mixed> $data
* @param self::STRINGIFY_* $stringification
Expand Down Expand Up @@ -4511,7 +4517,7 @@ private function performDriverTest(
}

/**
* @param array<string, mixed> $connectionParams
* @param Params $connectionParams
*/
private function createConnection(
array $connectionParams
Expand All @@ -4534,7 +4540,7 @@ private function createConnection(
$connection->executeQuery('USE foo');
}

if ($connectionParams['driver'] === 'pdo_mysql') {
if (isset($connectionParams['driver']) && $connectionParams['driver'] === 'pdo_mysql') {
$connection->executeQuery('SET GLOBAL max_connections = 1000');
}

Expand Down Expand Up @@ -4734,23 +4740,29 @@ private function assertInferredResultMatchesExpected(
}

/**
* @return array<string, mixed>
* @return Params
*/
private function getConnectionParamsForDriver(string $driver): array
{
switch ($driver) {
case 'pdo_mysql':
case 'mysqli':
$host = getenv('MYSQL_HOST');
assert(is_string($host));

return [
'host' => getenv('MYSQL_HOST'),
'host' => $host,
'user' => 'root',
'password' => 'secret',
'dbname' => 'foo',
];
case 'pdo_pgsql':
case 'pgsql':
$host = getenv('PGSQL_HOST');
assert(is_string($host));

return [
'host' => getenv('PGSQL_HOST'),
'host' => $host,
'user' => 'root',
'password' => 'secret',
'dbname' => 'foo',
Expand All @@ -4763,8 +4775,11 @@ private function getConnectionParamsForDriver(string $driver): array
];
case 'pdo_sqlsrv':
case 'sqlsrv':
$host = getenv('MSSQL_HOST');
assert(is_string($host));

return [
'host' => getenv('MSSQL_HOST'),
'host' => $host,
'user' => 'SA',
'password' => 'Secret.123',
// user database is created after connection
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public function test(Type $expectedType, string $dql, string $methodName, ?int $
}

/**
* @return iterable<string,array{Type,string,2?:string|null}>
* @return iterable<string,array{Type,string,string,3?:int|null}>
*/
public static function getTestData(): iterable
{
Expand Down
Loading