File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11<?php
22
33use Fhaculty \Graph \Graph ;
4+ use Fhaculty \Graph \Vertex ;
45
56class 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
You can’t perform that action at this time.
0 commit comments