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
7 changes: 7 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/.gitattributes export-ignore
/.gitignore export-ignore
/.travis.yml export-ignore
/examples/ export-ignore
/phpunit.xml.dist export-ignore
/phpunit.xml.legacy export-ignore
/tests/ export-ignore
11 changes: 5 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ language: php
# lock distro so new future defaults will not break the build
dist: trusty

matrix:
jobs:
include:
- php: 5.3
dist: precise
Expand All @@ -16,7 +16,7 @@ matrix:
- php: 7.3
- php: 7.4
- php: hhvm-3.18
install: composer require phpunit/phpunit:^5 --dev --no-interaction
install: composer require phpunit/phpunit:^5 --dev
- name: "Windows"
os: windows
language: shell # no built-in php support
Expand All @@ -30,10 +30,9 @@ matrix:
- php: hhvm-3.18
- os: windows

sudo: false

install:
- composer install --no-interaction
- composer install

script:
- vendor/bin/phpunit --coverage-text
- if [[ "$TRAVIS_PHP_VERSION" > "7.2" ]]; then vendor/bin/phpunit --coverage-text; fi
- if [[ "$TRAVIS_PHP_VERSION" < "7.3" ]]; then vendor/bin/phpunit --coverage-text -c phpunit.xml.legacy; fi
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": "^7.0 || ^6.0 || ^5.2 || ^4.8.35"
"phpunit/phpunit": "^9.3 || ^5.7 || ^4.8.35"
}
}
18 changes: 9 additions & 9 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>

<phpunit bootstrap="vendor/autoload.php"
<!-- PHPUnit configuration file with new format for PHPUnit 9.3+ -->
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
>
cacheResult="false">
<testsuites>
<testsuite name="Socket Test Suite">
<directory>./tests/</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<coverage>
<include>
<directory>./src/</directory>
</whitelist>
</filter>
</include>
</coverage>
</phpunit>
18 changes: 18 additions & 0 deletions phpunit.xml.legacy
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>

<!-- PHPUnit configuration file with old format for PHPUnit 9.2 or older -->
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/4.8/phpunit.xsd"
bootstrap="vendor/autoload.php"
colors="true">
<testsuites>
<testsuite name="Socket Test Suite">
<directory>./tests/</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory>./src/</directory>
</whitelist>
</filter>
</phpunit>
15 changes: 11 additions & 4 deletions tests/FactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ class FactoryTest extends TestCase
*/
protected $factory;

public function setUp()
/**
* @before
*/
public function setUpFactory()
{
$this->factory = new Factory();
}
Expand Down Expand Up @@ -409,13 +412,13 @@ public function testCreateListenRandom()
*
* @param Socket $socket
* @depends testCreateListenRandom
* @expectedException Exception
*/
public function testCreateListenInUseFails(Socket $socket)
{
$address = $socket->getSockName();
$port = substr($address, strrpos($address, ':') + 1);

$this->setExpectedException('Exception');
$this->factory->createListen($port);
}

Expand Down Expand Up @@ -488,15 +491,19 @@ public function testCreateFromStringInvalid()
$this->fail('Creating socket for invalid scheme should fail');
}

public function setExpectedException($exception, $message = '', $code = 0)
public function setExpectedException($exception, $message = null, $code = null)
{
if (method_exists($this, 'expectException')) {
// PHPUnit 5.2+
$this->expectException($exception);
if ($message !== null) {
$this->expectExceptionMessage($message);
}
$this->expectExceptionCode($code);
if ($code !== null) {
$this->expectExceptionCode($code);
}
} else {
// legacy PHPUnit 4 - PHPUnit 5.1
parent::setExpectedException($exception, $message, $code);
}
}
Expand Down
5 changes: 4 additions & 1 deletion tests/SocketTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ class SocketTest extends TestCase
*/
protected $factory;

public function setUp()
/**
* @before
*/
public function setUpFactory()
{
$this->factory = new Factory();
}
Expand Down