8000 Merge pull request #24 from clue-labs/tests · reactphp/promise-timer@1c6d820 · GitHub
[go: up one dir, main page]

Skip to content

Commit 1c6d820

Browse files
authored
Merge pull request #24 from clue-labs/tests
Add PHPUnit to require-dev
2 parents 16e4511 + 1778b5a commit 1c6d820

File tree

6 files changed

+36
-10
lines changed

6 files changed

+36
-10
lines changed

.travis.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
11
language: php
2+
23
php:
34
- 5.3
5+
- 5.4
6+
- 5.5
47
- 5.6
8+
- 7.0
9+
- 7.1
510
- hhvm
11+
612
install:
7-
- composer install --prefer-source --no-interaction
13+
- composer install --no-interaction
14+
815
script:
9-
- phpunit --coverage-text
16+
- vendor/bin/phpunit --coverage-text

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ A trivial implementation of timeouts for `Promise`s, built on top of [React PHP]
1717
* [Reject cancellation](#reject-cancellation)
1818
* [TimeoutException](#timeoutexception)
1919
* [Install](#install)
20+
* [Tests](#tests)
2021
* [License](#license)
2122

2223
## Usage
@@ -325,6 +326,21 @@ $ composer require react/promise-timer:^1.1.1
325326

326327
More details and upgrade guides can be found in the [CHANGELOG](CHANGELOG.md).
327328

329+
## Tests
330+
331+
To run the test suite, you first need to clone this repo and then install all
332+
dependencies [through Composer](http://getcomposer.org):
333+
334+
```bash
335+
$ composer install
336+
```
337+
338+
To run the test suite, go to the project root and run:
339+
340+
```bash
341+
$ php vendor/bin/phpunit
342+
```
343+
328344
## License
329345

330346
MIT

composer.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,8 @@
2121
"php": ">=5.3",
2222
"react/event-loop": "^0.4 || ^0.3.5",
2323
"react/promise": "~2.1|~1.2"
24+
},
25+
"require-dev": {
26+
"phpunit/phpunit": "^5.0 || ^4.8"
2427
}
2528
}

tests/FunctionResolveTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,17 @@ public function testPromiseExpiredWillBeResolvedOnTimeout()
4040

4141
public function testWillStartLoopTimer()
4242
{
43-
$loop = $this->getMock('React\EventLoop\LoopInterface');
43+
$loop = $this->getMockBuilder('React\EventLoop\LoopInterface')->getMock();
4444
$loop->expects($this->once())->method('addTimer')->with($this->equalTo(0.01));
4545

4646
Timer\resolve(0.01, $loop);
4747
}
4848

4949
public function testCancellingPromiseWillCancelLoopTimer()
5050
{
51-
$loop = $this->getMock('React\EventLoop\LoopInterface');
51+
$loop = $this->getMockBuilder('React\EventLoop\LoopInterface')->getMock();
5252

53-
$timer = $this->getMock('React\EventLoop\Timer\TimerInterface');
53+
$timer = $this->getMockBuilder('React\EventLoop\Timer\TimerInterface')->getMock();
5454
$loop->expects($this->once())->method('addTimer')->will($this->returnValue($timer));
5555

5656
$promise = Timer\resolve(0.01, $loop);

tests/FunctionTimeoutTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public function testRejectedWillNotStartTimer()
6262

6363
public function testPendingWillRejectOnTimeout()
6464
{
65-
$promise = $this->getMock('React\Promise\PromiseInterface');
65+
$promise = $this->getMockBuilder('React\Promise\PromiseInterface')->getMock();
6666

6767
$promise = Timer\timeout($promise, 0.01, $this->loop);
6868

@@ -73,7 +73,7 @@ public function testPendingWillRejectOnTimeout()
7373

7474
public function testPendingCancellableWillBeCancelledOnTimeout()
7575
{
76-
$promise = $this->getMock('React\Promise\CancellablePromiseInterface');
76+
$promise = $this->getMockBuilder('React\Promise\CancellablePromiseInterface')->getMock();
7777
$promise->expects($this->once())->method('cancel');
7878

7979
Timer\timeout($promise, 0.01, $this->loop);
@@ -85,9 +85,9 @@ public function testCancelTimeoutWithoutCancellationhandlerWillNotCancelTimerAnd
8585
{
8686
$promise = new \React\Promise\Promise(function () { });
8787

88-
$loop = $this->getMock('React\EventLoop\LoopInterface');
88+
$loop = $this->getMockBuilder('React\EventLoop\LoopInterface')->getMock();
8989

90-
$timer = $this->getMock('React\EventLoop\Timer\TimerInterface');
90+
$timer = $this->getMockBuilder('React\EventLoop\Timer\TimerInterface')->getMock();
9191
$loop->expects($this->once())->method('addTimer')->will($this->returnValue($timer));
9292
$loop->expects($this->never())->method('cancelTimer');
9393

tests/TestCase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ protected function expectCallableNever()
4141
*/
4242
protected function createCallableMock()
4343
{
44-
return $this->getMock('React\Tests\Promise\Timer\CallableStub');
44+
return $this->getMockBuilder('React\Tests\Promise\Timer\CallableStub')->getMock();
4545
}
4646

4747
protected function expectPromiseRejected($promise)

0 commit comments

Comments
 (0)
0