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\\.$#', 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')); } 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']); }