Skip to content

Commit 2f54bd0

Browse files
author
Christian Lück
committed
Add tests for explicit Vertex instantiation
1 parent 46b9b6a commit 2f54bd0

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

tests/Fhaculty/Graph/VertexTest.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?php
22

33
use Fhaculty\Graph\Graph;
4+
use Fhaculty\Graph\Vertex;
45

56
class VertexTest extends TestCase
67
{
@@ -10,6 +11,32 @@ public function setUp()
1011
$this->vertex = $this->graph->createVertex(1);
1112
}
1213

14+
public function testPrecondition()
15+
{
16+
$this->assertCount(1, $this->graph->getVertices());
17+
$this->assertTrue($this->graph->hasVertex(1));
18+
$this->assertFalse($this->graph->hasVertex(2));
19+
$this->assertSame($this->vertex, $this->graph->getVertex(1));
20+
}
21+
22+
public function testConstructor()
23+
{
24+
$v2 = new Vertex(2, $this->graph);
25+
26+
$this->assertCount(2, $this->graph->getVertices());
27+
$this->assertTrue($this->graph->hasVertex(2));
28+
29+
$this->assertSame($v2, $this->graph->getVertex(2));
30+
}
31+
32+
/**
33+
* @expectedException OverflowException
34+
*/
35+
public function testCanNotConstructDuplicateVertex()
36+
{
37+
$v2 = new Vertex(1, $this->graph);
38+
}
39+
1340
public function testEdges()
1441
{
1542
// v1 -> v2, v1 -- v3, v1 <- v4

0 commit comments

Comments
 (0)