Skip to content

Commit

Permalink
Merge pull request #8731 from kenjis/refactor-test-Registrar.php
Browse files Browse the repository at this point in the history
test: refactor Config/Registrar.php
  • Loading branch information
kenjis authored Apr 10, 2024
2 parents 6b6fcaa + d3a03a7 commit 2c524fd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 27 deletions.
20 changes: 0 additions & 20 deletions phpstan-baseline.php
Original file line number Diff line number Diff line change
Expand Up @@ -10041,26 +10041,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

0 comments on commit 2c524fd

Please sign in to comment.