8000 Merge pull request #235 from clue-labs/tests · reactphp/socket@59730c4 · GitHub
[go: up one dir, main page]

Skip to content

Commit 59730c4

Browse files
authored
Merge pull request #235 from clue-labs/tests
Simplify Travis CI test matrix for Mac OS X setup and skip all TLS tests on legacy HHVM
2 parents b3de2a0 + 8e2f1d7 commit 59730c4

9 files changed

+33
-45
lines changed

.travis.yml

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,30 +17,19 @@ matrix:
1717
- php: 7.4
1818
- php: hhvm-3.18
1919
install: composer require phpunit/phpunit:^5 --dev --no-interaction # requires legacy phpunit
20-
- os: osx
20+
- name: Mac OS X
21+
os: osx
2122
language: generic
22-
php: 7.0 # just to look right on travis
23-
env:
24-
- PACKAGE: php70
23+
before_install:
24+
- curl -s http://getcomposer.org/installer | php
25+
- mv composer.phar /usr/local/bin/composer
2526
allow_failures:
2627
- php: hhvm-3.18
2728
- os: osx
2829

2930
sudo: false
3031

3132
install:
32-
# OSX install inspired by https://github.com/kiler129/TravisCI-OSX-PHP
33-
- |
34-
if [[ "${TRAVIS_OS_NAME}" == "osx" ]]; then
35-
brew tap homebrew/homebrew-php
36-
echo "Installing PHP ..."
37-
brew install "${PACKAGE}"
38-
brew install "${PACKAGE}"-xdebug
39-
brew link "${PACKAGE}"
40-
echo "Installing composer ..."
41-
curl -s http://getcomposer.org/installer | php
42-
mv composer.phar /usr/local/bin/composer
43-
fi
4433
- composer install --no-interaction
4534

4635
script:

tests/FunctionalConnectorTest.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,16 @@ public function connectionToTcpServerShouldSucceedWithLocalhost()
2222
$loop = Factory::create();
2323

2424
$server = new TcpServer(9998, $loop);
25-
$server->on('connection', $this->expectCallableOnce());
26-
$server->on('connection', array($server, 'close'));
2725

2826
$connector = new Connector($loop);
2927

3028
$connection = Block\await($connector->connect('localhost:9998'), $loop, self::TIMEOUT);
3129

30+
$server->close();
31+
3232
$this->assertInstanceOf('React\Socket\ConnectionInterface', $connection);
3333

3434
$connection->close();
35-
$server->close();
3635
}
3736

