Closed Modelizer closed 4 years ago
Which environment variables are we talking about? Generic variables or some that are used from PHPUnit_Selenium code?
Generic variables or some that are used from PHPUnit_Selenium code?
Global variables.
This would be a small example to understand
<php>
<env name="APP_ENV" value="testing"/>
<env name="CACHE_DRIVER" value="array"/>
<env name="SESSION_DRIVER" value="array"/>
<env name="QUEUE_DRIVER" value="sync"/>
<env name="DB_CONNECTION" value="testing"/>
</php>
Can you provide the simplest test case that fails because of this behavior? These are env variables that should be set by PHPUnit more than by this project, but maybe there is some weird interaction.
Problem is when PHPUnit is run it gets env variables from phpunit.xml
file which is correct but when selenium open a browser at that time it's not using phpunit.xml
file.
Here you will find a sample test case. https://github.com/Modelizer/Laravel-Selenium/issues/29
In phpunit.xml file we are setting DB_CONNECTION
as testing
<env name="DB_CONNECTION" value="testing"/>
But still when browser is loaded it reads from .env
file. which is weird.
Do you mean the PHP code that runs inside the web server, when loaded from a browser run from PHPUnit_Selenium, does not see that environment variable? That's expected as PHPUnit does not run in the same PHP process as the code that creates the HTML page. Being able to set environment variables from outside the web server would be a huge security hole.
Being able to set environment variables from outside the web server would be a huge security hole.
I think we are not setting env variables outside the web server.
That's expected as PHPUnit does not run in the same PHP process as the code that creates the HTML page.
Yes. Selenium is not able to share the same instances which is been run from CLI.
When an actual browser is open; selenium uses default environment variable from .env file. But as specified in doc https://phpunit.de/manual/current/en/appendixes.configuration.html#appendixes.configuration.php-ini-constants-variables it should load it from phpunit.xml file. Actual issue was raised on https://github.com/Modelizer/Laravel-Selenium/issues/29