It seems that before Laravel 5.4 we could change the URL for testing by coding like this:
protected $baseUrl = 'http://someurl.com';
But now it is not working and some suggest we have to use this method
function setUp()
{
parent::setUp();
config(['app.url' => 'http://yourcustomeaddress.loc']);
}
Would anybody help me and tell Where I should put this method?
You may put it in tests/TestCase.php
(Laravel 5.4 example):
abstract class TestCase extends BaseTestCase
{
function setUp()
{
parent::setUp();
config(['app.url' => 'http://yourcustomeaddress.loc']);
}
use CreatesApplication;
}
Or you may add it in specific test:
class ExampleTest extends TestCase
{
function setUp()
{
parent::setUp();
config(['app.url' => 'http://yourcustomeaddress.loc']);
}
// your test functions
}