diff --git a/.travis.yml b/.travis.yml index d6e1dfe..72ae172 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,9 +1,28 @@ 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 --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..4075e78 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,26 @@ 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 +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(); } }