Skip to content

Commit 23160f6

Browse files
authored
Merge pull request #31 from gabriel-caruso/phpunit
Support PHPUnit 6
2 parents 5b7962b + 696b510 commit 23160f6

5 files changed

Lines changed: 30 additions & 10 deletions

File tree

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@
2020
"react/promise-timer": "~1.0"
2121
},
2222
"require-dev": {
23-
"phpunit/phpunit": "^5.0 || ^4.8"
23+
"phpunit/phpunit": "^6.4 || ^5.7 || ^4.8.35"
2424
}
2525
}

tests/FunctionAwaitAllTest.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,36 +21,44 @@ public function testAwaitAllAllResolved()
2121
$this->assertEquals(array('first' => 1, 'second' => 2), Block\awaitAll($all, $this->loop));
2222
}
2323

24+
/**
25+
* @expectedException Exception
26+
* @expectedExceptionMessage test
27+
*/
2428
public function testAwaitAllRejected()
2529
{
2630
$all = array(
2731
$this->createPromiseResolved(1),
2832
$this->createPromiseRejected(new Exception('test'))
2933
);
3034

31-
$this->setExpectedException('Exception', 'test');
3235
Block\awaitAll($all, $this->loop);
3336
}
3437

38+
/**
39+
* @expectedException UnexpectedValueException
40+
*/
3541
public function testAwaitAllRejectedWithFalseWillWrapInUnexpectedValueException()
3642
{
3743
$all = array(
3844
$this->createPromiseResolved(1),
3945
Promise\reject(false)
4046
);
4147

42-
$this->setExpectedException('UnexpectedValueException');
4348
Block\awaitAll($all, $this->loop);
4449
}
4550

51+
/**
52+
* @expectedException Exception
53+
* @expectedExceptionMessage first
54+
*/
4655
public function testAwaitAllOnlyRejected()
4756
{
4857
$all = array(
4958
$this->createPromiseRejected(new Exception('first')),
5059
$this->createPromiseRejected(new Exception('second'))
5160
);
5261

53-
$this->setExpectedException('Exception', 'first');
5462
Block\awaitAll($all, $this->loop);
5563
}
5664

tests/FunctionAwaitAnyTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,16 @@ public function testAwaitAnyFirstResolvedConcurrently()
4747
$this->assertEquals(2, Block\awaitAny($all, $this->loop));
4848
}
4949

50+
/**
51+
* @expectedException UnderflowException
52+
*/
5053
public function testAwaitAnyAllRejected()
5154
{
5255
$all = array(
5356
$this->createPromiseRejected(1),
5457
$this->createPromiseRejected(2)
5558
);
5659

57-
$this->setExpectedException('UnderflowException');
5860
Block\awaitAny($all, $this->loop);
5961
}
6062

tests/FunctionAwaitTest.php

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,34 @@
66

77
class FunctionAwaitTest extends TestCase
88
{
9+
/**
10+
* @expectedException Exception
11+
* @expectedExceptionMessage test
12+
*/
913
public function testAwaitOneRejected()
1014
{
1115
$promise = $this->createPromiseRejected(new Exception('test'));
1216

13-
$this->setExpectedException('Exception', 'test');
1417
Block\await($promise, $this->loop);
1518
}
1619

20+
/**
21+
* @expectedException UnexpectedValueException
22+
*/
1723
public function testAwaitOneRejectedWithFalseWillWrapInUnexpectedValueException()
1824
{
1925
$promise = Promise\reject(false);
2026

21-
$this->setExpectedException('UnexpectedValueException');
2227
Block\await($promise, $this->loop);
2328
}
2429

30+
/**
31+
* @expectedException UnexpectedValueException
32+
*/
2533
public function testAwaitOneRejectedWithNullWillWrapInUnexpectedValueException()
2634
{
2735
$promise = Promise\reject(null);
2836

29-
$this->setExpectedException('UnexpectedValueException');
3037
Block\await($promise, $this->loop);
3138
}
3239

@@ -61,11 +68,13 @@ public function testAwaitOneInterrupted()
6168
$this->assertEquals(2, Block\await($promise, $this->loop));
6269
}
6370

71+
/**
72+
* @expectedException React\Promise\Timer\TimeoutException
73+
*/
6474
public function testAwaitOncePendingWillThrowOnTimeout()
6575
{
6676
$promise = new Promise\Promise(function () { });
6777

68-
$this->setExpectedException('React\Promise\Timer\TimeoutException');
6978
Block\await($promise, $this->loop, 0.001);
7079
}
7180

tests/bootstrap.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
<?php
22

3+
use PHPUnit\Framework\TestCase as BaseTestCase;
34
use React\Promise\Deferred;
45

56
require_once __DIR__ . '/../vendor/autoload.php';
67

78
error_reporting(-1);
89

9-
class TestCase extends PHPUnit_Framework_TestCase
10+
class TestCase extends BaseTestCase
1011
{
1112
protected $loop;
1213

0 commit comments

Comments
 (0)