Skip to content

Commit 64c3b16

Browse files
authored
Merge pull request #9 from clue-labs/tests
Improve test suite by adding test instructions and adding PHPUnit to require-dev
2 parents d31721f + dace564 commit 64c3b16

File tree

5 files changed

+46
-31
lines changed

5 files changed

+46
-31
lines changed

.travis.yml

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,29 @@
11
language: php
22

33
php:
4-
- 5.3
4+
# - 5.3 # requires old distro, see below
55
- 5.4
66
- 5.5
77
- 5.6
8-
- 7
9-
- hhvm
8+
- 7.0
9+
- 7.1
10+
- 7.2
11+
- hhvm # ignore errors, see below
12+
13+
# lock distro so future defaults will not break the build
14+
dist: trusty
15+
16+
matrix:
17+
include:
18+
- php: 5.3
19+
dist: precise
20+
allow_failures:
21+
- php: hhvm
22+
23+
sudo: false
1024

1125
install:
12-
- composer install --prefer-source --no-interaction
26+
- composer install --no-interaction
1327

1428
script:
15-
- phpunit --coverage-text
29+
- vendor/bin/phpunit --coverage-text

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ Among others, multicast networking is the basis for:
2121
* [createReceiver()](#createreceiver)
2222
* [Socket](#socket)
2323
* [Install](#install)
24+
* [Tests](#tests)
2425
* [License](#license)
2526

2627
## Quickstart example
@@ -134,6 +135,26 @@ The recommended way to install this library is [through Composer](http://getcomp
134135
$ composer require clue/multicast-react:~1.0
135136
```
136137

138+
This project aims to run on any platform and thus does not require any PHP
139+
extensions and supports running on legacy PHP 5.3 through current PHP 7+ and
140+
HHVM.
141+
It's *highly recommended to use PHP 7+* for this project.
142+
143+
## Tests
144+
145+
To run the test suite, you first need to clone this repo and then install all
146+
dependencies [through Composer](https://getcomposer.org):
147+
148+
```bash
149+
$ composer install
150+
```
151+
152+
To run the test suite, go to the project root and run:
153+
154+
```bash
155+
$ php vendor/bin/phpunit
156+
```
157+
137158
## License
138159

139160
MIT

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
"react/datagram": "~1.0"
2020
},
2121
"require-dev": {
22-
"clue/hexdump": "0.2.*"
22+
"clue/hexdump": "0.2.*",
23+
"phpunit/phpunit": "^6.0 || ^5.7 || ^4.8.35"
2324
},
2425
"suggest": {
2526
"php": "PHP 5.4+ is required for listening on multicast addresses (socket options to send IGMP announcements)",

tests/FunctionalTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ public function setUp()
1515
$this->factory = new Factory($this->loop);
1616
}
1717

18+
/** @doesNotPerformAssertions */
1819
public function testSenderWithNoReceiver()
1920
{
2021
$sender = $this->factory->createSender();

tests/bootstrap.php

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<?php
22

3-
require_once __DIR__ . '/../vendor/autoload.php';
3+
require __DIR__ . '/../vendor/autoload.php';
44

55
error_reporting(-1);
66

7-
class TestCase extends PHPUnit_Framework_TestCase
7+
class TestCase extends PHPUnit\Framework\TestCase
88
{
99
protected function expectCallableOnce()
1010
{
@@ -39,30 +39,8 @@ protected function expectCallableNever()
3939
return $mock;
4040
}
4141

42-
protected function expectCallableOnceParameter($type)
43-
{
44-
$mock = $this->createCallableMock();
45-
$mock
46-
->expects($this->once())
47-
->method('__invoke')
48-
->with($this->isInstanceOf($type));
49-
50-
return $mock;
51-
}
52-
53-
/**
54-
* @link https://github.com/reactphp/react/blob/master/tests/React/Tests/Socket/TestCase.php (taken from reactphp/react)
55-
*/
5642
protected function createCallableMock()
5743
{
58-
return $this->getMock('CallableStub');
44+
return $this->getMockBuilder('stdClass')->setMethods(array('__invoke'))->getMock();
5945
}
6046
}
61-
62-
class CallableStub
63-
{
64-
public function __invoke()
65-
{
66-
}
67-
}
68-

0 commit comments

Comments
 (0)