diff --git a/.travis.yml b/.travis.yml index 6cc3dcd..30be35b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,11 +1,29 @@ language: php + php: - - 5.6 - - 5.5 +# - 5.3 # requires old distro, see below - 5.4 - - 5.3 - - hhvm + - 5.5 + - 5.6 + - 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 --prefer-source --no-interaction + - composer install --no-interaction + script: - - php vendor/bin/phpunit --coverage-text + - vendor/bin/phpunit --coverage-text diff --git a/README.md b/README.md index efcb7b6..f2e9500 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,26 @@ 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. + +## Tests + +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 +``` + ## License Released under the terms of the permissive [MIT license](http://opensource.org/licenses/MIT). diff --git a/composer.json b/composer.json index 83eda52..7168e87 100644 --- a/composer.json +++ b/composer.json @@ -15,7 +15,7 @@ "clue/graph": "~0.9.0|~0.8.0" }, "require-dev": { - "phpunit/phpunit": "~4.0" + "phpunit/phpunit": "^6.4 || ^5.7 || ^4.8.35" }, "autoload": { "psr-4": {"Graphp\\Algorithms\\": "src/"} diff --git a/tests/MaxFlow/EdmondsKarpTest.php b/tests/MaxFlow/EdmondsKarpTest.php index 034087e..978cdf9 100644 --- a/tests/MaxFlow/EdmondsKarpTest.php +++ b/tests/MaxFlow/EdmondsKarpTest.php @@ -1,12 +1,11 @@ createAlg($v1); $cycle = $alg->getCycleNegative(); + + $this->assertInstanceOf('Fhaculty\Graph\Walk', $cycle); } public function testLoopNegativeWeightIsCycle() @@ -68,6 +70,8 @@ public function testLoopNegativeWeightIsCycle() $alg = $this->createAlg($v1); $cycle = $alg->getCycleNegative(); + + $this->assertInstanceOf('Fhaculty\Graph\Walk', $cycle); } public function testNegativeComponentHasCycle() @@ -90,7 +94,16 @@ public function testNegativeComponentHasCycle() // first component does not have a cycle $alg = $this->createAlg($v1); - $this->setExpectedException('UnderflowException'); + $this->expectException('UnderflowException'); $alg->getCycleNegative(); } + + public function expectException($class) + { + if (method_exists($this, 'setExpectedException')) { + $this->setExpectedException($class); + } else { + parent::expectException($class); + } + } } diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 0e3be73..b211810 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -5,10 +5,11 @@ use Fhaculty\Graph\Graph; use Fhaculty\Graph\Vertex; use Fhaculty\Graph\Set\Vertices; +use PHPUnit\Framework\TestCase as BaseTestCase; (include_once __DIR__ . '/../vendor/autoload.php') OR die(PHP_EOL . 'ERROR: composer autoloader not found, run "composer install" or see README for instructions' . PHP_EOL); -class TestCase extends PHPUnit_Framework_TestCase +class TestCase extends BaseTestCase { protected function assertGraphEquals(Graph $expected, Graph $actual) { @@ -28,11 +29,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(); }