Skip to content

Commit 5deb19b

Browse files
authored
Merge pull request #122 from andig/test
Forward compatibility with PHPUnit v5
2 parents e621ea2 + 909d4bc commit 5deb19b

9 files changed

Lines changed: 25 additions & 25 deletions

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
},
1515
"require-dev": {
1616
"clue/block-react": "^1.1",
17-
"phpunit/phpunit": "~4.8"
17+
"phpunit/phpunit": "^5.0 || ^4.8"
1818
},
1919
"autoload": {
2020
"psr-4": {

tests/DnsConnectorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class DnsConnectorTest extends TestCase
1313

1414
public function setUp()
1515
{
16-
$this->tcp = $this->getMock('React\Socket\ConnectorInterface');
16+
$this->tcp = $this->getMockBuilder('React\Socket\ConnectorInterface')->getMock();
1717
$this->resolver = $this->getMockBuilder('React\Dns\Resolver\Resolver')->disableOriginalConstructor()->getMock();
1818

1919
$this->connector = new DnsConnector($this->tcp, $this->resolver);

tests/LimitingServerTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public function testCloseWillBePassedThroughToTcpServer()
7575

7676
public function testSocketErrorWillBeForwarded()
7777
{
78-
$loop = $this->getMock('React\EventLoop\LoopInterface');
78+
$loop = $this->getMockBuilder('React\EventLoop\LoopInterface')->getMock();
7979

8080
$tcp = new TcpServer(0, $loop);
8181

@@ -90,7 +90,7 @@ public function testSocketConnectionWillBeForwarded()
9090
{
9191
$connection = $this->getMockBuilder('React\Socket\ConnectionInterface')->getMock();
9292

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

9595
$tcp = new TcpServer(0, $loop);
9696

@@ -110,7 +110,7 @@ public function testSocketConnectionWillBeClosedOnceLimitIsReached()
110110
$second = $this->getMockBuilder('React\Socket\ConnectionInterface')->getMock();
111111
$second->expects($this->once())->method('close');
112112

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

115115
$tcp = new TcpServer(0, $loop);
116116

@@ -124,7 +124,7 @@ public function testSocketConnectionWillBeClosedOnceLimitIsReached()
124124

125125
public function testPausingServerWillBePausedOnceLimitIsReached()
126126
{
127-
$loop = $this->getMock('React\EventLoop\LoopInterface');
127+
$loop = $this->getMockBuilder('React\EventLoop\LoopInterface')->getMock();
128128
$loop->expects($this->once())->method('addReadStream');
129129
$loop->expects($this->once())->method('removeReadStream');
130130

tests/SecureConnectorTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ public function setUp()
1717
$this->markTestSkipped('Not supported on your platform (outdated HHVM?)');
1818
}
1919

20-
$this->loop = $this->getMock('React\EventLoop\LoopInterface');
21-
$this->tcp = $this->getMock('React\Socket\ConnectorInterface');
20+
$this->loop = $this->getMockBuilder('React\EventLoop\LoopInterface')->getMock();
21+
$this->tcp = $this->getMockBuilder('React\Socket\ConnectorInterface')->getMock();
2222
$this->connector = new SecureConnector($this->tcp, $this->loop);
2323
}
2424

tests/SecureServerTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public function testGetAddressWillBePassedThroughToTcpServer()
1919
$tcp = $this->getMockBuilder('React\Socket\ServerInterface')->getMock();
2020
$tcp->expects($this->once())->method('getAddress')->willReturn('127.0.0.1:1234');
2121

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

2424
$server = new SecureServer($tcp, $loop, array());
2525

@@ -31,7 +31,7 @@ public function testPauseWillBePassedThroughToTcpServer()
3131
$tcp = $this->getMockBuilder('React\Socket\ServerInterface')->getMock();
3232
$tcp->expects($this->once())->method('pause');
3333

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

3636
$server = new SecureServer($tcp, $loop, array());
3737

@@ -43,7 +43,7 @@ public function testResumeWillBePassedThroughToTcpServer()
4343
$tcp = $this->getMockBuilder('React\Socket\ServerInterface')->getMock();
4444
$tcp->expects($this->once())->method('resume');
4545

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

4848
$server = new SecureServer($tcp, $loop, array());
4949

@@ -55,7 +55,7 @@ public function testCloseWillBePassedThroughToTcpServer()
5555
$tcp = $this->getMockBuilder('React\Socket\ServerInterface')->getMock();
5656
$tcp->expects($this->once())->method('close');
5757

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

6060
$server = new SecureServer($tcp, $loop, array());
6161

@@ -64,7 +64,7 @@ public function testCloseWillBePassedThroughToTcpServer()
6464

6565
public function testConnectionWillBeEndedWithErrorIfItIsNotAStream()
6666
{
67-
$loop = $this->getMock('React\EventLoop\LoopInterface');
67+
$loop = $this->getMockBuilder('React\EventLoop\LoopInterface')->getMock();
6868

6969
$tcp = new TcpServer(0, $loop);
7070

@@ -80,7 +80,7 @@ public function testConnectionWillBeEndedWithErrorIfItIsNotAStream()
8080

8181
public function testSocketErrorWillBeForwarded()
8282
{
83-
$loop = $this->getMock('React\EventLoop\LoopInterface');
83+
$loop = $this->getMockBuilder('React\EventLoop\LoopInterface')->getMock();
8484

8585
$tcp = new TcpServer(0, $loop);
8686

tests/TcpConnectorTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ public function connectionToIp6TcpServerShouldSucceed()
141141
/** @test */
142142
public function connectionToHostnameShouldFailImmediately()
143143
{
144-
$loop = $this->getMock('React\EventLoop\LoopInterface');
144+
$loop = $this->getMockBuilder('React\EventLoop\LoopInterface')->getMock();
145145

146146
$connector = new TcpConnector($loop);
147147
$connector->connect('www.google.com:80')->then(
@@ -153,7 +153,7 @@ public function connectionToHostnameShouldFailImmediately()
153153
/** @test */
154154
public function connectionToInvalidPortShouldFailImmediately()
155155
{
156-
$loop = $this->getMock('React\EventLoop\LoopInterface');
156+
$loop = $this->getMockBuilder('React\EventLoop\LoopInterface')->getMock();
157157

158158
$connector = new TcpConnector($loop);
159159
$connector->connect('255.255.255.255:12345678')->then(
@@ -165,7 +165,7 @@ public function connectionToInvalidPortShouldFailImmediately()
165165
/** @test */
166166
public function connectionToInvalidSchemeShouldFailImmediately()
167167
{
168-
$loop = $this->getMock('React\EventLoop\LoopInterface');
168+
$loop = $this->getMockBuilder('React\EventLoop\LoopInterface')->getMock();
169169

170170
$connector = new TcpConnector($loop);
171171
$connector->connect('tls://google.com:443')->then(
@@ -179,7 +179,7 @@ public function connectionWithInvalidContextShouldFailImmediately()
179179
{
180180
$this->markTestIncomplete();
181181

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

184184
$connector = new TcpConnector($loop, array('bindto' => 'invalid.invalid:123456'));
185185
$connector->connect('127.0.0.1:80')->then(

tests/TestCase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ protected function expectCallableNever()
5252

5353
protected function createCallableMock()
5454
{
55-
return $this->getMock('React\Tests\Socket\Stub\CallableStub');
55+
return $this->getMockBuilder('React\Tests\Socket\Stub\CallableStub')->getMock();
5656
}
5757

5858
protected function buffer(ReadableStreamInterface $stream, LoopInterface $loop, $timeout)

tests/TimeoutConnectorTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public function testRejectsOnTimeout()
1212
{
1313
$promise = new Promise\Promise(function () { });
1414

15-
$connector = $this->getMock('React\Socket\ConnectorInterface');
15+
$connector = $this->getMockBuilder('React\Socket\ConnectorInterface')->getMock();
1616
$connector->expects($this->once())->method('connect')->with('google.com:80')->will($this->returnValue($promise));
1717

1818
$loop = Factory::create();
@@ -31,7 +31,7 @@ public function testRejectsWhenConnectorRejects()
3131
{
3232
$promise = Promise\reject(new \RuntimeException());
3333

34-
$connector = $this->getMock('React\Socket\ConnectorInterface');
34+
$connector = $this->getMockBuilder('React\Socket\ConnectorInterface')->getMock();
3535
$connector->expects($this->once())->method('connect')->with('google.com:80')->will($this->returnValue($promise));
3636

3737
$loop = Factory::create();
@@ -50,7 +50,7 @@ public function testResolvesWhenConnectorResolves()
5050
{
5151
$promise = Promise\resolve();
5252

53-
$connector = $this->getMock('React\Socket\ConnectorInterface');
53+
$connector = $this->getMockBuilder('React\Socket\ConnectorInterface')->getMock();
5454
$connector->expects($this->once())->method('connect')->with('google.com:80')->will($this->returnValue($promise));
5555

5656
$loop = Factory::create();
@@ -69,7 +69,7 @@ public function testRejectsAndCancelsPendingPromiseOnTimeout()
6969
{
7070
$promise = new Promise\Promise(function () { }, $this->expectCallableOnce());
7171

72-
$connector = $this->getMock('React\Socket\ConnectorInterface');
72+
$connector = $this->getMockBuilder('React\Socket\ConnectorInterface')->getMock();
7373
$connector->expects($this->once())->method('connect')->with('google.com:80')->will($this->returnValue($promise));
7474

7575
$loop = Factory::create();
@@ -88,7 +88,7 @@ public function testCancelsPendingPromiseOnCancel()
8888
{
8989
$promise = new Promise\Promise(function () { }, function () { throw new \Exception(); });
9090

91-
$connector = $this->getMock('React\Socket\ConnectorInterface');
91+
$connector = $this->getMockBuilder('React\Socket\ConnectorInterface')->getMock();
9292
$connector->expects($this->once())->method('connect')->with('google.com:80')->will($this->returnValue($promise));
9393

9494
$loop = Factory::create();

tests/UnixConnectorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class UnixConnectorTest extends TestCase
1313

1414
public function setUp()
1515
{
16-
$this->loop = $this->getMock('React\EventLoop\LoopInterface');
16+
$this->loop = $this->getMockBuilder('React\EventLoop\LoopInterface')->getMock();
1717
$this->connector = new UnixConnector($this->loop);
1818
}
1919

0 commit comments

Comments
 (0)