Skip to content

Commit

Permalink
Merge pull request #1090 from kenjis/update-test-CI45
Browse files Browse the repository at this point in the history
test: update for CI 4.5.0
  • Loading branch information
kenjis authored Apr 8, 2024
2 parents 0894a16 + 25e3ad2 commit af7ddd6
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 10 deletions.
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

0 comments on commit af7ddd6

Please sign in to comment.