Skip to content

Commit 97b163e

Browse files
authored
Merge pull request #162 from clue-labs/tests
Update test suite to support PHPUnit 6 and PHPUnit 5 and support running on legacy PHP 5.3 through PHP 7.2 and HHVM
2 parents 4d4146c + 97817ac commit 97b163e

6 files changed

Lines changed: 36 additions & 20 deletions

File tree

.travis.yml

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +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
1022

1123
sudo: false
1224

1325
install:
1426
- composer install --no-interaction
1527

1628
script:
17-
- php vendor/bin/phpunit --coverage-text
29+
- vendor/bin/phpunit --coverage-text

README.md

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,16 +96,25 @@ The recommended way to install this library is [through composer](http://getcomp
9696
}
9797
```
9898

99+
This project aims to run on any platform and thus does not require any PHP
100+
extensions and supports running on legacy PHP 5.3 through current PHP 7+ and
101+
HHVM.
102+
It's *highly recommended to use PHP 7+* for this project.
103+
99104
You may also want to install some of the [additional components](#components).
100105
A list of all official components can be found in the [graphp project](https://github.com/graphp).
101106

102107
## Tests
103108

104109
This library uses PHPUnit for its extensive test suite.
105-
You can either use a global installation or rely on the one composer installs
106-
when you first run `$ composer install`.
107-
This sets up the developer environment, so that you
108-
can now run it from the project root directory:
110+
To run the test suite, you first need to clone this repo and then install all
111+
dependencies [through Composer](https://getcomposer.org):
112+
113+
```bash
114+
$ composer install
115+
```
116+
117+
To run the test suite, go to the project root and run:
109118

110119
```bash
111120
$ php vendor/bin/phpunit

_config.yml

Lines changed: 0 additions & 1 deletion
This file was deleted.

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"php": "^7.0 || ^5.3"
2626
},
2727
"require-dev": {
28-
"phpunit/phpunit": "~4.0"
28+
"phpunit/phpunit": "^6.4 || ^5.7 || ^4.8.35"
2929
},
3030
"suggest": {
3131
"graphp/graphviz": "GraphViz graph drawing / DOT output",

tests/GraphTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,15 +203,15 @@ public function testCreateVerticesNone()
203203
/**
204204
* expect to fail for invalid number of vertices
205205
* @expectedException InvalidArgumentException
206-
* @dataProvider testCreateVerticesFailProvider
206+
* @dataProvider createVerticesFailProvider
207207
*/
208208
public function testCreateVerticesFail($number)
209209
{
210210
$graph = new Graph();
211211
$graph->createVertices($number);
212212
}
213213

214-
public static function testCreateVerticesFailProvider()
214+
public static function createVerticesFailProvider()
215215
{
216216
return array(
217217
array(-1),

tests/TestCase.php

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,9 @@
66
use Fhaculty\Graph\Edge\Base as Edge;
77
use Fhaculty\Graph\Graph;
88
use Fhaculty\Graph\Vertex;
9-
use Fhaculty\Graph\Set\Vertices;
10-
use PHPUnit_Framework_TestCase;
9+
use PHPUnit\Framework\TestCase as BaseTestCase;
1110

12-
class TestCase extends PHPUnit_Framework_TestCase
11+
class TestCase extends BaseTestCase
1312
{
1413
protected function assertGraphEquals(Graph $expected, Graph $actual)
1514
{
@@ -29,11 +28,8 @@ protected function assertGraphEquals(Graph $expected, Graph $actual)
2928
// do not use assertVertexEquals() in order to not increase assertion counter
3029

3130
foreach ($expected->getVertices()->getMap() as $vid => $vertex) {
32-
try {
33-
$other = $actual->getVertex($vid);
34-
} catch (Exception $e) {
35-
$this->fail();
36-
}
31+
$other = $actual->getVertex($vid);
32+
3733
if ($this->getVertexDump($vertex) !== $this->getVertexDump($vertex)) {
3834
$this->fail();
3935
}

0 commit comments

Comments
 (0)