Get Config in Routes tested?

I need to make my routes conditional, based on config:

if (config('auth.allow_registration')) {....

The above config param is set in the config file:

//config/auth.php

'allow_registration' => false,

It is all working fine, until I try to unit-test it

public function test_registration_screen_can_be_rendered()
{
    config()->set('auth.allow_registration', true);
    $response = $this->get('/register');

    $response->assertStatus(200);
}

The test case is failing.

I understand that after I change config, I need to reread routes. But how?

I found only this $this->refreshApplication(); it suppose to reread routes, but it also rereads the config.

How can I only reread routes, but keep my modified config intact?

Source: Laravel

Leave a Reply