Skip to content

Commit 105948c

Browse files
committed
Add tests with 100% coverage for Algorithm\Complete
1 parent 5338a8b commit 105948c

File tree

1 file changed

+65
-0
lines changed

1 file changed

+65
-0
lines changed

tests/CompleteTest.php

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
<?php
2+
3+
use Fhaculty\Graph\Algorithm\Complete as AlgorithmComplete;
4+
use Fhaculty\Graph\Graph;
5+
6+
class CompleteTest extends TestCase
7+
{
8+
public function testGraphEmptyK0()
9+
{
10+
$graph = new Graph();
11+
12+
$alg = new AlgorithmComplete($graph);
13+
14+
$this->assertTrue($alg->isComplete());
15+
}
16+
17+
public function testGraphSingleTrivialK1()
18+
{
19+
$graph = new Graph();
20+
$graph->createVertex(1);
21+
22+
$alg = new AlgorithmComplete($graph);
23+
24+
$this->assertTrue($alg->isComplete());
25+
}
26+
27+
public function testGraphSimplePairK2()
28+
{
29+
// 1 -- 2
30+
$graph = new Graph();
31+
$graph->createVertex(1)->createEdge($graph->createVertex(2));
32+
33+
$alg = new AlgorithmComplete($graph);
34+
35+
$this->assertTrue($alg->isComplete());
36+
}
37+
38+
public function testGraphSingleDirectedIsNotComplete()
39+
{
40+
// 1 -> 2
41+
$graph = new Graph();
42+
$graph->createVertex(1)->createEdgeTo($graph->createVertex(2));
43+
44+
$alg = new AlgorithmComplete($graph);
45+
46+
$this->assertFalse($alg->isComplete());
47+
}
48+
49+
public function testAdditionalEdgesToNotAffectCompleteness()
50+
{
51+
// 1 -> 2
52+
// 1 -- 2
53+
// 2 -> 1
54+
// 1 -> 1
55+
$graph = new Graph();
56+
$graph->createVertex(1)->createEdgeTo($graph->createVertex(2));
57+
$graph->getVertex(1)->createEdge($graph->getVertex(2));
58+
$graph->getVertex(2)->createEdgeTo($graph->getVertex(1));
59+
$graph->getVertex(1)->createEdgeTo($graph->getVertex(1));
60+
61+
$alg = new AlgorithmComplete($graph);
62+
63+
$this->assertTrue($alg->isComplete());
64+
}
65+
}

0 commit comments

Comments
 (0)