harmonyio/phpunit-extension

PHPUnit 的异步助手

v1.0.0-rc1 2018-12-24 18:07 UTC

README

Latest Stable Version Build Status Build status Coverage Status License

异步 PHPUnit 助手

要求

  • PHP 7.3

此外,对于非阻塞上下文,应安装以下事件库之一

安装

composer require harmonyio/phpunit-extension

使用

PHPUnit 的断言可以在承诺上透明地使用。承诺将自动解析为其值,最终值将进行断言。

<?php declare(strict_types=1);

namespace Foo\Test\Unit;

use Amp\Success;
use HarmonyIO\PHPUnitExtension\TestCase;

class BarTest extends TestCase
{
    public function testPromiseValueAssertsCorrectly(): void
    {
        // the promise will be automatically resolved here
        // and the eventual value will be asserted instead of the promise itself
        $this->assertTrue(new Success(true));
    }
}