Skip to content

Commit

Permalink
Try to fix tests on Travis.
Browse files Browse the repository at this point in the history
  • Loading branch information
drupol committed Jun 15, 2019
1 parent 21829da commit 97ce53b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion spec/drupol/phptree/Exporter/GraphSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,29 @@

use drupol\phptree\Exporter\Graph;
use drupol\phptree\Node\ValueNode;
use Graphp\GraphViz\GraphViz;
use spec\drupol\phptree\Node\NodeObjectBehavior;

/**
* Class GraphSpec.
*
* @method shouldHaveSameGraphImageFile(string $filepath)
*/
class GraphSpec extends NodeObjectBehavior
{
/**
* {@inheritdoc}
*/
public function getMatchers(): array
{
return [
'haveSameGraphImageFile' => function ($subject, $key) {
$left = (new GraphViz())->setFormat('png')->createImageFile($subject);

return \sha1(\file_get_contents($left)) === \sha1(\file_get_contents($key));
},
];
}
public function it_can_generate_a_graph()
{
$tree = new ValueNode('root');
Expand All @@ -32,7 +51,7 @@ public function it_can_generate_a_graph()

$this
->export($tree)
->shouldHaveSameGraphImageFile($_SERVER['PWD'] . '/tests/fixtures/graphvizMvJSKP.png');
->shouldHaveSameGraphImageFile($_SERVER['PWD'] . '/tests/fixtures/Exporter/GraphSpec1.png');
}

public function it_is_initializable()
Expand Down
File renamed without changes

0 comments on commit 97ce53b

Please sign in to comment.