Skip to content

Commit 12d4dc5

Browse files
authored
Merge pull request #8 from clue-labs/tests
Improve test suite by adding test instructions and adding PHPUnit to require-dev
2 parents 85e3f1b + c212b3f commit 12d4dc5

File tree

5 files changed

+64
-22
lines changed

5 files changed

+64
-22
lines changed

.travis.yml

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,28 @@
11
language: php
22
php:
3-
- 5.3
3+
# - 5.3 # requires old distro, see below
4+
- 5.4
5+
- 5.5
46
- 5.6
5-
- hhvm
7+
- 7.0
8+
- 7.1
9+
- 7.2
10+
- hhvm # ignore errors, see below
11+
12+
# lock distro so future defaults will not break the build
13+
dist: trusty
14+
15+
matrix:
16+
include:
17+
- php: 5.3
18+
dist: precise
19+
allow_failures:
20+
- php: hhvm
21+
22+
sudo: false
23+
624
install:
7-
- composer install --prefer-source --no-interaction
25+
- composer install --no-interaction
26+
827
script:
9-
- phpunit --coverage-text
28+
- vendor/bin/phpunit --coverage-text

README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@ expired IETF draft: https://tools.ietf.org/html/draft-goland-http-udp-01
1212
This is an alternative to DNS-Based Service Discovery (DNS-SD)
1313
as defined in [RFC 6763](http://tools.ietf.org/html/rfc6763).
1414

15+
**Table of Contents**
16+
17+
* [Quickstart example](#quickstart-example)
18+
* [Install](#install)
19+
* [Tests](#tests)
20+
* [License](#license)
21+
1522
> Note: This project is in early alpha stage! Feel free to report any issues you encounter.
1623
1724
## Quickstart example
@@ -53,6 +60,26 @@ The recommended way to install this library is [through composer](http://getcomp
5360
}
5461
```
5562

63+
This project aims to run on any platform and thus does not require any PHP
64+
extensions and supports running on legacy PHP 5.3 through current PHP 7+ and
65+
HHVM.
66+
It's *highly recommended to use PHP 7+* for this project.
67+
68+
## Tests
69+
70+
To run the test suite, you first need to clone this repo and then install all
71+
dependencies [through Composer](https://getcomposer.org):
72+
73+
```bash
74+
$ composer install
75+
```
76+
77+
To run the test suite, go to the project root and run:
78+
79+
```bash
80+
$ php vendor/bin/phpunit
81+
```
82+
5683
## License
5784

5885
MIT

composer.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,8 @@
1818
"react/event-loop": "~0.4.0|~0.3.0",
1919
"react/promise": "~2.0|~1.0",
2020
"clue/multicast-react": "~0.2.0"
21+
},
22+
"require-dev": {
23+
"phpunit/phpunit": "^6.0 || ^5.7 || ^4.8.35"
2124
}
2225
}

tests/ClientTest.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,25 @@
55

66
class ClientTest extends TestCase
77
{
8+
/**
9+
* @doesNotPerformAssertions
10+
*/
811
public function testCtor()
912
{
10-
$loop = $this->getMock('React\EventLoop\LoopInterface');
13+
$loop = $this->getMockBuilder('React\EventLoop\LoopInterface')->getMock();
1114
new Client($loop);
1215
}
1316

1417
public function testSearchCancel()
1518
{
16-
$loop = $this->getMock('React\EventLoop\LoopInterface');
19+
$loop = $this->getMockBuilder('React\EventLoop\LoopInterface')->getMock();
1720
$multicast = $this->getMockBuilder('Clue\React\Multicast\Factory')->disableOriginalConstructor()->getMock();
1821
$client = new Client($loop, $multicast);
1922

20-
$socket = $this->getMock('React\Datagram\SocketInterface');
23+
$socket = $this->getMockBuilder('React\Datagram\SocketInterface')->getMock();
2124
$socket->expects($this->once())->method('send');
2225

23-
$timer = $this->getMock('React\EventLoop\Timer\TimerInterface');
26+
$timer = $this->getMockBuilder('React\EventLoop\Timer\TimerInterface')->getMock();
2427
$loop->expects($this->once())->method('addTimer')->will($this->returnValue($timer));
2528

2629
$multicast->expects($this->once())->method('createSender')->will($this->returnValue($socket));

tests/bootstrap.php

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

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

5-
class TestCase extends PHPUnit_Framework_TestCase
5+
class TestCase extends PHPUnit\Framework\TestCase
66
{
77
protected function expectCallableOnce()
88
{
@@ -19,24 +19,14 @@ protected function expectCallableNever()
1919
{
2020
$mock = $this->createCallableMock();
2121
$mock
22-
->expects($this->never())
23-
->method('__invoke');
22+
->expects($this->never())
23+
->method('__invoke');
2424

2525
return $mock;
2626
}
2727

28-
/**
29-
* @link https://github.com/reactphp/react/blob/master/tests/React/Tests/Socket/TestCase.php (taken from reactphp/react)
30-
*/
3128
protected function createCallableMock()
3229
{
33-
return $this->getMock('CallableStub');
34-
}
35-
}
36-
37-
class CallableStub
38-
{
39-
public function __invoke()
40-
{
30+
return $this->getMockBuilder('stdClass')->setMethods(array('__invoke'))->getMock();
4131
}
4232
}

0 commit comments

Comments
 (0)