diff --git a/.travis.yml b/.travis.yml index ad96133..34e3ebb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,15 +1,5 @@ language: php -php: -# - 5.3 # requires old distro, see below - - 5.4 - - 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 @@ -17,18 +7,29 @@ matrix: include: - php: 5.3 dist: precise + - php: 5.4 + - php: 5.5 + - php: 5.6 + - php: 7.0 + - php: 7.1 - php: 7.2 + - php: 7.3 + - php: 7.4 + - name: "Build phar" + php: 7.2 script: composer build - - php: 7.2 + - name: "Test dependency installation" + php: 7.2 install: [] script: composer install --dry-run --working-dir=tests/install-as-dep + - php: hhvm-3.18 allow_failures: - - php: hhvm + - php: hhvm-3.18 sudo: false install: - - composer install --prefer-source --no-interaction + - composer install --no-interaction script: - vendor/bin/phpunit --coverage-text diff --git a/tests/GraphComposerTest.php b/tests/GraphComposerTest.php index 1304fde..32ff41c 100644 --- a/tests/GraphComposerTest.php +++ b/tests/GraphComposerTest.php @@ -1,6 +1,35 @@ called; + } +} + +class GraphVizMockCreateImageFile extends GraphViz +{ + public $called = 0; + public function createImageFile(Graph $graph) + { + return 'test' . ++$this->called . '.png'; + } +} + +class GraphVizMockSetFormat extends GraphViz +{ + public $called = null; + public function setFormat($format) + { + $this->called = $format; + } +} class GraphTest extends PHPUnit_Framework_TestCase { @@ -15,40 +44,43 @@ public function testCreateGraph() $this->assertTrue(count($graph->getVertices()) > 0); } - public function testWillDisplayGraph() + public function testDisplayGraphCallsDisplayGraphViz() { $dir = __DIR__ . '/../'; - $graphviz = $this->getMock('Graphp\GraphViz\GraphViz'); - $graphviz->expects($this->once())->method('display'); + // mocking with PHP 7.4 reports error with legacy PHPUnit, create manual mock classes instead + $graphviz = new GraphVizMockDisplay(); $graphComposer = new GraphComposer($dir, $graphviz); $graphComposer->displayGraph(); + + $this->assertEquals(1, $graphviz->called); } - public function testWillWriteTemporaryGraph() + public function testGetImagePathWillCreateTemporaryImageFileViaGraphViz() { $dir = __DIR__ . '/../'; - $graphviz = $this->getMock('Graphp\GraphViz\GraphViz'); - $graphviz->expects($this->once())->method('createImageFile')->will($this->returnValue('test.png')); + // mocking with PHP 7.4 reports error with legacy PHPUnit, create manual mock classes instead + $graphviz = new GraphVizMockCreateImageFile(); $graphComposer = new GraphComposer($dir, $graphviz); $ret = $graphComposer->getImagePath(); - $this->assertEquals('test.png', $ret); + $this->assertEquals('test1.png', $ret); } - public function testWillSetFormat() + public function testSetFormatWillSetFormatOnGraphViz() { $dir = __DIR__ . '/../'; - $graphviz = $this->getMock('Graphp\GraphViz\GraphViz'); - $graphviz->expects($this->once())->method('setFormat')->with($this->equalTo('gif')); + // mocking with PHP 7.4 reports error with legacy PHPUnit, create manual mock classes instead + $graphviz = new GraphVizMockSetFormat(); $graphComposer = new GraphComposer($dir, $graphviz); $ret = $graphComposer->setFormat('gif'); $this->assertEquals($graphComposer, $ret); + $this->assertEquals('gif', $graphviz->called); } }