amphp/phpunit-util
Small utility for simplifying async testing in PHPUnit with AMPHP’s fiber-based concurrency. Integrates seamlessly with AsyncTestCase to run tests as coroutines, ensuring smooth execution of I/O-bound operations like sockets, streams, and HTTP requests. Works with PHP 8.1+. Ideal for testing concurr...
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.
This package can be installed as a Composer dependency.
composer require --dev amphp/phpunit-util
The package requires PHP 8.1 or later.
<?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 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));
}
}
How can I help you explore Laravel packages today?