CodeIgniter Forums
How to test filters are active on route? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forum-28.html)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forum-30.html)
+--- Thread: How to test filters are active on route? (/thread-79404.html)



How to test filters are active on route? - tgix - 06-10-2021

Upgraded to 4.1.3 just to be able to start adding tests to my project but fails miserably on the first hurdle.
I have many, many routes configured (~100) and most of them require a JWT token with specific privileges. When trying the steps from https://codeigniter.com/user_guide/testing/controllers.html#filter-testing I get nothing in return from any of the routes tested. I know there are filters defined because they run with the requests coming in normally.

In my test:
PHP Code:
public function testFiltersForAdminRoutes() {
        $this->assertFilter('companies/proctors''before''bearer-auth:comp');


In my Config/Routes.php
PHP Code:
$routes->group('companies', ['filter' => 'bearer-auth:comp'], function($routes) {
    $routes->get('proctors''Companies::proctors');


What gets me puzzled is this line from the description of Filter Testing:
Quote:$filtersConfig The default Config\Filters configuration (note: discovery is handle by Filters so this will not include module aliases)

All filters I have designed are aliases defined in Config/Filters.php - can I not do that?
I am trying to make sure the correct filters are executed based on the route - is that not possible?

Any help greatly appreciated!
/Mattias