From 5994c2560b3ee9a3242178496570a03e29788613 Mon Sep 17 00:00:00 2001 From: kenjis Date: Mon, 8 Apr 2024 20:53:44 +0900 Subject: [PATCH 1/3] chore: update phpstan-baseline.php --- phpstan-baseline.php | 5 ----- 1 file changed, 5 deletions(-) diff --git a/phpstan-baseline.php b/phpstan-baseline.php index 0b47303f5..948dd522e 100644 --- a/phpstan-baseline.php +++ b/phpstan-baseline.php @@ -279,11 +279,6 @@ 'count' => 2, 'path' => __DIR__ . '/src/Filters/TokenAuth.php', ]; -$ignoreErrors[] = [ - 'message' => '#^Property CodeIgniter\\\\Shield\\\\Models\\\\LoginModel\\:\\:\\$validationRules \\(list\\\\|string\\) does not accept default value of type array\\{ip_address\\: \'required\', id_type\\: \'required\', identifier\\: \'permit_empty\\|string\', user_agent\\: \'permit_empty\\|string\', user_id\\: \'permit_empty\', date\\: \'required\'\\}\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/src/Models/LoginModel.php', -]; $ignoreErrors[] = [ 'message' => '#^Call to deprecated function random_string\\(\\)\\: The type \'basic\', \'md5\', and \'sha1\' are deprecated\\. They are not cryptographically secure\\.$#', From 5b10fa870954940310b63a8d799bb3078edcc595 Mon Sep 17 00:00:00 2001 From: kenjis Date: Mon, 8 Apr 2024 20:53:57 +0900 Subject: [PATCH 2/3] test: update assert method --- tests/Controllers/ActionsTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Controllers/ActionsTest.php b/tests/Controllers/ActionsTest.php index a6d9394f6..f44d5fc44 100644 --- a/tests/Controllers/ActionsTest.php +++ b/tests/Controllers/ActionsTest.php @@ -102,7 +102,7 @@ public function testEmail2FAHandleInvalidEmail(): void ]); $result->assertRedirect(); - $result->assertSame(site_url('/auth/a/show'), $result->getRedirectUrl()); + $this->assertSame(site_url('/auth/a/show'), $result->getRedirectUrl()); $result->assertSessionHas('error', lang('Auth.invalidEmail')); } From 25e3ad2f312e0ad3a015ed81289ffd657c388e84 Mon Sep 17 00:00:00 2001 From: kenjis Date: Mon, 8 Apr 2024 21:13:28 +0900 Subject: [PATCH 3/3] test: update test code with RouteCollection::getRoutes() --- tests/Unit/AuthRoutesTest.php | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/tests/Unit/AuthRoutesTest.php b/tests/Unit/AuthRoutesTest.php index c0c5f2741..d4e568121 100644 --- a/tests/Unit/AuthRoutesTest.php +++ b/tests/Unit/AuthRoutesTest.php @@ -13,6 +13,9 @@ namespace Tests\Unit; +use CodeIgniter\CodeIgniter; +use CodeIgniter\Router\RouteCollection; +use CodeIgniter\Shield\Auth; use Tests\Support\TestCase; /** @@ -22,12 +25,18 @@ final class AuthRoutesTest extends TestCase { public function testRoutes(): void { + /** @var RouteCollection $collection */ $collection = single_service('routes'); - $auth = service('auth'); + /** @var Auth $auth */ + $auth = service('auth'); $auth->routes($collection); - $routes = $collection->getRoutes('get'); + if (version_compare(CodeIgniter::CI_VERSION, '4.5') >= 0) { + $routes = $collection->getRoutes('GET'); + } else { + $routes = $collection->getRoutes('get'); + } $this->assertArrayHasKey('register', $routes); $this->assertArrayHasKey('login', $routes); @@ -43,7 +52,11 @@ public function testRoutesExcept(): void $auth->routes($collection, ['except' => ['login']]); - $routes = $collection->getRoutes('get'); + if (version_compare(CodeIgniter::CI_VERSION, '4.5') >= 0) { + $routes = $collection->getRoutes('GET'); + } else { + $routes = $collection->getRoutes('get'); + } $this->assertArrayNotHasKey('login', $routes); $this->assertArrayHasKey('register', $routes); @@ -59,7 +72,11 @@ public function testRoutesCustomNamespace(): void $auth->routes($collection, ['namespace' => 'Auth']); - $routes = $collection->getRoutes('get'); + if (version_compare(CodeIgniter::CI_VERSION, '4.5') >= 0) { + $routes = $collection->getRoutes('GET'); + } else { + $routes = $collection->getRoutes('get'); + } $this->assertSame('\Auth\RegisterController::registerView', $routes['register']); }