I would like to test a new function in a helper file.
function isProductionSite() {
return !(bool) preg_match('/admin|development/', request()->getHttpHost());
}
When I call this function in my test function I get my local address. Therefore I tried to mock the request()->getHttpHost.
public function testIsProductionSiteExpectFalse(): void
{
$request = Mockery::mock(Request::class);
$request->shouldReceive('getHttpHost')->once()->andReturn('admin.mydomain.de');
$this->assertFalse(isProductionSite());
}
In the Tets Function $request->getHttpHost() would now output admin.mydomain.de. But getHttpHost() from the function to be tested (isProductionSite()) gives me the correct host.
How can I set the HttpHost in the testcase so that the helper function outputs the manipulated host?