You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
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.
The text was updated successfully, but these errors were encountered: