| 1 |
lars |
1 |
--TEST--
|
|
|
2 |
Unit test for graphs with ports
|
|
|
3 |
--FILE--
|
|
|
4 |
<?php
|
|
|
5 |
|
|
|
6 |
/**
|
|
|
7 |
* Test 14: "Drawing of records (revisited)"
|
|
|
8 |
*
|
|
|
9 |
* Graph definition taken from GraphViz documentation
|
|
|
10 |
*
|
|
|
11 |
* @category Image
|
|
|
12 |
* @package Image_GraphViz
|
|
|
13 |
* @author Philippe Jausions <jausions@php.net>
|
|
|
14 |
*/
|
|
|
15 |
require_once 'Image/GraphViz.php';
|
|
|
16 |
|
|
|
17 |
$graph = new Image_GraphViz(true, array(), 'structs', false);
|
|
|
18 |
|
|
|
19 |
$graph->addNode('struct1', array('shape' => 'record',
|
|
|
20 |
'label' => '<f0> left|<f1> middle|<f2> right'));
|
|
|
21 |
$graph->addNode('struct2', array('shape' => 'record',
|
|
|
22 |
'label' => '<f0> one|<f1> two'));
|
|
|
23 |
$graph->addNode('struct3', array('shape' => 'record',
|
|
|
24 |
'label' => "hello\nworld | { b |{c|<here> d|e}| f}| g | h"));
|
|
|
25 |
$graph->addEdge(array('struct1' => 'struct2'), array(),
|
|
|
26 |
array('struct1' => 'f1', 'struct2' => 'f0'));
|
|
|
27 |
$graph->addEdge(array('struct1' => 'struct3'), array(),
|
|
|
28 |
array('struct1' => 'f1', 'struct3' => 'here'));
|
|
|
29 |
|
|
|
30 |
echo $graph->parse();
|
|
|
31 |
|
|
|
32 |
?>
|
|
|
33 |
--EXPECT--
|
|
|
34 |
digraph structs {
|
|
|
35 |
struct1 [ shape=record,label="<f0> left|<f1> middle|<f2> right" ];
|
|
|
36 |
struct2 [ shape=record,label="<f0> one|<f1> two" ];
|
|
|
37 |
struct3 [ shape=record,label="hello\nworld | { b |{c|<here> d|e}| f}| g | h" ];
|
|
|
38 |
struct1:f1 -> struct2:f0;
|
|
|
39 |
struct1:f1 -> struct3:here;
|
|
|
40 |
}
|