From 0efc611d5d461db150e957af01d0ba646ac11e3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20L=C3=BCck?= Date: Sat, 19 May 2018 19:45:45 +0200 Subject: [PATCH 1/2] Add tests instructions and add PHPUnit to require-dev --- .travis.yml | 6 ++++-- README.md | 22 ++++++++++++++++++++++ composer.json | 3 +++ tests/ClientTest.php | 11 +++++++---- tests/bootstrap.php | 18 ++++-------------- 5 files changed, 40 insertions(+), 20 deletions(-) diff --git a/.travis.yml b/.travis.yml index d6e1dfe..c51caba 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,9 @@ php: - 5.3 - 5.6 - hhvm + install: - - composer install --prefer-source --no-interaction + - composer install --no-interaction + script: - - phpunit --coverage-text + - vendor/bin/phpunit --coverage-text diff --git a/README.md b/README.md index 3f83c11..e393ab3 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,13 @@ expired IETF draft: https://tools.ietf.org/html/draft-goland-http-udp-01 This is an alternative to DNS-Based Service Discovery (DNS-SD) as defined in [RFC 6763](http://tools.ietf.org/html/rfc6763). +**Table of Contents** + +* [Quickstart example](#quickstart-example) +* [Install](#install) +* [Tests](#tests) +* [License](#license) + > Note: This project is in early alpha stage! Feel free to report any issues you encounter. ## Quickstart example @@ -53,6 +60,21 @@ The recommended way to install this library is [through composer](http://getcomp } ``` +## Tests + +To run the test suite, you first need to clone this repo and then install all +dependencies [through Composer](https://getcomposer.org): + +```bash +$ composer install +``` + +To run the test suite, go to the project root and run: + +```bash +$ php vendor/bin/phpunit +``` + ## License MIT diff --git a/composer.json b/composer.json index 4c66ed2..7ef22e1 100644 --- a/composer.json +++ b/composer.json @@ -18,5 +18,8 @@ "react/event-loop": "~0.4.0|~0.3.0", "react/promise": "~2.0|~1.0", "clue/multicast-react": "~0.2.0" + }, + "require-dev": { + "phpunit/phpunit": "^6.0 || ^5.7 || ^4.8.35" } } diff --git a/tests/ClientTest.php b/tests/ClientTest.php index 1f2a149..d53878f 100644 --- a/tests/ClientTest.php +++ b/tests/ClientTest.php @@ -5,22 +5,25 @@ class ClientTest extends TestCase { + /** + * @doesNotPerformAssertions + */ public function testCtor() { - $loop = $this->getMock('React\EventLoop\LoopInterface'); + $loop = $this->getMockBuilder('React\EventLoop\LoopInterface')->getMock(); new Client($loop); } public function testSearchCancel() { - $loop = $this->getMock('React\EventLoop\LoopInterface'); + $loop = $this->getMockBuilder('React\EventLoop\LoopInterface')->getMock(); $multicast = $this->getMockBuilder('Clue\React\Multicast\Factory')->disableOriginalConstructor()->getMock(); $client = new Client($loop, $multicast); - $socket = $this->getMock('React\Datagram\SocketInterface'); + $socket = $this->getMockBuilder('React\Datagram\SocketInterface')->getMock(); $socket->expects($this->once())->method('send'); - $timer = $this->getMock('React\EventLoop\Timer\TimerInterface'); + $timer = $this->getMockBuilder('React\EventLoop\Timer\TimerInterface')->getMock(); $loop->expects($this->once())->method('addTimer')->will($this->returnValue($timer)); $multicast->expects($this->once())->method('createSender')->will($this->returnValue($socket)); diff --git a/tests/bootstrap.php b/tests/bootstrap.php index b1e7d90..156599d 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -2,7 +2,7 @@ require __DIR__ . '/../vendor/autoload.php'; -class TestCase extends PHPUnit_Framework_TestCase +class TestCase extends PHPUnit\Framework\TestCase { protected function expectCallableOnce() { @@ -19,24 +19,14 @@ protected function expectCallableNever() { $mock = $this->createCallableMock(); $mock - ->expects($this->never()) - ->method('__invoke'); + ->expects($this->never()) + ->method('__invoke'); return $mock; } - /** - * @link https://github.com/reactphp/react/blob/master/tests/React/Tests/Socket/TestCase.php (taken from reactphp/react) - */ protected function createCallableMock() { - return $this->getMock('CallableStub'); - } -} - -class CallableStub -{ - public function __invoke() - { + return $this->getMockBuilder('stdClass')->setMethods(array('__invoke'))->getMock(); } } From c212b3f2c25cd4b066d3098fb23da2cf1548add7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20L=C3=BCck?= Date: Sat, 19 May 2018 19:50:24 +0200 Subject: [PATCH 2/2] Support legacy PHP 5.3 through PHP 7.2 and HHVM --- .travis.yml | 21 +++++++++++++++++++-- README.md | 5 +++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index c51caba..72ae172 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,25 @@ language: php php: - - 5.3 +# - 5.3 # requires old distro, see below + - 5.4 + - 5.5 - 5.6 - - hhvm + - 7.0 + - 7.1 + - 7.2 + - hhvm # ignore errors, see below + +# lock distro so future defaults will not break the build +dist: trusty + +matrix: + include: + - php: 5.3 + dist: precise + allow_failures: + - php: hhvm + +sudo: false install: - composer install --no-interaction diff --git a/README.md b/README.md index e393ab3..4075e78 100644 --- a/README.md +++ b/README.md @@ -60,6 +60,11 @@ The recommended way to install this library is [through composer](http://getcomp } ``` +This project aims to run on any platform and thus does not require any PHP +extensions and supports running on legacy PHP 5.3 through current PHP 7+ and +HHVM. +It's *highly recommended to use PHP 7+* for this project. + ## Tests To run the test suite, you first need to clone this repo and then install all