Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: refactor Config/Registrar.php #8731

Merged
merged 3 commits into from
Apr 10, 2024
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
20 changes: 0 additions & 20 deletions phpstan-baseline.php
Original file line number Diff line number Diff line change
Expand Up @@ -10046,26 +10046,6 @@
'count' => 2,
'path' => __DIR__ . '/tests/_support/Config/Filters.php',
];
$ignoreErrors[] = [
'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#',
'count' => 1,
'path' => __DIR__ . '/tests/_support/Config/Registrar.php',
];
$ignoreErrors[] = [
'message' => '#^Method Tests\\\\Support\\\\Config\\\\Registrar\\:\\:Database\\(\\) return type has no value type specified in iterable type array\\.$#',
'count' => 1,
'path' => __DIR__ . '/tests/_support/Config/Registrar.php',
];
$ignoreErrors[] = [
'message' => '#^Method Tests\\\\Support\\\\Config\\\\Registrar\\:\\:Publisher\\(\\) return type has no value type specified in iterable type array\\.$#',
'count' => 1,
'path' => __DIR__ . '/tests/_support/Config/Registrar.php',
];
$ignoreErrors[] = [
'message' => '#^Property Tests\\\\Support\\\\Config\\\\Registrar\\:\\:\\$dbConfig type has no value type specified in iterable type array\\.$#',
'count' => 1,
'path' => __DIR__ . '/tests/_support/Config/Registrar.php',
];
$ignoreErrors[] = [
'message' => '#^Variable \\$routes might not be defined\\.$#',
'count' => 5,
Expand Down
14 changes: 7 additions & 7 deletions tests/_support/Config/Registrar.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ class Registrar
/**
* DB config array for testing purposes.
*
* @var array
* @var array<string, array<string, array<string, bool|int|string>|bool|int|string>>
*/
protected static $dbConfig = [
protected static array $dbConfig = [
'MySQLi' => [
'DSN' => '',
'hostname' => '127.0.0.1',
Expand Down Expand Up @@ -126,15 +126,15 @@ class Registrar
/**
* Override database config
*
* @return array
* @return array<string, array<string, bool|int|string>|bool|int|string>
*/
public static function Database()
public static function Database(): array
{
$config = [];

// Under GitHub Actions, we can set an ENV var named 'DB'
// so that we can test against multiple databases.
if (($group = getenv('DB')) && ! empty(self::$dbConfig[$group])) {
if (($group = getenv('DB')) && isset(self::$dbConfig[$group])) {
$config['tests'] = self::$dbConfig[$group];
}

Expand All @@ -146,9 +146,9 @@ public static function Database()
*
* @see PublisherRestrictionsTest::testRegistrarsNotAllowed()
*
* @return array
* @return array<string, array<string, string>>
*/
public static function Publisher()
public static function Publisher(): array
{
return [
'restrictions' => [SUPPORTPATH => '*'],
Expand Down
Loading