Skip to content

Commit fdc05f0

Browse files
committed
Merge branch 'ttrig/trait'
2 parents aa575f0 + 6920af6 commit fdc05f0

File tree

3 files changed

+23
-3
lines changed

3 files changed

+23
-3
lines changed

README.md

+21-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ composer require seregazhuk/react-promise-testing --dev
3838
```
3939

4040
## Quick Start
41-
Use the trait `seregazhuk\React\PromiseTesting\AssertPromise` or extend your
41+
Use the trait `seregazhuk\React\PromiseTesting\AssertsPromise` or extend your
4242
test classes from `seregazhuk\React\PromiseTesting\TestCase` class,
4343
which itself extends PHPUnit `TestCase`.
4444

@@ -53,7 +53,27 @@ final class MyTest extends TestCase
5353
$this->assertPromiseFulfillsWithInstanceOf($promise, ResponseInterface::class);
5454
}
5555
}
56+
```
57+
58+
Using the trait:
59+
60+
```php
61+
62+
use PHPUnit\Framework\TestCase;
63+
use seregazhuk\React\PromiseTesting\AssertsPromise;
64+
65+
final class MyTest extends TestCase
66+
{
67+
use AssertsPromise;
5668

69+
/** @test */
70+
public function promise_fulfills_with_a_response_object()
71+
{
72+
$browser = new Clue\React\Buzz\Browser($this->eventLoop());
73+
$promise = $browser->get('http://www.google.com/');
74+
$this->assertPromiseFulfillsWithInstanceOf($promise, ResponseInterface::class);
75+
}
76+
}
5777
```
5878

5979
Test above checks that a specified promise fulfills with an instance of `ResponseInterface`.

src/AssertPromise.php renamed to src/AssertsPromise.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
use React\Promise\PromiseInterface;
1111
use React\Promise\Timer\TimeoutException;
1212

13-
trait AssertPromise
13+
trait AssertsPromise
1414
{
1515
protected $defaultWaitTimeout = 2;
1616

src/TestCase.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
abstract class TestCase extends PHPUnitTestCase
88
{
9-
use AssertPromise;
9+
use AssertsPromise;
1010

1111
protected function setUp(): void
1212
{

0 commit comments

Comments
 (0)