Skip to content

Helper package to ease testing with PHPUnit.

License

Notifications You must be signed in to change notification settings

amphp/phpunit-util

Folders and files

NameName
Last commit message
Last commit date

Latest commit

d83f86f · Feb 27, 2023

History

94 Commits
Nov 7, 2022
Feb 27, 2023
Dec 18, 2022
Mar 11, 2017
Mar 11, 2017
Feb 14, 2020
Nov 7, 2022
Oct 4, 2019
Nov 7, 2022
Sep 19, 2022
Dec 18, 2022
Oct 1, 2020

Repository files navigation

amphp/phpunit-util

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.

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 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));
    }
}