magento2-enhanced-smtp
magento2-enhanced-smtp copied to clipboard
Failing Unit Test
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.