Search by

amphp / phpunit-util

Trowskikelunikbwoebi

Helper package to ease testing with PHPUnit.

Package info

github.com/amphp/phpunit-util

Homepage

pkg:composer/amphp/phpunit-util

Fund package maintenance!

amphp

Statistics

Installs: 1 015 444

Dependents: 135

Suggesters: 0

Stars: 22

Open Issues: 0

v4.0.0-beta.1 2026-10-31 01:07 UTC

README

AMPHP is a collection of event-driven libraries for PHP designed with fibers and concurrency in mind. amphp/phpunit-util is a small helper package to ease testing with PHPUnit.

License

Installation

This package can be installed as a Composer dependency.

composer require --dev amphp/phpunit-util

The package requires PHP 8.1 or later and PHPUnit 9 or 12+ (PHPUnit 10 and 11 are not supported).

PHP and PHPUnit versions supported

amphp/phpunit-util Version PHP PHPUnit
3 8.1+ 9
4 8.3+ 12+

Usage

<?php

namespace Foo;

use Amp\ByteStream;
use Amp\PHPUnit\AsyncTestCase;
use Amp\Socket;

class BarTest extends AsyncTestCase
{
    // Each test case is executed as a coroutine (within a separate fiber) and checked to run to completion
    public function test(): void
    {
        $socket = Socket\connect('tcp://localhost:12345');
        $socket->write('foobar');

        $this->assertSame('foobar', ByteStream\buffer($socket));
    }
}