I am testing a multi-lingual site with phpunit. One of the tests I want to perform is that the application will detect the locale of the user and automatically redirect.
That is, user accesses the site on /. The application detects they're from France and redirects to /fr-FR/
The application does appear to do this, but trying to write a unit test for this seems impossible. I need to forge the locale for the purpose of the test. Can anyone advise?
It's probably looking at the Accept-Language header that the browser sends. You can access this in PHP using
$_SERVER['HTTP_ACCEPT_LANGUAGE']
. It's a global, so in your test setup, you could change its value: