Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failing Unit Test #7

Open
HenKun opened this issue Feb 11, 2020 · 0 comments
Open

Failing Unit Test #7

HenKun opened this issue Feb 11, 2020 · 0 comments

Comments

@HenKun
Copy link

HenKun commented Feb 11, 2020

Failing unit test due to missing constructor parameter

Preconditions

Magento version 2.3.2
Enhanced SMTP version 1.0.7

Steps to reproduce

Run unit test SaveEmailLogTest::testPrepareMessage()

Expected result

Test passes

Actual result

TypeError : Argument 6 passed to KiwiCommerce\EnhancedSMTP\Email\Log\SaveEmailLog::__construct() must be an instance of Magento\Framework\Mail\MessageInterfaceFactory or null, instance of Mock_LogsFactory_267748ca given

Solution

To overcome the issue, a mock of type \Magento\Framework\Mail\MessageInterfaceFactory should be passed as 6th argument to SaveEmailLog constructor.

However, this leads to a successive failure: Error : Call to a member function create() on null

This is because the constructor of SaveEmailLog decided - based on the Magento version - which parent constructor should be called.

By default it takes the first variant in unit tests, because the real Magento version is not evaluated.
So the base class of Magento version < 2.2.8 is used.

Luckily the constructor of the base class in v 2.3.2 is backward compatible and gets the MessageInterfaceFactory itself from the object manager, if null is passed.

But this leads to further problems, I could not further investigate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant