production icon indicating copy to clipboard operation
production copied to clipboard

TestBootstrap.php not using bootEnv

Open AndreasA opened this issue 3 years ago • 11 comments

PHP Version

8.1

Shopware Version

6.4.7.0

Expected behaviour

TestBootstrap.php to use bootEnv as all other files do, similar to Symfony's own bootstrap.php

Even better also move it to the tests folder as it has nothing to do with src.

Actual behaviour

Uses .env.test directly.

How to reproduce

Create a test case and not use APP_ENV=test but a custom test APP_ENV.

AndreasA avatar Jan 31 '22 06:01 AndreasA

I guess that file can be completly deleted as https://github.com/shopware/platform/blob/trunk/src/Core/TestBootstrapper.php should be used

shyim avatar Jan 31 '22 06:01 shyim

@shyim OK. But from what I can see that one also uses loadEnv instead of bootEnv.

AndreasA avatar Jan 31 '22 07:01 AndreasA

ooof . I forgot to change it there 😅

shyim avatar Jan 31 '22 07:01 shyim

@shyim Should testbootstrap not actually be changed completely to use the TestBootstrapper?

AndreasA avatar Mar 01 '22 06:03 AndreasA

Yes

shyim avatar Mar 01 '22 06:03 shyim

Didn't I changed it already 🤔

shyim avatar Mar 01 '22 06:03 shyim

https://github.com/shopware/platform/commit/e11ac0c230fa99b17d186b874883b0731a5a9b5f

shyim avatar Mar 01 '22 06:03 shyim

@shyim Yes, but this file still exists: https://github.com/shopware/production/blob/6.4/src/TestBootstrap.php and does not use the TestBootstrapper. I think it might be good to keep a test bootstrap in the template but I would moved it to tests/bootstrap.php (as symfony default has) and use TestBootstrapper there too? or just include the platform TestBootstrap.php file?

Especially as the phpunit.xml.dist still points to it https://github.com/shopware/production/blob/6.4/phpunit.xml.dist

AndreasA avatar Mar 01 '22 06:03 AndreasA

Feel free to make a PR :) reopend need a coffee 😅

shyim avatar Mar 01 '22 06:03 shyim

@shyim just wondering but is this file https://github.com/shopware/production/blob/6.4/config/services/defaults_test.xml still needed? because if I see it correctly the test bootstrapper nor just uses the same key (which I think is fine, there should be no need to differentiate).

AndreasA avatar Mar 01 '22 06:03 AndreasA

I am not sure. I would remove it and look if the test suite still passes 🙈 . Maybe @pweyck can say more

shyim avatar Mar 01 '22 06:03 shyim

We removed that file from the new template for now. I will look into adding a new flex package which adds this config back as I guess most of the users didn't event used that

shyim avatar Oct 25 '22 07:10 shyim