Skip to content

Update PHPUnit docs #2153

@shyim

Description

@shyim

From Discord https://canary.discord.com/channels/1308047705309708348/1473628451943481374

so the ffeedback is not lost

Hi,

according to https://developer.shopware.com/docs/guides/plugins/plugins/testing/php-unit.html and
https://hub.shopware.com/learn/unit/phpunit-test,
a tests/TestBootstrap.php should be used which extends Shopware\Core\TestBootstrapper and setForceInstallPlugins(true)

Isn't it excessive to boot the kernel, require a DB connection and install the plugins on every run for pure unit tests?

Furthermore, the logic in "TestBootstrapper" does not work if you have dependencies on
plugins installed via composer, see here:
shopware/shopware#11456

Shopware also deemed this as low priority, so I wonder what the official approach for plugin unit tests should be then.

Even if getPluginPath is adapted to also take composer plugins into account, there are problems because the installPlugins method does not take into account the dependencies between these plugins, which leads to further issue on reinstall.

Sure, you can always cobble something together yourself, but is that really the way to go?

Answer:

hi, you dont need the TestBootstrapper for unit tests, we use them for integration tests only. i created two different phpunit.xml files where the default php unit just loads the autoloader and here we run the unit tests. for integration tests, i point to the Bootstrap file with test bootstrapper.
https://github.com/mollie/Shopware6/tree/master/config. here you can see the phpunit.xml and phpunit.integration.xml

for the database i also just read the connection from env so that the actual db is used instead of new shopware_test database.

https://github.com/mollie/Shopware6/blob/master/tests/bootstrap.php#L18

Metadata

Metadata

Assignees

No one assigned

    Labels

    Core@ct-core

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions