Global Dependency Provider is not used in tests

shas
shas Software Engineer Posts: 1 🧑🏻‍🚀 - Cadet

Hi,

We moved some dependencies to a Global Dependency Provider as documented by spryker here https://docs.spryker.com/docs/scos/dev/back-end-development/factory/inject-dependencies-within-factories-container-globals.html . This works fine. But when exeucting tests codeception does not recognize the dependencies registered in the Global Dependency Provider.

The first assumption was that it just needs to be registered in yet another Class which uses 'getApplicationPlugins' to register those but unfortunately there is no option provided for codeception.

Currently our solution is to customize the "src/Pyz/Shared/Kernel/ContainerMocker/ContainerMocker.php" trait and manually add the Global Dependency Provider by then also customizing every single Class that uses this trait. This works, but obviously isn't ideal. There should be an option to make codeception aware of Global Dependencies in a single central location.

Has anybody else encountered this problem and has a more efficient solution or did we overlook something?

Answers

  • fsmeier
    fsmeier Senior Software Engineer & Developer Enablement Advocate Sprykee Posts: 1,075 ⚖️ - Guardians (admin)

    Heyhey @shas ,

    I have some questions to understand the challenge a bit better:

    1. Where did you register your ApplicationPlugin?
    2. What kind of test are you trying to write?

    Because without a full boot of your targeted Application no ApplicationPlugin should be loaded at all.

    Maybe you can show me your codeception.yml

    All the best,

    Florian