Skip to content

Instantly share code, notes, and snippets.

@ircmaxell
Created August 9, 2014 19:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ircmaxell/d5925f42dcaedab78ee6 to your computer and use it in GitHub Desktop.
Save ircmaxell/d5925f42dcaedab78ee6 to your computer and use it in GitHub Desktop.
<?php
/**
* @covers ::generateText
*/
public function testGenerateText() {
$a = p::mock(Vertex::class);
p::when($a)->__toString()->thenReturn('a');
$b = p::mock(Vertex::class);
p::when($b)->__toString()->thenReturn('b');
$c = p::mock(Vertex::class);
p::when($c)->__toString()->thenReturn('c');
$graph = p::mock(DirectedAdjacencyList::class);
p::when($graph)->eachVertex()->thenReturn(call_user_func(function() use ($a, $b, $c) {
yield $a => [];
yield $b => [];
yield $c => [];
}));
p::when($graph)->eachEdge()->thenReturn([[$a, $b], [$b, $c], [$c, $a]]);
$printer = new GraphPrinter;
$this->assertContains('node_0', $printer->generateText($graph));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment