Skip to content

Commit 8c90aa0

Browse files
authored
Merge pull request #3570 from paulbalandan/featuretesttrait-routes
Use null coalescing to routes resolution in FeatureTestTrait::call
2 parents 1fa648a + 02daf8f commit 8c90aa0

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

system/Test/FeatureTestTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ public function call(string $method, string $path, array $params = null)
167167
$request = $this->populateGlobals($method, $request, $params);
168168

169169
// Make sure the RouteCollection knows what method we're using...
170-
$routes = $this->routes ?: Services::routes(); // @phpstan-ignore-line
170+
$routes = $this->routes ?? Services::routes();
171171
$routes->setHTTPVerb($method);
172172

173173
// Make sure any other classes that might call the request

tests/system/HomeTest.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
namespace CodeIgniter;
4+
5+
use CodeIgniter\Test\CIUnitTestCase;
6+
use CodeIgniter\Test\FeatureTestTrait;
7+
8+
class HomeTest extends CIUnitTestCase
9+
{
10+
use FeatureTestTrait;
11+
12+
public function testPageLoadsSuccessfully()
13+
{
14+
$this->withRoutes([
15+
[
16+
'get',
17+
'home',
18+
'\App\Controllers\Home::index',
19+
],
20+
]);
21+
22+
$response = $this->get('home');
23+
$this->assertInstanceOf('CodeIgniter\Test\FeatureResponse', $response);
24+
$this->assertTrue($response->isOK());
25+
}
26+
}

0 commit comments

Comments
 (0)