Fatal error: Class 'Codeception\Platform\Extension' not found. Issue occurred after magento 2.3.0 upgrade to 2.3.1
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
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