browser
browser copied to clipboard
Specifying headers and relying on $_SERVER
Hello,
I was trying to do a test on a controller using Mobile Detect lib (https://github.com/serbanghita/Mobile-Detect).
Like this:
$browser
->interceptRedirects()
->actingAs($user->_real())
->get('/', [
'headers' => [
'User-Agent' => 'blabla'
]
]);
However mobile detect lib seems to use $_SERVER to do his job, so $_SERVER['HTTP_USER_AGENT']. And using $browser as before does not seems to change $_SERVER. So I end up adding the following before my test:
$_SERVER['HTTP_USER_AGENT'] = 'blabla'
Which is working but not great as I also need to reset this value for any other tests in the same class.
I was wondering if I'm using the library the wrong way (zenstruck browser) or if there's anything that can be improved.
Regards,
Jean