Skip to content

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

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

Merged
merged 3 commits into from
Aug 14, 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 export-ignore
/phpunit-legacy.xml 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-legacy.xml; fi
5 changes: 4 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,12 @@
"graphp/graph": "dev-master#fb198e4 as 1.0.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\\Algorithms\\": "src/"}
},
"autoload-dev": {
"psr-4": { "Graphp\\Tests\\Algorithms\\": "tests/" }
}
}
18 changes: 18 additions & 0 deletions phpunit-legacy.xml
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="Algorithm Test Suite">
<directory>./tests/</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory>./src/</directory>
</whitelist>
</filter>
</phpunit>
19 changes: 19 additions & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>

<!-- 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"
cacheResult="false">
<testsuites>
<testsuite name="Algorithm Test Suite">
<directory>./tests/</directory>
</testsuite>
</testsuites>
<coverage>
<include>
<directory>./src/</directory>
</include>
</coverage>
</phpunit>
19 changes: 0 additions & 19 deletions phpunit.xml.dist

This file was deleted.

6 changes: 4 additions & 2 deletions tests/BipartitTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

namespace Graphp\Tests\Algorithms;

use Graphp\Algorithms\Bipartit as AlgorithmBipartit;
use Graphp\Graph\Graph;

Expand Down Expand Up @@ -73,22 +75,22 @@ public function testGraphTriangleCycleIsNotBipartit()
/**
*
* @param AlgorithmBipartit $alg
* @expectedException UnexpectedValueException
* @depends testGraphTriangleCycleIsNotBipartit
*/
public function testGraphTriangleCycleColorsInvalid(AlgorithmBipartit $alg)
{
$this->setExpectedException('UnexpectedValueException');
$alg->getColors();
}

/**
*
* @param AlgorithmBipartit $alg
* @expectedException UnexpectedValueException
* @depends testGraphTriangleCycleIsNotBipartit
*/
public function testGraphTriangleCycleColorVerticesInvalid(AlgorithmBipartit $alg)
{
$this->setExpectedException('UnexpectedValueException');
$alg->getColorVertices();
}
}
2 changes: 2 additions & 0 deletions tests/CompleteTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

namespace Graphp\Tests\Algorithms;

use Graphp\Algorithms\Complete as AlgorithmComplete;
use Graphp\Graph\Graph;

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

namespace Graphp\Tests\Algorithms;

use Graphp\Algorithms\ConnectedComponents as AlgorithmConnected;
use Graphp\Graph\Graph;

Expand Down Expand Up @@ -81,9 +83,6 @@ public function testComponents()
$this->assertEquals($ge, $alg->createGraphComponentVertex($v5));
}

/**
* @expectedException InvalidArgumentException
*/
public function testInvalidVertexPassedToAlgorithm()
{
$graph = new Graph();
Expand All @@ -92,6 +91,8 @@ public function testInvalidVertexPassedToAlgorithm()
$v2 = $graph2->createVertex(12);

$alg = new AlgorithmConnected($graph);

$this->setExpectedException('InvalidArgumentException');
$alg->createGraphComponentVertex($v2);
}
}
2 changes: 2 additions & 0 deletions tests/DegreeTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

namespace Graphp\Tests\Algorithms;

use Graphp\Algorithms\Degree as AlgorithmDegree;
use Graphp\Graph\Exception\UnderflowException;
use Graphp\Graph\Exception\UnexpectedValueException;
Expand Down
6 changes: 4 additions & 2 deletions tests/DetectNegativeCycleTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

namespace Graphp\Tests\Algorithms;

use Graphp\Algorithms\DetectNegativeCycle;
use Graphp\Graph\Graph;

Expand All @@ -20,21 +22,21 @@ public function testNullGraph()
*
* @param DetectNegativeCycle $alg
* @depends testNullGraph
* @expectedException UnderflowException
*/
public function testNullGraphHasNoCycle(DetectNegativeCycle $alg)
{
$this->setExpectedException('UnderflowException');
$alg->getCycleNegative();
}

