How to set $_SERVER['var'] in a functional test?

Hi guys,

I have an action to make an ‘autologin’ based in a id that the system gets from $_SERVER[‘AUTH_USER’]. In my business server that value is always set for authenticated user. Now, I am trying test my autologin (and so many other things that depends the autologin to work) so I need to set some user to that global (just a string).

[size="3"]What I tryed[/size]

$_SERVER['AUTH_USER'] = 'someUser';

$I->amOnPage('some-route'); // this page redirects to autologin action where $_SERVER is used to get the user logged.

But when the action autologin is loaded that value is no more inside $_SERVER global and my test crashes.

[size="3"]What I would like to know[/size]

Where or how I can set that global value so that my page could behave normally, reading the value and just going on.

I will appreciate any help.

Thank you.

For now, I am using a workaround because there is only one place where that variable value it is checked:

//Inside my action autologin:    

$authUser = explode('\\', ($_SERVER['AUTH_USER'] ?? (YII_ENV_TEST ? 'domain\x12345' : 'domain\xInvalid')))[1];

The only relevant point here is [i]YII_ENV_TEST[/i] that is [i]true[/i] when testing. Using this I can set get an specific value that is enough to that simple test.

However I hope to see any other better idea here! Thanks.

[font="Arial,"] [/font]