Subversion-Projekte lars-tiefland.php_share

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
--TEST--
2
Unit test for graph with clusters
3
--FILE--
4
<?php
5
 
6
/**
7
 * Test 17: "Process diagram with clusters"
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(), 'G', false);
18
 
19
// cluster0
20
$graph->addCluster('cluster0', 'process #1',
21
                   array('style' => 'filled', 'color' => 'lightgrey'));
22
$graph->addNode('a0', null, 'cluster0');
23
$graph->addNode('a1', null, 'cluster0');
24
$graph->addNode('a2', null, 'cluster0');
25
$graph->addNode('a3', null, 'cluster0');
26
$graph->addEdge(array('a0' => 'a1'));
27
$graph->addEdge(array('a1' => 'a2'));
28
$graph->addEdge(array('a2' => 'a3'));
29
 
30
// cluster1
31
$graph->addCluster('cluster1', 'process #2',
32
                   array('color' => 'blue'));
33
$graph->addNode('b0', null, 'cluster1');
34
$graph->addNode('b1', null, 'cluster1');
35
$graph->addNode('b2', null, 'cluster1');
36
$graph->addNode('b3', null, 'cluster1');
37
$graph->addEdge(array('b0' => 'b1'));
38
$graph->addEdge(array('b1' => 'b2'));
39
$graph->addEdge(array('b2' => 'b3'));
40
 
41
// Global
42
$graph->addNode('start', array('shape' => 'Mdiamond'));
43
$graph->addNode('end', array('shape' => 'Msquare'));
44
 
45
$graph->addEdge(array('start' => 'a0'));
46
$graph->addEdge(array('start' => 'b0'));
47
 
48
$graph->addEdge(array('a1' => 'b3'));
49
$graph->addEdge(array('b2' => 'a3'));
50
$graph->addEdge(array('a3' => 'a0'));
51
$graph->addEdge(array('a3' => 'end'));
52
$graph->addEdge(array('b3' => 'end'));
53
 
54
echo $graph->parse();
55
 
56
?>
57
--EXPECT--
58
digraph G {
59
    start [ shape=Mdiamond ];
60
    end [ shape=Msquare ];
61
    subgraph cluster0 {
62
        graph [ style=filled,color=lightgrey,label="process #1" ];
63
        a0;
64
        a1;
65
        a2;
66
        a3;
67
    }
68
    subgraph cluster1 {
69
        graph [ color=blue,label="process #2" ];
70
        b0;
71
        b1;
72
        b2;
73
        b3;
74
    }
75
    a0 -> a1;
76
    a1 -> a2;
77
    a1 -> b3;
78
    a2 -> a3;
79
    b0 -> b1;
80
    b1 -> b2;
81
    b2 -> b3;
82
    b2 -> a3;
83
    start -> a0;
84
    start -> b0;
85
    a3 -> a0;
86
    a3 -> end;
87
    b3 -> end;
88
}