Skip to content

Commit 5170c27

Browse files
committed
Compatiblility with PHPUnit v5
1 parent 303d6a8 commit 5170c27

9 files changed

+28
-28
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,6 @@
2121
"react/promise-timer": "^1.1"
2222
},
2323
"require-dev": {
24-
"phpunit/phpunit": "^4.8"
24+
"phpunit/phpunit": "^5.0 || ^4.8"
2525
}
2626
}

tests/ConnectionManagerDelayTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public function testDelayTenth()
2626

2727
public function testCancellationOfPromiseBeforeDelayDoesNotStartConnection()
2828
{
29-
$unused = $this->getMock('React\SocketClient\ConnectorInterface');
29+
$unused = $this->getMockBuilder('React\SocketClient\ConnectorInterface')->getMock();
3030
$unused->expects($this->never())->method('create');
3131

3232
$cm = new ConnectionManagerDelay($unused, 1.0, $this->loop);

tests/ConnectionManagerRepeatTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public function testTwoTriesWillStartTwoConnectionAttempts()
2121
{
2222
$promise = Promise\reject(new \RuntimeException('nope'));
2323

24-
$connector = $this->getMock('React\SocketClient\ConnectorInterface');
24+
$connector = $this->getMockBuilder('React\SocketClient\ConnectorInterface')->getMock();
2525
$connector->expects($this->exactly(2))->method('create')->with('google.com', 80)->willReturn($promise);
2626

2727
$cm = new ConnectionManagerRepeat($connector, 2);
@@ -44,7 +44,7 @@ public function testCancellationWillNotStartAnyFurtherConnections()
4444
{
4545
$pending = new Promise\Promise(function () { }, $this->expectCallableOnce());
4646

47-
$connector = $this->getMock('React\SocketClient\ConnectorInterface');
47+
$connector = $this->getMockBuilder('React\SocketClient\ConnectorInterface')->getMock();
4848
$connector->expects($this->once())->method('create')->with('google.com', 80)->willReturn($pending);
4949

5050
$cm = new ConnectionManagerRepeat($connector, 3);
@@ -59,7 +59,7 @@ public function testCancellationWillNotStartAnyFurtherConnectionsIfPromiseReject
5959
throw new \RuntimeException('cancelled');
6060
});
6161

62-
$connector = $this->getMock('React\SocketClient\ConnectorInterface');
62+
$connector = $this->getMockBuilder('React\SocketClient\ConnectorInterface')->getMock();
6363
$connector->expects($this->once())->method('create')->with('google.com', 80)->willReturn($pending);
6464

6565
$cm = new ConnectionManagerRepeat($connector, 3);

tests/ConnectionManagerTimeoutTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public function testWillEndConnectionIfConnectionResolvesDespiteTimeout()
6868
});
6969
});
7070

71-
$connector = $this->getMock('React\SocketClient\ConnectorInterface');
71+
$connector = $this->getMockBuilder('React\SocketClient\ConnectorInterface')->getMock();
7272
$connector->expects($this->once())->method('create')->with('www.google.com', 80)->willReturn($promise);
7373

7474
$cm = new ConnectionManagerTimeout($connector, 0.001, $this->loop);
@@ -86,7 +86,7 @@ public function testCancellationOfPromiseWillCancelConnectionAttempt()
8686
throw new \RuntimeException();
8787
});
8888

89-
$connector = $this->getMock('React\SocketClient\ConnectorInterface');
89+
$connector = $this->getMockBuilder('React\SocketClient\ConnectorInterface')->getMock();
9090
$connector->expects($this->once())->method('create')->with('www.google.com', 80)->willReturn($promise);
9191

9292
$cm = new ConnectionManagerTimeout($connector, 5.0, $this->loop);

