Skip to content

Commit f45dfe9

Browse files
committed
Issue #7: Trying to fix png image generation on Travis.
1 parent d2df15e commit f45dfe9

File tree

1 file changed

+8
-14
lines changed

1 file changed

+8
-14
lines changed

spec/drupol/phptree/Exporter/GraphSpec.php

+8-14
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace spec\drupol\phptree\Exporter;
66

77
use drupol\phptree\Exporter\Graph;
8+
use drupol\phptree\Importer\Text;
89
use drupol\phptree\Node\ValueNode;
910
use Graphp\GraphViz\GraphViz;
1011
use spec\drupol\phptree\Node\NodeObjectBehavior;
@@ -22,20 +23,13 @@ class GraphSpec extends NodeObjectBehavior
2223
public function getMatchers(): array
2324
{
2425
return [
25-
'haveSameGraphImageFile' => function ($subject, $key) {
26-
$left = (new GraphViz())->setFormat('png')->createImageFile($subject);
26+
'haveSameGraphImageFile' => function ($left, $right) {
27+
$importer = new Text();
28+
$exporter = new Graph();
2729

28-
$left = file_get_contents($left);
29-
var_dump('file_get_contents($left)');
30-
print_r($left);
30+
$right = $exporter->export($importer->import($right));
3131

32-
var_dump('right');
33-
print_r(file_get_contents($key));
34-
35-
var_dump(sha1($left));
36-
var_dump(sha1(file_get_contents($key)));
37-
38-
return \sha1($left) === \sha1(\file_get_contents($key));
32+
return (new GraphViz())->createImageSrc($left) === (new GraphViz())->createImageSrc($right);
3933
},
4034
];
4135
}
@@ -46,7 +40,7 @@ public function it_can_generate_a_graph()
4640
$child1 = new ValueNode('child1');
4741
$child2 = new ValueNode('child2');
4842
$child3 = new ValueNode('child3');
49-
$child4 = new ValueNode('child3');
43+
$child4 = new ValueNode('child4');
5044
$child1->add($child4);
5145

5246
$tree
@@ -62,7 +56,7 @@ public function it_can_generate_a_graph()
6256

6357
$this
6458
->export($tree)
65-
->shouldHaveSameGraphImageFile(getcwd() . '/tests/fixtures/Exporter/GraphSpec1.png');
59+
->shouldHaveSameGraphImageFile('[root[child1[child4]][child2][child3]]');
6660
}
6761

6862
public function it_is_initializable()

0 commit comments

Comments
 (0)