dotmailer / dotmailer-magento2-extension

The official Dotdigital for Magento2 extension
https://dotdigital.com/integrations/magento
MIT License
49 stars 63 forks source link

Declaration of Tests setUp() functions are not compatible with PHPUnit\Framework\TestCase::setUp() #566

Closed t-heuser closed 4 years ago

t-heuser commented 4 years ago

Every unit and integration test setUp() function has not the typed return type "void". This throws the following error: PHP Fatal error: Declaration of Dotdigitalgroup\Email\Test\Integration\Model\Sync\Importer\BulkRecordsImportedSuccessTest::setUp() must be compatible with PHPUnit\Framework\TestCase::setUp()

I guess that every test has to be refactored so that the setUp() functions don't look like this:

    public function setUp()
    {
    ....

but instead like this:

    public function setUp(): void
    {
    ....

The error appears since the magento 2.4.0 update as it's now using PhpUnit 9 which has the typed return value void in it's setup function.

sta1r commented 4 years ago

@oneserv-heuser Hi, thanks for reporting this. It's a known issue and listed here: https://devdocs.magento.com/guides/v2.4/release-notes/release-notes-2-4-0-commerce.html#dotdigital-1. It's due to be fixed with Magento's forthcoming 2.4.0-p1.

t-heuser commented 4 years ago

@sta1r The problem is that I cannot run integration tests (not even mine). I'm always getting this error, even if I execute a single test from one of my test classes which is definitly not using anything of this module.

sta1r commented 4 years ago

@oneserv-heuser I guess PHPUnit scans all available tests before running yours or something. You can download a hotfix from https://magento.com/tech-resources/download - click on Patches.

t-heuser commented 4 years ago

@sta1r The patch isn't working, it just skips every file as it cannot find it. The other problem is that there is no patch for "dotmailer-magento2-extension-chat" where the same problem exists. It only patches "dotmailer-magento2-extension".

Edit: After renaming the file to .diff instead of .patch it's working. But still the tests in "dotmailer-magento2-extension-chat" are not fixed in this patch.

sta1r commented 4 years ago

Thanks for flagging that oversight re Chat. I'll raise both issues with Magento.

In the meantime, there's just one test for Chat, can you manually add the : void return type to get your suite to run?

t-heuser commented 4 years ago

Yeah, I'll do that in the meantime. Thanks for your help and pointing out the patch!