-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: filters are executed when controller does not exist with Auto Routing (Legacy). #7925
Conversation
f2f9638
to
5a3d48d
Compare
@kenjis Got it and I have modified that. |
@ping-yee I think CodeIgniter4/system/Router/AutoRouter.php Lines 99 to 101 in f35f956
|
@kenjis Seems that it will have some problem occur after add the |
Do you mean the following PHPUnit errors?
|
For example, see the following test. RouteCollectionTest: /**
* @dataProvider provideRouteDefaultNamespace
*
* @param mixed $namespace
*/
public function testAutoRoutesControllerNameReturnsFQCN($namespace): void
{
$routes = $this->getCollector();
$routes->setAutoRoute(true);
$routes->setDefaultNamespace($namespace);
$router = new Router($routes, Services::request());
$router->handle('/product');
$this->assertSame('\App\\Controllers\\Product', $router->controllerName());
} |
👋 Hi, @ping-yee! |
f3aadcc
to
a1f2c50
Compare
I am also feel confused about this and I wonder how these test cases work as we expect, like this case as below. public function testAutoRouteFindsControllerWithSubfolder(): void
{
$this->collection->setAutoRoute(true);
$router = new Router($this->collection, $this->request);
mkdir(APPPATH . 'Controllers/Subfolder');
$router->autoRoute('subfolder/myController/someMethod');
rmdir(APPPATH . 'Controllers/Subfolder');
$this->assertSame('MyController', $router->controllerName());
$this->assertSame('someMethod', $router->methodName());
} It make a |
That is a test to find the controller in a subfolder, so the controller should be present. In the test code, the controller file that should be prepared is not created because the test passes without a controller file. |
Yes. And I also find that the testing used controllers has been prepared in the same directory. https://github.com/codeigniter4/CodeIgniter4/tree/develop/tests/system/Router But I think the controllers aren't being used because it's different method name between the test case and mock controller. Or I have some misunderstandings. public function testAutoRouteFindsControllerWithSubfolder(): void
{
$this->collection->setAutoRoute(true);
$router = new Router($this->collection, $this->request);
mkdir(APPPATH . 'Controllers/Subfolder');
$router->autoRoute('subfolder/myController/someMethod');
rmdir(APPPATH . 'Controllers/Subfolder');
$this->assertSame('MyController', $router->controllerName());
$this->assertSame('someMethod', $router->methodName());
} namespace CodeIgniter\Router\Controllers\Subfolder;
use CodeIgniter\Controller;
class Mycontroller extends Controller
{
public function getSomemethod(): void
{
}
} |
a1f2c50
to
bc31b56
Compare
@kenjis I fix the problem that the controller isn't exist into few test cases at the latest commit, please review. |
Yes, these controllers are for testing Auto Routing Improved. |
@ping-yee Thank you. Your way seems to be okay. It is better not to copy files during testing, but the Auto Routing Legacy has hard coded |
… with Auto Routing (Legacy).
60f7e69
to
3ecdc1b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
Description
See #7205
Checklist: