I have a multi site project in Laravel 5.4. I'm trying to run site-specific tests on each domain using PHPUnit.
My setup.
1) In my .env
file I have
DOMAIN_DEV_1=http://dev.site1.net
DOMAIN_DEV_2=http://dev.site2.net
2) In my CreateApplication
trait of my TestCase()
I have
public function createApplication()
{
$app = require __DIR__.'/../bootstrap/app.php';
$app->make(Kernel::class)->bootstrap();
$this->baseUrl = $_ENV['DOMAIN_DEV_1'];
// $this->baseUrl = $_ENV['DOMAIN_DEV_2'];
return $app;
}
3) Lastly, in my phpunit.xml
I have
<php>
...
<env name="DOMAIN_DEV_1" value="http://dev.site1.net"/>
<!-- <env name="DOMAIN_DEV_2" value="http://dev.site2.net"/> -->
</php>
Tests) So in my ExampleTest
file I added in a few basic http checks inside the function testBasicTest()
:
$this->assertTrue(true); //passes
$this->assertFalse(false); //passes
$login = $this->get('/login');
$login->assertStatus(200); //passes. returns 200
$logout = $this->get('/logout');
$logout->assertStatus(200); //returns 404
$base = $this->get('/');
$base->assertStatus(200); //returns 404
But the only one that works in the get('/login')
assertion. Both the logout and base return 404. When I was trying to debug to make sure I was at least getting the correct baseUrl, I added in:
echo 'Domain = $this->baseUrl';
And sure enough in my command like was
PHPUnit 5.7.20 by Sebastian Bergmann and Contributors.
..FPHP Domain = http://dev.site1.net
So I'm not really sure what is going wrong exactly. Any helpful hints/pointers to the right direction?
Thanks again!
Aucun commentaire:
Enregistrer un commentaire