Skip to content

Commit

Permalink
Update README
Browse files Browse the repository at this point in the history
  • Loading branch information
kelunik committed Oct 4, 2019
1 parent 8351678 commit 840959c
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 9 deletions.
6 changes: 1 addition & 5 deletions CONTRIBUTING.md
Expand Up @@ -23,8 +23,4 @@ Truths which we believe to be self-evident:

## Code style

The amphp project adheres to the PSR-2 style guide with the exception that
opening braces for classes and methods must appear on the same line as
the declaration:

https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md
The amphp project adheres to the [PSR-2 style guide](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md).
34 changes: 30 additions & 4 deletions README.md
Expand Up @@ -2,27 +2,53 @@

![License](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)

`amphp/phpunit-util` is a small helper package to ease testing with PHPUnit in combination with the [`amp`](https://github.com/amphp/amp) concurrency framework.
`amphp/phpunit-util` is a small helper package to ease testing with PHPUnit in combination with the [`Amp`](https://github.com/amphp/amp) concurrency framework.

**Required PHP Version**

- PHP 7.0+

**Installation**
## Installation

```bash
composer require --dev amphp/phpunit-util
```

**Usage**
## Usage

Currently, this package only provides a PHPUnit `TestListener` to reset the global event loop after each test. By adding the listener to your PHPUnit configuration, each test will be executed with a completely new event loop instance.
```php
<?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()
{
$socket = yield Socket\connect('tcp://localhost:12345');
yield $socket->write('foobar');

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

#### Deprecated Functionality

This package also provides a PHPUnit `TestListener` to reset the global event loop after each test, but this is deprecated.

```xml
<phpunit>
<!-- ... -->

<!-- DEPRECATED, use AsyncTestCase instead -->
<listeners>
<!-- DEPRECATED, use AsyncTestCase instead -->
<listener class="Amp\PHPUnit\LoopReset" />
</listeners>

Expand Down

0 comments on commit 840959c

Please sign in to comment.