Phpunit 单元测试中的Magento 2依赖项注入首选项

Phpunit 单元测试中的Magento 2依赖项注入首选项,phpunit,magento2,Phpunit,Magento2,我想知道为什么由Magento提供的Magento\TestFramework\Helper\Bootstrap没有读取di.xml中指定的依赖项注入首选项。 我通过为其提供直接配置设置找到了一个解决方法: Bootstrap::getObjectManager()->configure( [ 'preferences' => [ 'Example\CoreInterface' => 'Example\Core'

我想知道为什么由Magento提供的
Magento\TestFramework\Helper\Bootstrap
没有读取di.xml中指定的依赖项注入首选项。 我通过为其提供直接配置设置找到了一个解决方法:

Bootstrap::getObjectManager()->configure(
   [
     'preferences' =>
         [
           'Example\CoreInterface' => 'Example\Core'
         ]
   ]
);
不幸的是,它不容易重写di.xml,因此有一天会有人重写di.xml首选项并破坏测试。最好在测试引导时加载di.xml。是否有更好的方法加载接口首选项重写