tests/Multiple/ConnectionManagerConcurrentTest.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public function testWillForwardToInnerConnector()
1717
{
1818
$pending = new Promise\Promise(function() { });
1919

20-
$only = $this->getMock('React\SocketClient\ConnectorInterface');
20+
$only = $this->getMockBuilder('React\SocketClient\ConnectorInterface')->getMock();
2121
$only->expects($this->once())->method('create')->with('google.com', 80)->willReturn($pending);
2222

2323
$connector = new ConnectionManagerConcurrent(array($only));
@@ -29,12 +29,12 @@ public function testWillForwardToInnerConnector()
2929

3030
public function testWillCancelOtherIfOneResolves()
3131
{
32-
$resolved = Promise\resolve($this->getMock('React\Stream\DuplexStreamInterface'));
33-
$first = $this->getMock('React\SocketClient\ConnectorInterface');
32+
$resolved = Promise\resolve($this->getMockBuilder('React\Stream\DuplexStreamInterface')->getMock());
33+
$first = $this->getMockBuilder('React\SocketClient\ConnectorInterface')->getMock();
3434
$first->expects($this->once())->method('create')->with('google.com', 80)->willReturn($resolved);
3535

3636
$pending = new Promise\Promise(function() { }, $this->expectCallableOnce());
37-
$second = $this->getMock('React\SocketClient\ConnectorInterface');
37+
$second = $this->getMockBuilder('React\SocketClient\ConnectorInterface')->getMock();
3838
$second->expects($this->once())->method('create')->with('google.com', 80)->willReturn($pending);
3939

4040
$connector = new ConnectionManagerConcurrent(array($first, $second));
@@ -46,13 +46,13 @@ public function testWillCancelOtherIfOneResolves()
4646

4747
public function testWillCloseOtherIfOneResolves()
4848
{
49-
$resolved = Promise\resolve($this->getMock('React\Stream\DuplexStreamInterface'));
50-
$first = $this->getMock('React\SocketClient\ConnectorInterface');
49+
$resolved = Promise\resolve($this->getMockBuilder('React\Stream\DuplexStreamInterface')->getMock());
50+
$first = $this->getMockBuilder('React\SocketClient\ConnectorInterface')->getMock();
5151
$first->expects($this->once())->method('create')->with('google.com', 80)->willReturn($resolved);
5252

53-
$slower = $this->getMock('React\Stream\DuplexStreamInterface');
53+
$slower = $this->getMockBuilder('React\Stream\DuplexStreamInterface')->getMock();
5454
$slower->expects($this->once())->method('close');
55-
$second = $this->getMock('React\SocketClient\ConnectorInterface');
55+
$second = $this->getMockBuilder('React\SocketClient\ConnectorInterface')->getMock();
5656
$second->expects($this->once())->method('create')->with('google.com', 80)->willReturn(Promise\resolve($slower));
5757

5858
$connector = new ConnectionManagerConcurrent(array($first, $second));

tests/Multiple/ConnectionManagerConsecutiveTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public function testWillTryAllIfEachRejects()
3131
{
3232
$rejected = Promise\reject(new \RuntimeException('nope'));
3333

34-
$connector = $this->getMock('React\SocketClient\ConnectorInterface');
34+
$connector = $this->getMockBuilder('React\SocketClient\ConnectorInterface')->getMock();
3535
$connector->expects($this->exactly(2))->method('create')->with('google.com', 80)->willReturn($rejected);
3636

3737
$cm = new ConnectionManagerConsecutive(array($connector, $connector));
@@ -45,7 +45,7 @@ public function testCancellationWillNotStartAnyFurtherConnections()
4545
{
4646
$pending = new Promise\Promise(function () { }, $this->expectCallableOnce());
4747

48-
$connector = $this->getMock('React\SocketClient\ConnectorInterface');
48+
$connector = $this->getMockBuilder('React\SocketClient\ConnectorInterface')->getMock();
4949
$connector->expects($this->once())->method('create')->with('google.com', 80)->willReturn($pending);
5050

5151
$cm = new ConnectionManagerConsecutive(array($connector, $connector));

tests/Multiple/ConnectionManagerRandomTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public function testWillTryAllIfEachRejects()
3131
{
3232
$rejected = Promise\reject(new \RuntimeException('nope'));
3333

34-
$connector = $this->getMock('React\SocketClient\ConnectorInterface');
34+
$connector = $this->getMockBuilder('React\SocketClient\ConnectorInterface')->getMock();
3535
$connector->expects($this->exactly(2))->method('create')->with('google.com', 80)->willReturn($rejected);
3636

3737
$cm = new ConnectionManagerRandom(array($connector, $connector));
@@ -45,7 +45,7 @@ public function testCancellationWillNotStartAnyFurtherConnections()
4545
{
4646
$pending = new Promise\Promise(function () { }, $this->expectCallableOnce());
4747

48-
$connector = $this->getMock('React\SocketClient\ConnectorInterface');
48+
$connector = $this->getMockBuilder('React\SocketClient\ConnectorInterface')->getMock();
4949
$connector->expects($this->once())->method('create')->with('google.com', 80)->willReturn($pending);
5050

5151
$cm = new ConnectionManagerRandom(array($connector, $connector));

tests/Multiple/ConnectionManagerSelectiveTest.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public function provideInvalidMatcher()
6969
*/
7070
public function testInvalidMatcherThrowsException($matcher)
7171
{
72-
$connector = $this->getMock('React\SocketClient\ConnectorInterface');
72+
$connector = $this->getMockBuilder('React\SocketClient\ConnectorInterface')->getMock();
7373

7474
new ConnectionManagerSelective(array(
7575
$matcher => $connector
@@ -78,9 +78,9 @@ public function testInvalidMatcherThrowsException($matcher)
7878

7979
public function testExactDomainMatchForwardsToConnector()
8080
{
81-
$promise = $this->getMock('React\Promise\PromiseInterface');
81+
$promise = $this->getMockBuilder('React\Promise\PromiseInterface')->getMock();
8282

83-
$connector = $this->getMock('React\SocketClient\ConnectorInterface');
83+
$connector = $this->getMockBuilder('React\SocketClient\ConnectorInterface')->getMock();
8484
$connector->expects($this->once())->method('create')->with('example.com', 80)->willReturn($promise);
8585

8686
$cm = new ConnectionManagerSelective(array(
@@ -94,9 +94,9 @@ public function testExactDomainMatchForwardsToConnector()
9494

9595
public function testExactIpv6MatchForwardsToConnector()
9696
{
97-
$promise = $this->getMock('React\Promise\PromiseInterface');
97+
$promise = $this->getMockBuilder('React\Promise\PromiseInterface')->getMock();
9898

99-
$connector = $this->getMock('React\SocketClient\ConnectorInterface');
99+
$connector = $this->getMockBuilder('React\SocketClient\ConnectorInterface')->getMock();
100100
$connector->expects($this->once())->method('create')->with('::1', 80)->willReturn($promise);
101101

102102
$cm = new ConnectionManagerSelective(array(
@@ -110,9 +110,9 @@ public function testExactIpv6MatchForwardsToConnector()
110110

111111
public function testExactIpv6WithPortMatchForwardsToConnector()
112112
{
113-
$promise = $this->getMock('React\Promise\PromiseInterface');
113+
$promise = $this->getMockBuilder('React\Promise\PromiseInterface')->getMock();
114114

115-
$connector = $this->getMock('React\SocketClient\ConnectorInterface');
115+
$connector = $this->getMockBuilder('React\SocketClient\ConnectorInterface')->getMock();
116116
$connector->expects($this->once())->method('create')->with('::1', 80)->willReturn($promise);
117117

118118
$cm = new ConnectionManagerSelective(array(
@@ -126,7 +126,7 @@ public function testExactIpv6WithPortMatchForwardsToConnector()
126126

127127
public function testNotMatchingDomainWillReject()
128128
{
129-
$connector = $this->getMock('React\SocketClient\ConnectorInterface');
129+
$connector = $this->getMockBuilder('React\SocketClient\ConnectorInterface')->getMock();
130130
$connector->expects($this->never())->method('create');
131131

132132
$cm = new ConnectionManagerSelective(array(

tests/bootstrap.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ protected function expectCallableOnceValue($type)
5353
*/
5454
protected function createCallableMock()
5555
{
56-
return $this->getMock('CallableStub');
56+
return $this->getMockBuilder('CallableStub')->getMock();
5757
}
5858

5959
protected function createConnectionManagerMock($ret)

0 commit comments

Comments
 (0)