Skip to content

Commit 97ce53b

Browse files
committed
Try to fix tests on Travis.
1 parent 21829da commit 97ce53b

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

spec/drupol/phptree/Exporter/GraphSpec.php

+20-1
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,29 @@
66

77
use drupol\phptree\Exporter\Graph;
88
use drupol\phptree\Node\ValueNode;
9+
use Graphp\GraphViz\GraphViz;
910
use spec\drupol\phptree\Node\NodeObjectBehavior;
1011

12+
/**
13+
* Class GraphSpec.
14+
*
15+
* @method shouldHaveSameGraphImageFile(string $filepath)
16+
*/
1117
class GraphSpec extends NodeObjectBehavior
1218
{
19+
/**
20+
* {@inheritdoc}
21+
*/
22+
public function getMatchers(): array
23+
{
24+
return [
25+
'haveSameGraphImageFile' => function ($subject, $key) {
26+
$left = (new GraphViz())->setFormat('png')->createImageFile($subject);
27+
28+
return \sha1(\file_get_contents($left)) === \sha1(\file_get_contents($key));
29+
},
30+
];
31+
}
1332
public function it_can_generate_a_graph()
1433
{
1534
$tree = new ValueNode('root');
@@ -32,7 +51,7 @@ public function it_can_generate_a_graph()
3251

3352
$this
3453
->export($tree)
35-
->shouldHaveSameGraphImageFile($_SERVER['PWD'] . '/tests/fixtures/graphvizMvJSKP.png');
54+
->shouldHaveSameGraphImageFile($_SERVER['PWD'] . '/tests/fixtures/Exporter/GraphSpec1.png');
3655
}
3756

3857
public function it_is_initializable()

0 commit comments

Comments
 (0)