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

Run tests on PHPUnit 9, on PHP 7.4 and add .gitattributes to exclude dev files from exports #15

Merged
merged 3 commits into from
Aug 17, 2020
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
6 changes: 6 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/.gitattributes export-ignore
/.gitignore export-ignore
/.travis.yml export-ignore
/phpunit.xml.dist export-ignore
/phpunit.xml.legacy export-ignore
/tests export-ignore
30 changes: 14 additions & 16 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,29 +1,27 @@
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

matrix:
jobs:
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
- php: hhvm-3.18
allow_failures:
- php: hhvm

sudo: false
- php: hhvm-3.18

install:
- composer install --no-interaction
- composer install

script:
- vendor/bin/phpunit --coverage-text
- if [[ "$TRAVIS_PHP_VERSION" > "7.2" ]]; then vendor/bin/phpunit --coverage-text; fi
- if [[ "$TRAVIS_PHP_VERSION" < "7.3" ]]; then vendor/bin/phpunit --coverage-text -c phpunit.xml.legacy; fi
5 changes: 4 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,12 @@
"clue/graph": "~0.9.0|~0.8.0"
},
"require-dev": {
"phpunit/phpunit": "^6.4 || ^5.7 || ^4.8.35"
"phpunit/phpunit": "^9.3 || ^5.7 || ^4.8.35"
},
"autoload": {
"psr-4": {"Graphp\\GraphML\\": "src/"}
},
"autoload-dev": {
"psr-4": { "Graphp\\Tests\\GraphML\\": "tests/" }
}
}
22 changes: 11 additions & 11 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>

<phpunit bootstrap="tests/bootstrap.php"
<!-- PHPUnit configuration file with new format for PHPUnit 9.3+ -->
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
>
cacheResult="false">
<testsuites>
<testsuite name="GraphML Test Suite">
<directory>./tests/</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory>./src</directory>
</whitelist>
</filter>
</phpunit>
<coverage>
<include>
<directory>./src/</directory>
</include>
</coverage>
</phpunit>
18 changes: 18 additions & 0 deletions phpunit.xml.legacy
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>

<!-- PHPUnit configuration file with old format for PHPUnit 9.2 or older -->
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/4.8/phpunit.xsd"
bootstrap="vendor/autoload.php"
colors="true">
<testsuites>
<testsuite name="GraphML Test Suite">
<directory>./tests/</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory>./src/</directory>
</whitelist>
</filter>
</phpunit>
13 changes: 9 additions & 4 deletions tests/ExporterTest.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
<?php

namespace Graphp\Tests\GraphML;

use Fhaculty\Graph\Graph;
use Graphp\GraphML\Exporter;

class ExporterTest extends TestCase
{
private $exporter;

public function setUp()
/**
* @before
*/
public function setUpExporter()
{
$this->exporter = new Exporter();
}
Expand All @@ -17,7 +22,7 @@ public function testEmpty()
$graph = new Graph();

$output = $this->exporter->getOutput($graph);
$xml = new SimpleXMLElement($output);
$xml = new \SimpleXMLElement($output);

$this->assertEquals(1, count($xml));
$this->assertEquals(1, count($xml->graph));
Expand All @@ -33,7 +38,7 @@ public function testSimple()
$v1->createEdge($v2);

$output = $this->exporter->getOutput($graph);
$xml = new SimpleXMLElement($output);
$xml = new \SimpleXMLElement($output);

$this->assertEquals(1, count($xml->graph->edge));

Expand All @@ -52,7 +57,7 @@ public function testSimpleDirected()
$v1->createEdgeTo($v2);

$output = $this->exporter->getOutput($graph);
$xml = new SimpleXMLElement($output);
$xml = new \SimpleXMLElement($output);

$this->assertEquals(1, count($xml->graph->edge));

Expand Down
2 changes: 2 additions & 0 deletions tests/FunctionalTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

namespace Graphp\Tests\GraphML;

use Fhaculty\Graph\Graph;
use Graphp\GraphML\Exporter;
use Graphp\GraphML\Loader;
Expand Down
7 changes: 6 additions & 1 deletion tests/LoaderTest.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
<?php

namespace Graphp\Tests\GraphML;

use Graphp\GraphML\Loader;

class LoaderTest extends TestCase
{
private $loader;

public function setUp()
/**
* @before
*/
public function setUpLoader()
{
$this->loader = new Loader();
}
Expand Down
5 changes: 2 additions & 3 deletions tests/bootstrap.php → tests/TestCase.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
<?php

namespace Graphp\Tests\GraphML;

use Fhaculty\Graph\Edge\Directed;
use Fhaculty\Graph\Edge\Base as Edge;
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 BaseTestCase
{
protected function assertGraphEquals(Graph $expected, Graph $actual)
Expand Down