fooman / magento2-phpunit-bridge
v0.10.1
2024-03-14 00:50 UTC
Requires
- php: ~7.0.0 || ~7.1.0 || ~7.2.0 || ~7.4.0 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0
- magento/framework: ^101.0 || ^102.0 || ^103.0
- phpunit/phpunit: ^6.2 || ^9.1
README
目标是能够编写针对phpunit 9的测试,然后能够运行这些针对Magento 2.4、Magento 2.3和2.2(更准确地说,它们相关的magento/framework版本和phpunit版本)的测试。早期的版本在phpunit 4和6之间建立了桥梁。
使用以下方法安装
composer require fooman/magento2-phpunit-bridge --dev
然后让您的测试扩展 \Fooman\PhpunitBridge\BaseUnitTestCase
<?php
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
class MyClassToTest extends \Fooman\PhpunitBridge\BaseUnitTestCase
{
public function setUp(): void
{
$objectManager = new ObjectManager($this);
}
public function testFunctionality()
{
$mock = $this->createMock(\Vendor\Module\MyClass::class);
}
}
this will now work on Magento 2.3 as well without failures related to not using \PHPUnit_Framework_TestCase.