fooman/magento2-phpunit-bridge

v0.10.1 2024-03-14 00:50 UTC

This package is auto-updated.

Last update: 2024-09-14 02:00:34 UTC


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.