HI, I have a service provider and there I register some routes.. if a given config value is true/false I register different set of routes. Can I somehow change from my tests which routes get registered? If I use the Config facade to set new config value and list the routes they are still the same as they were before changing the config.
protected function setUp()
{
parent::setUp();
Config::set('pages.default_locale_in_uri', true);
}
when I dump the Route::getRotes() method I see the same routes.. it works just fine in the browser though. Any ideas what am I doing wrong and how can I test which set of routes gets registered?
Well if you request your routes on the command line (php artisan route:list) it will be a new request. So if you in another request have set the config for the routes, it will not affect the command. It will be a new request.
Anyway, I think the best way to handle this is either writing your own route:list command so you can force it to use the correct config.
Regarding using different routes for your tests. This sounds like a really bad idea. How can you test your application properly when your tests and your application use different endpoints :O
Ook I'll try to explain a bit better because it seems I failed..
I do not use different set of routes for my tests, I want to test the same routes that I have in my app. However few of the routes I want to have are being swapped for few other very similar routes but yet they do different things. So when my config boolean is set to true I will be working with one set of routes, when it is set to false then these few routes are swapped for the replacement routes. It is not something I will change programmatically or at run time, it probably won't change never after the initial configuration being done when I start a new project.
To be very clear, it is for URI multilingual setup for my projects. In the default case I want to have one configuration but if the project owner decide to change the requirements I want to be able to just change the config value and go ahead. Respectively I need to be sure that I did not broke the alternative functionality while developing.
Long story short, what I am trying to achieve is to test all the routes and functionality.
Cheers!
BTW I tried to set the config just before I call $this->get('some/route') but it is the same. If the config get's reset when I make the request... then what? Maybe it is time for me to dive deeper in the crazy TDD world. Could a 'mock' help me preserve the configuration until I get the result from that call? Or can I somehow pass a parameter to the service provider that registers the routes and force it to do as I wish?