Skip to content

Commit af7ddd6

Browse files
authored
Merge pull request #1090 from kenjis/update-test-CI45
test: update for CI 4.5.0
2 parents 0894a16 + 25e3ad2 commit af7ddd6

File tree

3 files changed

+22
-10
lines changed

3 files changed

+22
-10
lines changed

phpstan-baseline.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -279,11 +279,6 @@
279279
'count' => 2,
280280
'path' => __DIR__ . '/src/Filters/TokenAuth.php',
281281
];
282-
$ignoreErrors[] = [
283-
'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\'\\}\\.$#',
284-
'count' => 1,
285-
'path' => __DIR__ . '/src/Models/LoginModel.php',
286-
];
287282
$ignoreErrors[] = [
288283
'message' => '#^Call to deprecated function random_string\\(\\)\\:
289284
The type \'basic\', \'md5\', and \'sha1\' are deprecated\\. They are not cryptographically secure\\.$#',

tests/Controllers/ActionsTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ public function testEmail2FAHandleInvalidEmail(): void
102102
]);
103103

104104
$result->assertRedirect();
105-
$result->assertSame(site_url('/auth/a/show'), $result->getRedirectUrl());
105+
$this->assertSame(site_url('/auth/a/show'), $result->getRedirectUrl());
106106
$result->assertSessionHas('error', lang('Auth.invalidEmail'));
107107
}
108108

tests/Unit/AuthRoutesTest.php

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313

1414
namespace Tests\Unit;
1515

16+
use CodeIgniter\CodeIgniter;
17+
use CodeIgniter\Router\RouteCollection;
18+
use CodeIgniter\Shield\Auth;
1619
use Tests\Support\TestCase;
1720

1821
/**
@@ -22,12 +25,18 @@ final class AuthRoutesTest extends TestCase
2225
{
2326
public function testRoutes(): void
2427
{
28+
/** @var RouteCollection $collection */
2529
$collection = single_service('routes');
26-
$auth = service('auth');
30+
/** @var Auth $auth */
31+
$auth = service('auth');
2732

2833
$auth->routes($collection);
2934

30-
$routes = $collection->getRoutes('get');
35+
if (version_compare(CodeIgniter::CI_VERSION, '4.5') >= 0) {
36+
$routes = $collection->getRoutes('GET');
37+
} else {
38+
$routes = $collection->getRoutes('get');
39+
}
3140

3241
$this->assertArrayHasKey('register', $routes);
3342
$this->assertArrayHasKey('login', $routes);
@@ -43,7 +52,11 @@ public function testRoutesExcept(): void
4352

4453
$auth->routes($collection, ['except' => ['login']]);
4554

46-
$routes = $collection->getRoutes('get');
55+
if (version_compare(CodeIgniter::CI_VERSION, '4.5') >= 0) {
56+
$routes = $collection->getRoutes('GET');
57+
} else {
58+
$routes = $collection->getRoutes('get');
59+
}
4760

4861
$this->assertArrayNotHasKey('login', $routes);
4962
$this->assertArrayHasKey('register', $routes);
@@ -59,7 +72,11 @@ public function testRoutesCustomNamespace(): void
5972

6073
$auth->routes($collection, ['namespace' => 'Auth']);
6174

62-
$routes = $collection->getRoutes('get');
75+
if (version_compare(CodeIgniter::CI_VERSION, '4.5') >= 0) {
76+
$routes = $collection->getRoutes('GET');
77+
} else {
78+
$routes = $collection->getRoutes('get');
79+
}
6380

6481
$this->assertSame('\Auth\RegisterController::registerView', $routes['register']);
6582
}

0 commit comments

Comments
 (0)