IG14Test   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 5
dl 0
loc 44
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 24 1
A testBuild() 0 13 1
1
<?php
2
3
/**
4
 * @file
5
 * Grafizzi\Graph\Tests\IG14Test: 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 test14.phpt
34
 *
35
 * Image_GraphViz version author: Philippe Jausions <[email protected]>
36
 *
37
 * Test 14: "Drawing of records (revisited)"
38
 *
39
 * Graph definition taken from GraphViz documentation
40
 */
41
class IG14Test extends BaseGraphTest {
42
43
  public function setUp() : void {
44
    // not strict by default.
45
    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...
46
    $g = $this->Graph;
47
    $dic = $this->dic;
48
    $g->setDirected(true);
49
50
    $recordShape = new Attribute($dic, 'shape', 'record');
51
    $g->addChild($struct1 = new Node($dic, 'struct1', array(
52
      $recordShape,
53
      new Attribute($dic, 'label', '<f0> left|<f1> middle|<f2> right'),
54
    )));
55
    $g->addChild($struct2 = new Node($dic, 'struct2', array(
56
      $recordShape,
57
      new Attribute($dic, 'label', '<f0> one|<f1> two'),
58
    )));
59
    $g->addChild($struct3 = new Node($dic, 'struct3', array(
60
      $recordShape,
61
      new Attribute($dic, 'label', "hello\nworld | { b |{c|<here> d|e}| f}| g | h"),
62
    )));
63
64
    $g->addChild(new Edge($dic, $struct1, $struct2, array(), 'f1', 'f0'));
65
    $g->addchild(new Edge($dic, $struct1, $struct3, array(), 'f1', 'here'));
66
  }
67
68
  /**
69
   * Tests Graph->build()
70
   */
71
  public function testBuild() {
72
    $expected = <<<'EOT'
73
digraph structs {
74
  struct1 [ shape=record, label="<f0> left|<f1> middle|<f2> right" ];
75
  struct2 [ shape=record, label="<f0> one|<f1> two" ];
76
  struct3 [ shape=record, label="hello\nworld | { b |{c|<here> d|e}| f}| g | h" ];
77
  struct1:f1 -> struct2:f0;
78
  struct1:f1 -> struct3:here;
79
} /* /digraph structs */
80
81
EOT;
82
    $this->check($expected, "Image_GraphViz test 14 passed.");
83
  }
84
}
85