Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ php:
- 7.0
- 7.1
- 7.2
- hhvm # ignore errors, see below
# - hhvm # requires legacy phpunit & ignore errors, see below

# lock distro so new future defaults will not break the build
dist: trusty
Expand All @@ -17,6 +17,8 @@ matrix:
include:
- php: 5.3
dist: precise
- php: hhvm
install: composer require phpunit/phpunit:^5 --dev --no-interaction
allow_failures:
- php: hhvm

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@
"php": ">=5.3"
},
"require-dev": {
"phpunit/phpunit": "^4.8 || ^5.2"
"phpunit/phpunit": "^7.0 || ^6.0 || ^5.2 || ^4.8.35"
}
}
35 changes: 32 additions & 3 deletions tests/FactoryTest.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<?php

use PHPUnit\Framework\TestCase;
use Socket\Raw\Factory;
use Socket\Raw\Socket;

class FactoryTest extends PHPUnit_Framework_TestCase
class FactoryTest extends TestCase
{
/**
* @var Socket\Raw\Factory
Expand All @@ -16,6 +17,9 @@ public function setUp()
$this->factory = new Factory();
}

/**
* @doesNotPerformAssertions
*/
public function testSupportsIpv6()
{
static $available = null;
Expand All @@ -34,6 +38,9 @@ public function testSupportsIpv6()
}
}

/**
* @doesNotPerformAssertions
*/
public function testSupportsUnix()
{
if (!defined('AF_UNIX')) {
Expand Down Expand Up @@ -81,6 +88,7 @@ public function testCreateClientWithSmallTimeoutToUnboundPortTimesOut()
* the target address should not be bound, so connecting via TCP should fail
*
* @see self::testCreateClientUdp4UnboundWorks()
* @doesNotPerformAssertions
*/
public function testCreateClientTcp4UnboundFails()
{
Expand Down Expand Up @@ -163,6 +171,7 @@ public function testCreateServerUnix()

/**
* @depends testSupportsUnix
* @doesNotPerformAssertions
*/
public function testCreateServerUnixFailInvalidPath()
{
Expand Down Expand Up @@ -319,7 +328,7 @@ public function testCreateIcmp6()
}

/**
* @dataProvider testCreateProvider
* @dataProvider provideCreateArguments
*/
public function testCreate($domain, $type, $protocol)
{
Expand All @@ -328,7 +337,7 @@ public function testCreate($domain, $type, $protocol)
$this->assertInstanceOf('Socket\Raw\Socket', $socket);
}

public static function testCreateProvider()
public static function provideCreateArguments()
{
// only return TCP/IP and UDP/IP as the above tests should already cover other sockets
return array(
Expand All @@ -337,6 +346,9 @@ public static function testCreateProvider()
);
}

/**
* @doesNotPerformAssertions
*/
public function testCreateInvalid()
{
try {
Expand All @@ -360,6 +372,9 @@ public function testCreatePair()
$this->assertInstanceOf('Socket\Raw\Socket', $sockets[1]);
}

/**
* @doesNotPerformAssertions
*/
public function testCreatePairInvalid()
{
try {
Expand Down Expand Up @@ -450,6 +465,8 @@ public function testCreateFromStringSchemelessTcp6()

/**
* creating socket for invalid scheme should fail
*
* @doesNotPerformAssertions
*/
public function testCreateFromStringInvalid()
{
Expand All @@ -463,4 +480,16 @@ public function testCreateFromStringInvalid()
$this->fail('Creating socket for invalid scheme should fail');
}

public function setExpectedException($exception, $message = '', $code = 0)
{
if (method_exists($this, 'expectException')) {
$this->expectException($exception);
if ($message !== null) {
$this->expectExceptionMessage($message);
}
$this->expectExceptionCode($code);
} else {
parent::setExpectedException($exception, $message, $code);
}
}
}
21 changes: 19 additions & 2 deletions tests/SocketTest.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<?php

use PHPUnit\Framework\TestCase;
use Socket\Raw\Socket;
use Socket\Raw\Factory;

class SocketTest extends PHPUnit_Framework_TestCase
class SocketTest extends TestCase
{
/**
* @var Socket\Raw\Factory
Expand Down Expand Up @@ -152,7 +153,10 @@ public function testConnectTimeoutGoogle()
$socket->close();
}

/** @group internet */
/**
* @group internet
* @doesNotPerformAssertions
*/
public function testConnectTimeoutUdpImmediately()
{
$socket = $this->factory->createUdp4();
Expand Down Expand Up @@ -239,4 +243,17 @@ public function testServerNonBlockingAcceptClient(Socket $server)

$peer->close();
}

public function setExpectedException($exception, $message = '', $code = 0)
{
if (method_exists($this, 'expectException')) {
$this->expectException($exception);
if ($message !== null) {
$this->expectExceptionMessage($message);
}
$this->expectExceptionCode($code);
} else {
parent::setExpectedException($exception, $message, $code);
}
}
}