Skip to content

Commit 840959c

Browse files
committed
Update README
1 parent 8351678 commit 840959c

File tree

2 files changed

+31
-9
lines changed

2 files changed

+31
-9
lines changed

CONTRIBUTING.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,4 @@ Truths which we believe to be self-evident:
2323

2424
## Code style
2525

26-
The amphp project adheres to the PSR-2 style guide with the exception that
27-
opening braces for classes and methods must appear on the same line as
28-
the declaration:
29-
30-
https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md
26+
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).

README.md

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,53 @@
22

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

5-
`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.
5+
`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.
66

77
**Required PHP Version**
88

99
- PHP 7.0+
1010

11-
**Installation**
11+
## Installation
1212

1313
```bash
1414
composer require --dev amphp/phpunit-util
1515
```
1616

17-
**Usage**
17+
## Usage
1818

19-
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.
19+
```php
20+
<?php
21+
22+
namespace Foo;
23+
24+
use Amp\ByteStream;
25+
use Amp\PHPUnit\AsyncTestCase;
26+
use Amp\Socket;
27+
28+
class BarTest extends AsyncTestCase
29+
{
30+
// Each test case is executed as a coroutine and checked to run to completion
31+
public function test()
32+
{
33+
$socket = yield Socket\connect('tcp://localhost:12345');
34+
yield $socket->write('foobar');
35+
36+
$this->assertSame('foobar', yield ByteStream\buffer($socket));
37+
}
38+
}
39+
```
40+
41+
#### Deprecated Functionality
42+
43+
This package also provides a PHPUnit `TestListener` to reset the global event loop after each test, but this is deprecated.
2044

2145
```xml
2246
<phpunit>
2347
<!-- ... -->
2448

49+
<!-- DEPRECATED, use AsyncTestCase instead -->
2550
<listeners>
51+
<!-- DEPRECATED, use AsyncTestCase instead -->
2652
<listener class="Amp\PHPUnit\LoopReset" />
2753
</listeners>
2854

0 commit comments

Comments
 (0)