-
Notifications
You must be signed in to change notification settings - Fork 2k
Closed
Description
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
namespace App\Libraries;
class Sample
{
public function urlTo($route)
{
return url_to($route);
}
public function routeTo($route)
{
return route_to($route);
}
}SampleTest.php - sample test
use App\Libraries\Sample;
use CodeIgniter\Test\CIUnitTestCase;
/**
* @internal
*/
final class SampleTest extends CIUnitTestCase
{
protected function setUp(): void
{
$this->resetServices();
parent::setUp();
}
public function testSampleUrlTo()
{
$sample = new Sample();
$this->assertInstanceOf(Sample::class, $sample);
$this->assertSame(
'http://example.com/index.php/sample-url-1',
$sample->urlTo('sample1')
);
}
public function testSampleRouteTo()
{
$sample = new Sample();
$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.
Metadata
Metadata
Assignees
Labels
No labels