Skip to content

Commit 0efc611

Browse files
committed
Add tests instructions and add PHPUnit to require-dev
1 parent 85e3f1b commit 0efc611

5 files changed

Lines changed: 40 additions & 20 deletions

File tree

.travis.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ php:
33
- 5.3
44
- 5.6
55
- hhvm
6+
67
install:
7-
- composer install --prefer-source --no-interaction
8+
- composer install --no-interaction
9+
810
script:
9-
- phpunit --coverage-text
11+
- vendor/bin/phpunit --coverage-text

README.md

Lines changed: 22 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,21 @@ The recommended way to install this library is [through composer](http://getcomp
5360
}
5461
```
5562

63+
## Tests
64+
65+
To run the test suite, you first need to clone this repo and then install all
66+
dependencies [through Composer](https://getcomposer.org):
67+
68+
```bash
69+
$ composer install
70+
```
71+
72+
To run the test suite, go to the project root and run:
73+
74+
```bash
75+
$ php vendor/bin/phpunit
76+
```
77+
5678
## License
5779

5880
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)