PHP Version
8.2
CodeIgniter4 Version
4.4.1 and develop
CodeIgniter4 Installation Method
Composer (using codeigniter4/appstarter)
Which operating systems have you tested for this bug?
macOS
Which server did you use?
cli
Database
irrelevant
What happened?
Using resetServices() in tests causes named routes to fail.
Steps to Reproduce
Routes.php
$routes->get('sample-url-1', 'HomeController::index', ['as' => 'sample1']);Sample.php - sample library
namespaceApp\Libraries;
class Sample
{
publicfunctionurlTo($route)
{
returnurl_to($route);
}
publicfunctionrouteTo($route)
{
returnroute_to($route);
}
}SampleTest.php - sample test
useApp\Libraries\Sample;
useCodeIgniter\Test\CIUnitTestCase;
/** * @internal */finalclass SampleTest extends CIUnitTestCase
{
protectedfunctionsetUp(): void
{
$this->resetServices();
parent::setUp();
}
publicfunctiontestSampleUrlTo()
{
$sample = newSample();
$this->assertInstanceOf(Sample::class, $sample);
$this->assertSame(
'http://example.com/index.php/sample-url-1',
$sample->urlTo('sample1')
);
}
publicfunctiontestSampleRouteTo()
{
$sample = newSample();
$this->assertInstanceOf(Sample::class, $sample);
$this->assertSame('/sample-url-1', $sample->routeTo('sample1'));
}
}Expected Output
Passing tests.
Anything else?
If we comment out the line with $this->resetServices();, then all tests will pass.
PHP Version
8.2
CodeIgniter4 Version
4.4.1 and develop
CodeIgniter4 Installation Method
Composer (using
codeigniter4/appstarter)Which operating systems have you tested for this bug?
macOS
Which server did you use?
cli
Database
irrelevant
What happened?
Using
resetServices()in tests causes named routes to fail.Steps to Reproduce
Routes.php
Sample.php - sample library
SampleTest.php - sample test
Expected Output
Passing tests.
Anything else?
If we comment out the line with
$this->resetServices();, then all tests will pass.