Calling Developers!
We are reenergizing our code contribution process! Learn More

What are the Slack Archives?

It’s a history of our time together in the Slack Community! There’s a ton of knowledge in here, so feel free to search through the archives for a possible answer to your question.

Because this space is not active, you won’t be able to create a new post or comment here. If you have a question or want to start a discussion about something, head over to our categories and pick one to post in! You can always refer back to a post from Slack Archives if needed; just copy the link to use it as a reference..

Hi all, question about tests - following error occurs: ``` Test ../Foo/Business/FooQueueTest.php:t

Options
U0107RNGSE8
U0107RNGSE8 Posts: 7 🧑🏻‍🚀 - Cadet

Hi all,
question about tests - following error occurs:

 Test  ../Foo/Business/FooQueueTest.php:testMessageSending

  [TypeError] Return value of Spryker\Zed\CompanyMailConnector\Business\CompanyMailConnectorBusinessFactory::getMailFacade() must implement interface Spryker\Zed\CompanyMailConnector\Dependency\Facade\CompanyMailConnectorToMailFacadeInterface, instance of Spryker\Zed\Customer\Dependency\Facade\CustomerToMailBridge returned  

#1  /builds/path/to-project/vendor/spryker/company-mail-connector/src/Spryker/Zed/CompanyMailConnector/Business/CompanyMailConnectorBusinessFactory.php:35
#2  /builds/path/to-project/vendor/spryker/company-mail-connector/src/Spryker/Zed/CompanyMailConnector/Business/CompanyMailConnectorBusinessFactory.php:25
#3  /builds/path/to-project/vendor/spryker/company-mail-connector/src/Spryker/Zed/CompanyMailConnector/Business/CompanyMailConnectorFacade.php:29
#4  /builds/path/to-project/vendor/spryker/company-mail-connector/src/Spryker/Zed/CompanyMailConnector/Communication/Plugin/Company/SendCompanyStatusChangePlugin.php:35
#5  /builds/path/to-project/vendor/spryker/company/src/Spryker/Zed/Company/Business/Model/CompanyPluginExecutor.php:66
#6  /builds/path/to-project/vendor/spryker/company/src/Spryker/Zed/Company/Business/Model/Company.php:135
#7  /builds/path/to-project/vendor/spryker/company/src/Spryker/Zed/Company/Business/Model/Company.php:74
#8  /builds/path/to-project/vendor/spryker/propel-orm/src/Spryker/Zed/PropelOrm/Business/Transaction/PropelDatabaseTransactionHandler.php:45
#9  /builds/path/to-project/vendor/spryker/company/src/Spryker/Zed/Company/Business/Model/Company.php:82
#10 /builds/path/to-project/vendor/spryker/company/src/Spryker/Zed/Company/Business/CompanyFacade.php:33
ERRORS!

we are only using default spryker helper in the tests and we also did nothing special within the code.. the test also worked for a while.. with adding another test, this error occurs 🤔 .. anybody an idea?

Comments

  • U013EK8RD7A
    U013EK8RD7A Posts: 127 🧑🏻‍🚀 - Cadet
    edited October 2020
    Options

    perhaps you should check if there are no updates for involved Spryker modules

  • U0107RNGSE8
    U0107RNGSE8 Posts: 7 🧑🏻‍🚀 - Cadet
    Options

    we did not make any updates in the meantime.

  • U013EK8RD7A
    U013EK8RD7A Posts: 127 🧑🏻‍🚀 - Cadet
    Options

    yeah, but you’ve probably started using a module which had a bug at the time it was installed

  • U0107RNGSE8
    U0107RNGSE8 Posts: 7 🧑🏻‍🚀 - Cadet
    Options

    hmm okay, that could be 🤔

  • Ahmed Sabaa
    Ahmed Sabaa Senior Application Architect @Spryker Sprykee Posts: 54 🧑🏻‍🚀 - Cadet
    Options

    Maybe some data cleanup is missing in your test?

  • U013EK8RD7A
    U013EK8RD7A Posts: 127 🧑🏻‍🚀 - Cadet
    Options

    IMHO it has nothing todo with data, because it’s PHP exception about interface mismatch

  • The problem is that the mail facade is provided in multiple module's dependency providers. The test setup is replacing that dependency globally in the dependency container (usually it is referred to as FACADE_MAIL). Since the different modules use different bridge interfaces, you see this issue coming up

  • U0107RNGSE8
    U0107RNGSE8 Posts: 7 🧑🏻‍🚀 - Cadet
    Options

    @UK5EG6PBM -> do you have any idea how this could be fixed? 🤔

  • Unknown
    edited October 2020
    Options

    Well, you could change MailFacadeInterface on project level and have it inherit all the necessary bridge interfaces. If you mock the mail facade using your project level interface, all the other place should have satisfied dependencies

  • Admittedly, that's not a pretty solution

  • Depending on the scope, it sometimes helps to limit replacement of dependencies during tests using the dependency helper and providing the necessary factory class name.
    https://github.com/spryker/testify/blob/master/tests/SprykerTest/Shared/Testify/_support/Helper/DependencyHelper.php#L65

    The $onlyFor argument can be used to limit the scope of the replacement