File tree 2 files changed +20
-1
lines changed
spec/drupol/phptree/Exporter
2 files changed +20
-1
lines changed Original file line number Diff line number Diff line change 6
6
7
7
use drupol \phptree \Exporter \Graph ;
8
8
use drupol \phptree \Node \ValueNode ;
9
+ use Graphp \GraphViz \GraphViz ;
9
10
use spec \drupol \phptree \Node \NodeObjectBehavior ;
10
11
12
+ /**
13
+ * Class GraphSpec.
14
+ *
15
+ * @method shouldHaveSameGraphImageFile(string $filepath)
16
+ */
11
17
class GraphSpec extends NodeObjectBehavior
12
18
{
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
+ }
13
32
public function it_can_generate_a_graph ()
14
33
{
15
34
$ tree = new ValueNode ('root ' );
@@ -32,7 +51,7 @@ public function it_can_generate_a_graph()
32
51
33
52
$ this
34
53
->export ($ tree )
35
- ->shouldHaveSameGraphImageFile ($ _SERVER ['PWD ' ] . '/tests/fixtures/graphvizMvJSKP .png ' );
54
+ ->shouldHaveSameGraphImageFile ($ _SERVER ['PWD ' ] . '/tests/fixtures/Exporter/GraphSpec1 .png ' );
36
55
}
37
56
38
57
public function it_is_initializable ()
File renamed without changes.
You can’t perform that action at this time.
0 commit comments