Preconditions (*)
- 1.Magento 2.3.1 upgraded from Magento 2.3.0
- Php 7.2.15
- OS : Ubuntu 18.04 Bionic
- Phpstorm 2019年1月1日
- Evnironemnt : Magento development
Steps to reproduce (*)
- Issue appears after upgrading magento from 2.3.0 to 2.3.1 and run below commands.
- bin/magento dev:tests:run unit
- vendor/phpunit/phpunit/phpunit -c dev/tests/unit/phpunit.xml.dist.
- Above commands will work if version 2.3.0 is installed directly and also for 2.3.1 if installed directly.
These commands should run unit test on entire magento project not just on one mdoule.
Error (*)
Fatal error: Class 'Codeception\Platform\Extension' not found in/var/www/html/magento23demo/vendor/allure-framework/allure-codeception/src/Yandex/Allure/Adapter/AllureAdapter.phpon line 49
Please note I can't find Platform\Extension codeception library in vendor folder.
5 Answers 5
BackGround: Problem occurred after using the cli upgrade method method mentioned here. First enable the maintenance mode so that website becomes inaccessible.
bin/magento maintenance:enable
For upgrade following command was used
composer require magento/product-community-edition=2.3.1 --no-update
This command will only update the composer.json file "require" key. Because of --no-update flag it will not install the new magento version along with new packages. This can be verified from composer.lock file which contains the list of all currently installed packages. Search for magento/product-community-edition in composer.lock file it will still how the version to be 2.3.0.
Now if you run below unit test command it will work fine as magento is still 2.3.0 version.
bin/magento dev:tests:run unit
Moving on above error(Class 'Codecception\Platform\Extension' not found) is related to allure-framework package in vendor directory.
- allure-framework package gets installed as dependency of magento/magento2-functional-testing-framework package (Abbr: mftf).
- It has two folders Alulure-Codeception and Allure-php-api.
Observe the Adapter/AllureAdapter.php file. This will change after update.
With magento version 2.3.0, mftf version 2.3.9 gets installed as can be noted in "require-dev" key of composer.json file.
Now run
composer update
This will update your magento installation and you will see numerous packages gets updates. Few but not all updates are shown in snap below. Total updated 173 and 11 new installs. Also your composer.lock file will be updated as well.
Again run and you will see that the error mentioned in this question will appear.
bin/magento dev:tests:run unit
Solution:
Remove your current package magento/magento2-functional-testing-framework package which is version 2.3.9 as follows
composer remove magento/magento2-functional-testing-framework
You will notice this command will remove numerous packages along with following packages shown in pictures below
enter image description here enter image description here
NOTE: If you dont run composer update in previous steps and try to remove mftf following error will happen
Your requirements could not be resolved to an installable set of packages.
Problem 1
- The requested package magento/product-community-edition (locked at 2.3.0, required as 2.3.1) is satisfiable by magento/product-community-edition[2.3.0] but these conflict with your requirements or minimum-stability.
Problem 2
- Can only install one of: amzn/amazon-pay-and-login-magento-2-module[3.1.4, 3.0.0].
- Can only install one of: amzn/amazon-pay-and-login-magento-2-module[3.1.4, 3.0.0].
- Can only install one of: amzn/amazon-pay-and-login-magento-2-module[3.0.0, 3.1.4].
- magento/product-community-edition 2.3.1 requires amzn/amazon-pay-and-login-magento-2-module 3.1.4 -> satisfiable by amzn/amazon-pay-and-login-magento-2-module[3.1.4].
- Installation request for magento/product-community-edition 2.3.1 -> satisfiable by magento/product-community-edition[2.3.1].
- Installation request for amzn/amazon-pay-and-login-magento-2-module (locked at 3.0.0) -> satisfiable by amzn/amazon-pay-and-login-magento-2-module[3.0.0].
Now since allure-framework and mftf 2.3.9 has been removed we can install latest mftf version suitable for magento version 2.3.1 as follows.
composer require magento/magento2-functional-testing-framework:~2.3.13 --dev
Notice it will install latest version of allure-framework and mftf along with many other packages. Snap below
Now notice that allure-framework with allure-codeception and allure-php-api folders.
- Observe that Adapter/AllureAdapter.php has changed to Codeception/AllureCodeception.php after new mftf version 2.3.13 installation.
Now again run
bin/magento dev:tests:run unit
You will see that a new error(below) will appear which means previous error (Class 'Codeception\Platform\Extension' not found) is resolved.
Class "Yandex\Allure\Adapter\AllureAdapter" does not exist
It can be resolved as follows
A vanilla installation of magento 2.3.1 was done and it was observed that a new folder allure-phpunit is added into allure-framework as given in picture below
Hence install allure-phpunit into your upgraded magento 2.3.1 as follows
composer require allure-framework/allure-phpunit --dev
This will give following error
Your requirements could not be resolved to an installable set of packages.
Problem 1
Installation request for allure-framework/allure-phpunit ^1.3 -> satisfiable by allure-framework/allure-phpunit[1.3.0].
allure-framework/allure-phpunit 1.3.0 requires phpunit/phpunit>=7.0.0 -> satisfiable by phpunit/phpunit[7.0.0, 7.0.1, 7.0.2, 7.0.3, 7.1.0, 7.1.1, 7.1.2, 7.1.3, 7.1.4, 7.1.5, 7.2.0, 7.2.1, 7.2.2, 7.2.3, 7.2.4, 7.2.5, 7.2.6, 7.2.7, 7.3.0, 7.3.1, 7.3.2, 7.3.3, 7.3.4, 7.3.5, 7.4.0, 7.4.1, 7.4.2, 7.4.3, 7.4.4, 7.4.5, 7.5.0, 7.5.1, 7.5.2, 7.5.3, 7.5.4, 7.5.5, 7.5.6, 7.5.7, 7.5.8, 7.5.9, 7.5.x-dev, 8.0.0, 8.0.1, 8.0.2, 8.0.3, 8.0.4, 8.0.5, 8.0.6, 8.1.0, 8.1.1, 8.1.2, 8.1.3, 8.1.x-dev, dev-master, 8.2.x-dev] but these conflict with your requirements or minimum-stability.
phpunit/phpunit version is 6.5.0 in composer.json both in upgraded magento 2.3.1 and in vanilla installed 2.3.1. Hence allure-framework/allure-phpunit version 1.3 which is latest version will not be installed as it required phpunit/phpunit>=7.0.0.
So install
composer require allure-framework/allure-phpunit:~1.2.0 --dev
It will install latest 1.2 version of phpunit/phpunit compatible to upgraded magento 2.3.1 installation.
Now run again
bin/magento dev:tests:run unit
SUCCESS !! phpunit test will start running for the entire project with following command line output. A snippet is given below enter image description here
-
For Magento 2.3.3 I had to specifically use version 1.2.3 of allure-phpunit as 1.2.4 uses the PHPUnit 7+ version of setUp() (setUp(): void) while the Magento tests still appear to use PHPUnit 6 way of doing things.wr125– wr1252019年10月23日 11:37:41 +00:00Commented Oct 23, 2019 at 11:37
composer require magento/magento2-functional-testing-framework:"2.3.13" allure-framework/allure-codeception:"1.3.0" allure-framework/allure-phpunit:"1.2.3" --dev
This is the smallest composer update to make unit tests work for M2.3.1 community edition. If you (for some reason like me) want composer.lock to have minimal changes and minimal affection on other packages.
-
Thanks, this worked for me.Raivis Dejus– Raivis Dejus2020年08月28日 10:09:59 +00:00Commented Aug 28, 2020 at 10:09
looks like there is a missing dependency.
Running composer install should resolve the issue.
It's working for me.
-
Hi @Saphal Jha. It didn't work for me. Which magento and php version are you using and which command did use for the test.PhantomS– PhantomS2019年04月29日 00:13:43 +00:00Commented Apr 29, 2019 at 0:13
-
I am using from git directly and I am running d:t:rSaphal Jha– Saphal Jha2019年04月29日 05:34:39 +00:00Commented Apr 29, 2019 at 5:34
-
That explains it I faced issue after an upgradePhantomS– PhantomS2019年04月29日 06:00:04 +00:00Commented Apr 29, 2019 at 6:00
-
Also i have updated my questionPhantomS– PhantomS2019年04月29日 06:35:29 +00:00Commented Apr 29, 2019 at 6:35
If anyone come across a similar error after upgrade, it's most likely due to AlluerAdapter class does not exist anymore and your phpunit.xml is listening to the wrong class. However, verify the alluer-framework package exists. Then you could just simply update your phpunit.xml listeners to Yandex\Allure\PhpUnit\AllurePhpUnit.
For Magento 2.3.7-p3
composer require magento/magento2-functional-testing-framework:~2.6 allure-framework/allure-codeception:"~1.4" allure-framework/allure-phpunit:"~1.2" --dev
Explore related questions
See similar questions with these tags.
vendor/phpunit/phpunit/phpunit -c dev/tests/unit/phpunit.xml.dist