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
27 changes: 23 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -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
27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
3 changes: 3 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
11 changes: 7 additions & 4 deletions tests/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
18 changes: 4 additions & 14 deletions tests/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require __DIR__ . '/../vendor/autoload.php';

class TestCase extends PHPUnit_Framework_TestCase
class TestCase extends PHPUnit\Framework\TestCase
{
protected function expectCallableOnce()
{
Expand All @@ -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();
}
}