shopware/development

Unable to run unit tests for plugin

Closed this issue · 2 comments

PHP Version

7.4

Shopware Version

6.4.99 (cloned from github)

Expected behaviour

(This may also belong in the platform queue, but I THINK this is an issue with the development template.)

After installing the development template (in a valet environment on MacOS, as per https://developer.shopware.com/docs/guides/installation/valet), I should be able to run the unit tests of my custom plugin with the vanilla phpunit.xml.dist as per https://developer.shopware.com/docs/guides/plugins/plugins/testing/php-unit.

( I suspect this documentation is slightly outdated, e.g. the schema version used in the phpunit.xml.dist template given. But the named bootstrap file exists, and should (via Testbootstrapper.php) set the correct dsn.)

Actual behaviour

Trying to run the unit tests, phpunit complains:Environment variable 'DATABASE_URL' does not contain a valid dsn. and does nothing.

How to reproduce

See above.

Closing this because it is most likely a doc issue.

The docs linked above instruct to invoke phpunit from the plugin directory, which results in the reported message. Invoking phpunit from the shopware root directory (with --configuration=custom/plugins/PLUGIN/phpunit.xml.dist) runs the tests without a problem.

Possibly not a doc issue after all - see this related issue in the platform queue.

(Posting for reference in case someone stumbles over this closed issue.)