Skip to content

Commit 31bb160

Browse files
committed
Add test with 100% coverage for new Algorithm\Directed
1 parent 0b0bec1 commit 31bb160

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

tests/DirectedTest.php

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<?php
2+
3+
use Fhaculty\Graph\Algorithm\Directed as AlgorithmDirected;
4+
use Fhaculty\Graph\Graph;
5+
6+
class DirectedTest extends TestCase
7+
{
8+
public function testGraphEmpty()
9+
{
10+
$graph = new Graph();
11+
12+
$alg = new AlgorithmDirected($graph);
13+
14+
$this->assertFalse($alg->isDirected());
15+
}
16+
17+
public function testGraphUndirected()
18+
{
19+
// 1 -- 2
20+
$graph = new Graph();
21+
$graph->createVertex(1)->createEdge($graph->createVertex(2));
22+
23+
$alg = new AlgorithmDirected($graph);
24+
25+
$this->assertFalse($alg->isDirected());
26+
}
27+
28+
public function testGraphDirected()
29+
{
30+
// 1 -> 2
31+
$graph = new Graph();
32+
$graph->createVertex(1)->createEdgeTo($graph->createVertex(2));
33+
34+
$alg = new AlgorithmDirected($graph);
35+
36+
$this->assertTrue($alg->isDirected());
37+
}
38+
39+
public function testGraphMixed()
40+
{
41+
// 1 -- 2 -> 3
42+
$graph = new Graph();
43+
$graph->createVertex(1)->createEdge($graph->createVertex(2));
44+
$graph->getVertex(2)->createEdgeTo($graph->createVertex(3));
45+
46+
$alg = new AlgorithmDirected($graph);
47+
48+
$this->assertTrue($alg->isDirected());
49+
}
50+
}

0 commit comments

Comments
 (0)