3837
/**

tests/FunctionalSecureServerTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ class FunctionalSecureServerTest extends TestCase
1919

2020
public function setUp()
2121
{
22-
if (!function_exists('stream_socket_enable_crypto')) {
23-
$this->markTestSkipped('Not supported on your platform (outdated HHVM?)');
22+
if (defined('HHVM_VERSION')) {
23+
$this->markTestSkipped('Not supported on legacy HHVM');
2424
}
2525
}
2626

tests/IntegrationTest.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ public function gettingStuffFromGoogleShouldWork()
3636
/** @test */
3737
public function gettingEncryptedStuffFromGoogleShouldWork()
3838
{
39-
if (!function_exists('stream_socket_enable_crypto')) {
40-
$this->markTestSkipped('Not supported on your platform (outdated HHVM?)');
39+
if (defined('HHVM_VERSION')) {
40+
$this->markTestSkipped('Not supported on legacy HHVM');
4141
}
4242

4343
$loop = Factory::create();
@@ -55,8 +55,8 @@ public function gettingEncryptedStuffFromGoogleShouldWork()
5555
/** @test */
5656
public function gettingEncryptedStuffFromGoogleShouldWorkIfHostIsResolvedFirst()
5757
{
58-
if (!function_exists('stream_socket_enable_crypto')) {
59-
$this->markTestSkipped('Not supported on your platform (outdated HHVM?)');
58+
if (defined('HHVM_VERSION')) {
59+
$this->markTestSkipped('Not supported on legacy HHVM');
6060
}
6161

6262
$loop = Factory::create();
@@ -363,8 +363,8 @@ public function testConnectingFailsIfTimeoutIsTooSmall()
363363

364364
public function testSelfSignedRejectsIfVerificationIsEnabled()
365365
{
366-
if (!function_exists('stream_socket_enable_crypto')) {
367-
$this->markTestSkipped('Not supported on your platform (outdated HHVM?)');
366+
if (defined('HHVM_VERSION')) {
367+
$this->markTestSkipped('Not supported on legacy HHVM');
368368
}
369369

370370
$loop = Factory::create();
@@ -381,8 +381,8 @@ public function testSelfSignedRejectsIfVerificationIsEnabled()
381381

382382
public function testSelfSignedResolvesIfVerificationIsDisabled()
383383
{
384-
if (!function_exists('stream_socket_enable_crypto')) {
385-
$this->markTestSkipped('Not supported on your platform (outdated HHVM?)');
384+
if (defined('HHVM_VERSION')) {
385+
$this->markTestSkipped('Not supported on legacy HHVM');
386386
}
387387

388388
$loop = Factory::create();

tests/SecureConnectorTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ class SecureConnectorTest extends TestCase
1414

1515
public function setUp()
1616
{
17-
if (!function_exists('stream_socket_enable_crypto')) {
18-
$this->markTestSkipped('Not supported on your platform (outdated HHVM?)');
17+
if (defined('HHVM_VERSION')) {
18+
$this->markTestSkipped('Not supported on legacy HHVM');
1919
}
2020

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

tests/SecureIntegrationTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ class SecureIntegrationTest extends TestCase
2424

2525
public function setUp()
2626
{
27-
if (!function_exists('stream_socket_enable_crypto')) {
28-
$this->markTestSkipped('Not supported on your platform (outdated HHVM?)');
27+
if (defined('HHVM_VERSION')) {
28+
$this->markTestSkipped('Not supported on legacy HHVM');
2929
}
3030

3131
$this->loop = LoopFactory::create();

tests/SecureServerTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ class SecureServerTest extends TestCase
1010
{
1111
public function setUp()
1212
{
13-
if (!function_exists('stream_socket_enable_crypto')) {
14-
$this->markTestSkipped('Not supported on your platform (outdated HHVM?)');
13+
if (defined('HHVM_VERSION')) {
14+
$this->markTestSkipped('Not supported on legacy HHVM');
1515
}
1616
}
1717

tests/ServerTest.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ public function testConstructorCreatesExpectedTcpServer()
5151

5252
public function testConstructorCreatesExpectedUnixServer()
5353
{
54+
if (defined('HHVM_VERSION')) {
55+
$this->markTestSkipped('Not supported on legacy HHVM');
56+
}
5457
if (!in_array('unix', stream_get_transports())) {
5558
$this->markTestSkipped('Unix domain sockets (UDS) not supported on your platform (Windows?)');
5659
}
@@ -199,8 +202,8 @@ public function testEmitsConnectionWithInheritedContextOptions()
199202

200203
public function testDoesNotEmitSecureConnectionForNewPlaintextConnectionThatIsIdle()
201204
{
202-
if (!function_exists('stream_socket_enable_crypto')) {
203-
$this->markTestSkipped('Not supported on your platform (outdated HHVM?)');
205+
if (defined('HHVM_VERSION')) {
206+
$this->markTestSkipped('Not supported on legacy HHVM');
204207
}
205208

206209
$loop = Factory::create();

tests/TcpConnectorTest.php

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,6 @@ public function connectionToTcpServerShouldSucceed()
5252
$loop = Factory::create();
5353

5454
$server = new TcpServer(9999, $loop);
55-
$server->on('connection', $this->expectCallableOnce());
56-
$server->on('connection', array($server, 'close'));
5755

5856
$connector = new TcpConnector($loop);
5957

@@ -62,6 +60,7 @@ public function connectionToTcpServerShouldSucceed()
6260
$this->assertInstanceOf('React\Socket\ConnectionInterface', $connection);
6361

6462
$connection->close();
63+
$server->close();
6564
}
6665

6766
/**
@@ -101,7 +100,6 @@ public function connectionToTcpServerShouldSucceedWithRemoteAdressSameAsTarget()
101100
$loop = Factory::create();
102101

103102
$server = new TcpServer(9999, $loop);
104-
$server->on('connection', array($server, 'close'));
105103

106104
$connector = new TcpConnector($loop);
107105

@@ -111,6 +109,7 @@ public function connectionToTcpServerShouldSucceedWithRemoteAdressSameAsTarget()
111109
$this->assertEquals('tcp://127.0.0.1:9999', $connection->getRemoteAddress());
112110

113111
$connection->close();
112+
$server->close();
114113
}
115114

116115
/** @test */
@@ -119,7 +118,6 @@ public function connectionToTcpServerShouldSucceedWithLocalAdressOnLocalhost()
119118
$loop = Factory::create();
120119

121120
$server = new TcpServer(9999, $loop);
122-
$server->on('connection', array($server, 'close'));
123121

124122
$connector = new TcpConnector($loop);
125123

@@ -130,6 +128,7 @@ public function connectionToTcpServerShouldSucceedWithLocalAdressOnLocalhost()
130128
$this->assertNotEquals('tcp://127.0.0.1:9999', $connection->getLocalAddress());
131129

132130
$connection->close();
131+
$server->close();
133132
}
134133

135134
/** @test */
@@ -138,13 +137,13 @@ public function connectionToTcpServerShouldSucceedWithNullAddressesAfterConnecti
138137
$loop = Factory::create();
139138

140139
$server = new TcpServer(9999, $loop);
141-
$server->on('connection', array($server, 'close'));
142140

143141
$connector = new TcpConnector($loop);
144142

145143
$connection = Block\await($connector->connect('127.0.0.1:9999'), $loop, self::TIMEOUT);
146144
/* @var $connection ConnectionInterface */
147145

146+
$server->close();
148147
$connection->close();
149148

150149
$this->assertNull($connection->getRemoteAddress());
@@ -197,9 +196,6 @@ public function connectionToIp6TcpServerShouldSucceed()
197196
$this->markTestSkipped('Unable to start IPv6 server socket (IPv6 not supported on this system?)');
198197
}
199198

200-
$server->on('connection', $this->expectCallableOnce());
201-
$server->on('connection', array($server, 'close'));
202-
203199
$connector = new TcpConnector($loop);
204200

205201
$connection = Block\await($connector->connect('[::1]:9999'), $loop, self::TIMEOUT);
@@ -211,6 +207,7 @@ public function connectionToIp6TcpServerShouldSucceed()
211207
$this->assertNotEquals('tcp://[::1]:9999', $connection->getLocalAddress());
212208

213209
$connection->close();
210+
$server->close();
214211
}
215212

216213
/** @test */

0 commit comments

Comments
 (0)
0