You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Adobe Commerce(Magento 2)无法执行PHPUnit测试的问题求助

问题

本地Docker环境运行Adobe Commerce(Magento 2),环境版本如下:

  • Magento Enterprise 2.4.3-p3
  • phpunit/phpunit 9.5.28
  • doctrine/annotations 2.0.0
  • allure-framework/allure-php-api 1.4.0

在PhpStorm(版本#PS-223.8214.64)中运行PHPUnit测试时报错:

Call to undefined method Doctrine\Common\Annotations\AnnotationRegistry::registerUniqueLoader()

排查发现该调用位于Yandex\Allure\Adapter\Annotation\AnnotationProvider::registerAnnotationNamespaces()中,代码如下:

public static function registerAnnotationNamespaces()
{
    AnnotationRegistry::registerUniqueLoader('class_exists');
}

当前Doctrine\Common\Annotations\AnnotationRegistry仅包含reset()和loadAnnotationClass()方法,不存在registerUniqueLoader()。

解决方案

问题根源是allure-framework/allure-php-api 1.4.0依赖的Doctrine Annotations版本过低,而当前使用的doctrine/annotations 2.0.0已移除registerUniqueLoader()方法(该方法仅存在于Doctrine Annotations 1.x版本,2.x版本已废弃移除)。

可通过以下两种版本调整方案解决:

  • 降低doctrine/annotations版本至1.x兼容版本,推荐1.14.3(此版本与Magento 2.4.3-p3兼容,同时适配allure-php-api 1.4.0的调用逻辑)
  • 升级allure-framework/allure-php-api至支持Doctrine Annotations 2.x的版本,推荐2.4.0及以上(该版本已适配Doctrine Annotations 2.x的API变更)

调整版本后执行composer update更新依赖,确保依赖冲突被解决。

内容的提问来源于stack exchange,提问作者Sean

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.03 20:01:54