Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update test suite to support PHPUnit 6 and PHPUnit 5 and support running on legacy PHP 5.3 through PHP 7.2 and HHVM #162

Merged
merged 2 commits into from
Sep 28, 2018
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
20 changes: 16 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,29 @@
language: php

php:
- 5.3
# - 5.3 # requires old distro, see below
- 5.4
- 5.5
- 5.6
- 7
- 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 --no-interaction

script:
- php vendor/bin/phpunit --coverage-text
- vendor/bin/phpunit --coverage-text
17 changes: 13 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,16 +96,25 @@ 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.

You may also want to install some of the [additional components](#components).
A list of all official components can be found in the [graphp project](https://github.com/graphp).

## Tests

This library uses PHPUnit for its extensive test suite.
You can either use a global installation or rely on the one composer installs
when you first run `$ composer install`.
This sets up the developer environment, so that you
can now run it from the project root directory:
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
Expand Down
1 change: 0 additions & 1 deletion _config.yml

This file was deleted.

2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"php": "^7.0 || ^5.3"
},
"require-dev": {
"phpunit/phpunit": "~4.0"
"phpunit/phpunit": "^6.4 || ^5.7 || ^4.8.35"
},
"suggest": {
"graphp/graphviz": "GraphViz graph drawing / DOT output",
Expand Down
4 changes: 2 additions & 2 deletions tests/GraphTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -203,15 +203,15 @@ public function testCreateVerticesNone()
/**
* expect to fail for invalid number of vertices
* @expectedException InvalidArgumentException
* @dataProvider testCreateVerticesFailProvider
* @dataProvider createVerticesFailProvider
*/
public function testCreateVerticesFail($number)
{
$graph = new Graph();
$graph->createVertices($number);
}

public static function testCreateVerticesFailProvider()
public static function createVerticesFailProvider()
{
return array(
array(-1),
Expand Down
12 changes: 4 additions & 8 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@
use Fhaculty\Graph\Edge\Base as Edge;
use Fhaculty\Graph\Graph;
use Fhaculty\Graph\Vertex;
use Fhaculty\Graph\Set\Vertices;
use PHPUnit_Framework_TestCase;
use PHPUnit\Framework\TestCase as BaseTestCase;

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

foreach ($expected->getVertices()->getMap() as $vid => $vertex) {
try {
$other = $actual->getVertex($vid);
} catch (Exception $e) {
$this->fail();
}
$other = $actual->getVertex($vid);

if ($this->getVertexDump($vertex) !== $this->getVertexDump($vertex)) {
$this->fail();
}
Expand Down