IG02Test::testBuild()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 30

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 30
rs 9.44
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
/**
4
 * @file
5
 * Grafizzi\Graph\Tests\IG02Test: a component of the Grafizzi library.
6
 *
7
 * (c) 2012 Frédéric G. MARAND <[email protected]>
8
 *
9
 * Grafizzi is free software: you can redistribute it and/or modify it under the
10
 * terms of the GNU Lesser General Public License as published by the Free
11
 * Software Foundation, either version 3 of the License, or (at your option) any
12
 * later version.
13
 *
14
 * Grafizzi is distributed in the hope that it will be useful, but WITHOUT ANY
15
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
16
 * A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
17
 * details.
18
 *
19
 * You should have received a copy of the GNU Lesser General Public License
20
 * along with Grafizzi, in the COPYING.LESSER.txt file.  If not, see
21
 * <http://www.gnu.org/licenses/>
22
 */
23
24
namespace Grafizzi\Graph\Tests;
25
26
use Grafizzi\Graph\Attribute;
27
use Grafizzi\Graph\Edge;
28
use Grafizzi\Graph\Node;
29
30
require 'vendor/autoload.php';
31
32
/**
33
 * A recreation of Image_GraphViz test2.phpt
34
 *
35
 * Image_GraphViz version author: Philippe Jausions <[email protected]>
36
 *
37
 * Test 2: "HTML-like labels"
38
 */
39
class IG02Test extends BaseGraphTest {
40
41
  public function setUp() : void {
42
    parent::setUpExtended('structs');
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (setUpExtended() instead of setUp()). Are you sure this is correct? If so, you might want to change this to $this->setUpExtended().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
43
    $this->Graph->setDirected(true);
44
    $graph = &$this->Graph;
45
    $dic = $this->dic;
46
47
    $plainText = new Attribute($dic, 'shape', 'plaintext');
48
49
    $graph->addChild($nStruct1 = new Node($dic, 'struct1', array(
50
      $plainText,
51
      new Attribute($dic, 'label', '<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0">
52
   <TR><TD>left</TD><TD PORT="f1">mid dle</TD><TD PORT="f2">right</TD></TR>
53
</TABLE>')
54
    )));
55
56
    $graph->addChild($nStruct2 = new Node($dic, 'struct2', array(
57
      $plainText,
58
      new Attribute($dic, 'label', '<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0">
59
   <TR><TD PORT="f0">one</TD><TD>two</TD></TR>
60
</TABLE>'))));
61
62
    $graph->addChild($nStruct3 = new Node($dic, 'struct3', array(
63
      $plainText,
64
      new Attribute($dic, 'label', '<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0" CELLPADDING="4">
65
   <TR>
66
      <TD ROWSPAN="3">hello<BR/>world</TD>
67
      <TD COLSPAN="3">b</TD>
68
      <TD ROWSPAN="3">g</TD>
69
      <TD ROWSPAN="3">h</TD>
70
   </TR>
71
   <TR>
72
      <TD>c</TD><TD PORT="here">d</TD><TD>e</TD>
73
   </TR>
74
   <TR>
75
      <TD COLSPAN="3">f</TD>
76
   </TR>
77
</TABLE>'),
78
    )));
79
80
    $emptyTitle = new Attribute($dic, 'title', '');
81
    $graph->addChild($edge12 = new Edge($dic, $nStruct1, $nStruct2,
82
      array($emptyTitle), 'f1', 'f0'));
83
    $graph->addChild($edge13 = new Edge($dic, $nStruct1, $nStruct3,
84
      array($emptyTitle), 'f2', 'here'));
85
  }
86
87
  /**
88
   * Tests Graph->build()
89
   */
90
  public function testBuild() {
91
    $expected = <<<EOT
92
digraph structs {
93
  struct1 [ shape=plaintext, label=<<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0">
94
   <TR><TD>left</TD><TD PORT="f1">mid dle</TD><TD PORT="f2">right</TD></TR>
95
</TABLE>> ];
96
  struct2 [ shape=plaintext, label=<<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0">
97
   <TR><TD PORT="f0">one</TD><TD>two</TD></TR>
98
</TABLE>> ];
99
  struct3 [ shape=plaintext, label=<<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0" CELLPADDING="4">
100
   <TR>
101
      <TD ROWSPAN="3">hello<BR/>world</TD>
102
      <TD COLSPAN="3">b</TD>
103
      <TD ROWSPAN="3">g</TD>
104
      <TD ROWSPAN="3">h</TD>
105
   </TR>
106
   <TR>
107
      <TD>c</TD><TD PORT="here">d</TD><TD>e</TD>
108
   </TR>
109
   <TR>
110
      <TD COLSPAN="3">f</TD>
111
   </TR>
112
</TABLE>> ];
113
  struct1:f1 -> struct2:f0;
114
  struct1:f2 -> struct3:here;
115
} /* /digraph structs */
116
117
EOT;
118
    $this->check($expected, "Image_GraphViz test 2 passed.");
119
  }
120
}
121