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
5 changes: 0 additions & 5 deletions phpstan-baseline.php
Original file line number Diff line number Diff line change
Expand Up @@ -279,11 +279,6 @@
'count' => 2,
'path' => __DIR__ . '/src/Filters/TokenAuth.php',
];
$ignoreErrors[] = [
'message' => '#^Property CodeIgniter\\\\Shield\\\\Models\\\\LoginModel\\:\\:\\$validationRules \\(list\\<string\\>\\|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\\.$#',
Expand Down
2 changes: 1 addition & 1 deletion tests/Controllers/ActionsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
}

Expand Down
25 changes: 21 additions & 4 deletions tests/Unit/AuthRoutesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@

namespace Tests\Unit;

use CodeIgniter\CodeIgniter;
use CodeIgniter\Router\RouteCollection;
use CodeIgniter\Shield\Auth;
use Tests\Support\TestCase;

/**
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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']);
}
Expand Down