/**
*
* @param DetectNegativeCycle $alg
* @depends testNullGraph
* @expectedException UnderflowException
*/
public function testNullGraphHasNoCycleGraph(DetectNegativeCycle $alg)
{
$this->setExpectedException('UnderflowException');
$alg->createGraph();
}

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

namespace Graphp\Tests\Algorithms;

use Graphp\Algorithms\Directed as AlgorithmDirected;
use Graphp\Graph\Graph;

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

namespace Graphp\Tests\Algorithms;

use Graphp\Algorithms\Eulerian as AlgorithmEulerian;
use Graphp\Graph\Graph;

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

namespace Graphp\Tests\Algorithms;

use Graphp\Algorithms\Flow as AlgorithmFlow;
use Graphp\Graph\Graph;

Expand All @@ -24,7 +26,6 @@ public function testEdgeWithZeroFlowIsConsideredFlow()
$graph = new Graph();
$graph->createEdgeDirected($graph->createVertex(1), $graph->createVertex(2))->setFlow(0);


$alg = new AlgorithmFlow($graph);

$this->assertTrue($alg->hasFlow());
Expand Down Expand Up @@ -81,18 +82,15 @@ public function testGraphBalance()
$this->assertFalse($alg->isBalancedFlow());
}

/**
* @expectedException UnexpectedValueException
*/
public function testVertexWithUndirectedEdgeHasInvalidFlow()
{
// 1 -- 2
$graph = new Graph();
$graph->createEdgeUndirected($graph->createVertex(1), $graph->createVertex(2))->setFlow(10);


$alg = new AlgorithmFlow($graph);

$this->setExpectedException('UnexpectedValueException');
$alg->getFlowVertex($graph->getVertex(1));
}
}
2 changes: 2 additions & 0 deletions tests/GroupsTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

namespace Graphp\Tests\Algorithms;

use Graphp\Algorithms\Groups as AlgorithmGroups;
use Graphp\Graph\Graph;

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

namespace Graphp\Tests\Algorithms;

use Graphp\Algorithms\Loop as AlgorithmLoop;
use Graphp\Graph\Graph;

Expand Down
17 changes: 6 additions & 11 deletions tests/MaxFlow/EdmondsKarpTest.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
<?php

namespace Graphp\Tests\Algorithms\MaxFlow;

use Graphp\Algorithms\MaxFlow\EdmondsKarp as AlgorithmMaxFlowEdmondsKarp;
use Graphp\Graph\Graph;
use PHPUnit\Framework\TestCase;
use Graphp\Tests\Algorithms\TestCase;

class EdmondsKarpTest extends TestCase
{
Expand Down Expand Up @@ -106,9 +108,6 @@ public function testEdgesMultiplePathsTree()
// $this->assertEquals(10, $alg->getFlowMax());
// }

/**
* @expectedException UnexpectedValueException
*/
public function testEdgesUndirected()
{
// 0 -[0/7]- 1
Expand All @@ -121,6 +120,7 @@ public function testEdgesUndirected()
// 0 -[7/7]- 1
$alg = new AlgorithmMaxFlowEdmondsKarp($v0, $v1);

$this->setExpectedException('UnexpectedValueException');
$this->assertEquals(7, $alg->getFlowMax());
}

Expand All @@ -136,10 +136,6 @@ public function testEdgesUndirected()
// $this->assertEquals(0.735802, $alg->getFlowMax());
// }


/**
* @expectedException InvalidArgumentException
*/
public function testInvalidFlowToOtherGraph()
{
$graph1 = new Graph();
Expand All @@ -148,17 +144,16 @@ public function testInvalidFlowToOtherGraph()
$graph2 = new Graph();
$vg2 = $graph2->createVertex(2);

$this->setExpectedException('InvalidArgumentException');
new AlgorithmMaxFlowEdmondsKarp($vg1, $vg2);
}

/**
* @expectedException InvalidArgumentException
*/
public function testInvalidFlowToSelf()
{
$graph = new Graph();
$v1 = $graph->createVertex(1);

$this->setExpectedException('InvalidArgumentException');
new AlgorithmMaxFlowEdmondsKarp($v1, $v1);
}

Expand Down
Loading