octobercms / october

Self-hosted CMS platform based on the Laravel PHP Framework.
https://octobercms.com/
Other
10.99k stars 2.22k forks source link

plugin:test command ignores phpunit.xml environment variables #5799

Closed uematsusoft closed 1 month ago

uematsusoft commented 2 months ago

Hello,

When testing a plugin with the command php artisan plugin:test PLUGIN.NAME the environment variables defined in the phpunit.xml file are ignored destroying, in my case, the database state.

The only way that I was able to run the test in another set of env variables is to create an .env.testing file and then, run the command forcing the enviroment php artisan plugin:test PLUGIN.NAME --env=testing.

If i run the command ..\..\..\vendor\bin\phpunit, in the plugin's folder, everything works correctly even without the .env.testing file.

October version is 3.6.18, phpunit is **10.*, php is 8.1.28** and I am using Window 10.

Thank you.

daftspunk commented 1 month ago

Hi @uematsusoft

Does it ignore the variables set in phpunit.xml? Eg:

    <php>
        <env name="APP_ENV" value="testing" />
        <env name="APP_LOCALE" value="en" />
        <env name="CACHE_DRIVER" value="array" />
        <env name="SESSION_DRIVER" value="array" />
        <env name="ACTIVE_THEME" value="test" />
        <env name="CONVERT_LINE_ENDINGS" value="true" />
        <env name="CMS_SAFE_MODE" value="false" />
        <env name="CMS_ROUTE_CACHE" value="true" />
        <env name="CMS_TWIG_CACHE" value="false" />
        <env name="PLUGINS_PATH" value="modules/system/tests/fixtures/plugins" />
        <env name="THEMES_PATH" value="modules/cms/tests/fixtures/themes" />
        <env name="ENABLE_CSRF" value="false" />
        <env name="DB_CONNECTION" value="sqlite" />
        <env name="DB_DATABASE" value=":memory:" />
    </php>
uematsusoft commented 1 month ago

Yes, and the .env.testing as well. The only way that it does not ignore the .env.testing is if I add the --env=testing parameter to the command.

daftspunk commented 1 month ago

Fixed in d262baf1f91427c4b90e72e0cc8d8ef9a8a79021

Released in v3.6.23

Thanks!