webshopapps / module-matrixrate

WebShopApps MatrixRates for Magento2
Open Software License 3.0
120 stars 64 forks source link

Tests Are Not Magento 2.3 Compatible #66

Closed sprankhub closed 3 years ago

sprankhub commented 5 years ago

PHP Fatal error: Class 'PHPUnit_Framework_TestCase' not found in /var/www/shop/vendor/webshopapps/module-matrixrate/Test/Unit/Block/Adminhtml/Carrier/Matrixrate/GridTest.php on line 38

ibraheemnabeelfauzi commented 5 years ago

Hi @sprankhub ,

Please follow instructions on "TestCase not found" the following doc to resolve this: https://docs.shipperhq.com/troubleshooting-magento-2-installations/#TestCase_not_found_Compiler_Error

Thank you.

sprankhub commented 5 years ago

The extension is installed via composer and the error occurs when running the tests. Magento 2.3 has a newer version of PHPUnit installed, which now uses namespaces. Hence, the tests need to be adjusted to be compatible. Would you accept a PR fixing this? Mind that the tests would then not work any more for older versions of Magento though.

ibraheemnabeelfauzi commented 5 years ago

Hi, @sprankhub from your explanation it sounds like the extension was installed via zip and then composer which what resulted in that issue. You shoudln't have any test files installed. We recommend to re-install the extension using a composer.

sprankhub commented 5 years ago

Complete steps to reproduce:

mkdir wsatest
composer init
composer require webshopapps/module-matrixrate
phpunit vendor/webshopapps/module-matrixrate/Test/

This results in the above mentioned error. The issue is, as said, that newer versions of PHPUnit (like 6.5.14 in my example) switches to namespaces and the class PHPUnit_Framework_TestCase does not exist any more. See https://phpunit.de/announcements/phpunit-6.html.

matiaso commented 5 years ago

Any updates on this ?

wsajason commented 5 years ago

Hi, Our developers are aware and will update the tests for a future version. The unit tests are not required for the module to function, to clarify.

matiaso commented 5 years ago

As a temporary fix you can create a PHP file containing: class_alias('\PHPUnit\Framework\TestCase', '\PHPUnit_Framework_TestCase');

And add it to composer.json: { "autoload": { "files": ["src/MyLibrary/functions.php"] } }

Copyright outlaw GPlanchat for the trick

wsajosh commented 3 years ago

Thanks for raising this and your patience. This will be resolved in the next release which should be available in the next week