Fatal error: Class 'Codeception\Platform\Extension' not found. Issue occurred after magento 2.3.0 upgrade to 2.3.1

magento.stackexchange https://magento.stackexchange.com/questions/270555

سؤال

Preconditions (*)

  1. 1.Magento 2.3.1 upgraded from Magento 2.3.0
  2. Php 7.2.15
  3. OS : Ubuntu 18.04 Bionic
  4. Phpstorm 2019.1.1
  5. Evnironemnt : Magento development

Steps to reproduce (*)

  1. Issue appears after upgrading magento from 2.3.0 to 2.3.1 and run below commands.
  2. bin/magento dev:tests:run unit
  3. vendor/phpunit/phpunit/phpunit -c dev/tests/unit/phpunit.xml.dist.
  4. 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.php on line 49

Please note I can't find Platform\Extension codeception library in vendor folder.

هل كانت مفيدة؟

المحلول

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.

enter image description here

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.

enter image description here

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

enter image description here

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

enter image description here

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

نصائح أخرى

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.

looks like there is a missing dependency.

Running composer install should resolve the issue.

It's working for me.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى magento.stackexchange
scroll top