IG05Test::testBuild()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 15
rs 9.7666
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
/**
4
 * @file
5
 * Grafizzi\Graph\Tests\IG05Test: 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 test5.phpt
34
 *
35
 * Image_GraphViz version author: Philippe Jausions <[email protected]>
36
 *
37
 * Test 5: "Unit test for Graph with polygonal shape"
38
 *
39
 * "Graph definition taken from GraphViz documentation"
40
 */
41
class IG05Test extends BaseGraphTest {
42
43
  public function setUp() : void {
44
    parent::setUpExtended();
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...
45
    $this->Graph->setDirected(true);
46
    $this->Graph->addChild($a = new Node($this->dic, 'a', array(
47
      new Attribute($this->dic, 'shape', 'polygon'),
48
      new Attribute($this->dic, 'sides', 5),
49
      new Attribute($this->dic, 'peripheries', 3),
50
      new Attribute($this->dic, 'color', 'lightblue'),
51
      new Attribute($this->dic, 'style', 'filled'),
52
    )));
53
54
    // TODO : support automatic (undeclared) nodes in edges, to remove $b
55
    $this->Graph->addChild($b = new Node($this->dic, 'b', Node::implicit()));
56
    $this->Graph->addChild($c = new Node($this->dic, 'c', array(
57
      new Attribute($this->dic, 'shape', 'polygon'),
58
      new Attribute($this->dic, 'sides', 4),
59
      new Attribute($this->dic, 'skew', .4),
60
      new Attribute($this->dic, 'label', 'hello world'),
61
    )));
62
    $this->Graph->addChild($d = new Node($this->dic, 'd', array(
63
      new Attribute($this->dic, 'shape', 'invtriangle'),
64
    )));
65
    $this->Graph->addChild($e = new Node($this->dic, 'e', array(
66
      new Attribute($this->dic, 'shape', 'polygon'),
67
      new Attribute($this->dic, 'sides', 4),
68
      new Attribute($this->dic, 'distortion', .7),
69
    )));
70
    $this->Graph->addChild(new Edge($this->dic, $a, $b));
71
    $this->Graph->addChild(new Edge($this->dic, $b, $c));
72
    $this->Graph->addChild(new Edge($this->dic, $b, $d));
73
74
  }
75
76
  /**
77
   * Tests Graph->build()
78
   */
79
  public function testBuild() {
80
    $expected = <<<EOT
81
digraph G {
82
  a [ shape=polygon, sides=5, peripheries=3, color=lightblue, style=filled ];
83
  c [ shape=polygon, sides=4, skew=0.4, label="hello world" ];
84
  d [ shape=invtriangle ];
85
  e [ shape=polygon, sides=4, distortion=0.7 ];
86
  a -> b;
87
  b -> c;
88
  b -> d;
89
} /* /digraph G */
90
91
EOT;
92
    $this->check($expected, "Image_GraphViz test 5 passed.");
93
  }
94
}
95