IG15943Test   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 71
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 6

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 34 1
A testBuild() 0 30 1
1
<?php
2
3
/**
4
 * @file
5
 * Grafizzi\Graph\Tests\IG15943Test: 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
27
use Grafizzi\Graph\Attribute;
28
use Grafizzi\Graph\Cluster;
29
use Grafizzi\Graph\Edge;
30
use Grafizzi\Graph\Node;
31
32
require 'vendor/autoload.php';
33
34
/**
35
 * A recreation of Image_GraphViz test15943.phpt
36
 *
37
 * Image_GraphViz version author: Philippe Jausions <[email protected]>
38
 *
39
 * Test for bug #15943: "Nested subgraphs"
40
 */
41
class IG15943Test extends BaseGraphTest {
42
43
  public function setUp() : void {
44
    // not strict by default.
45
    parent::setUpExtended('G', array('strict' => true));
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
    $nullTitle = array(new Attribute($dic, 'title', null));
51
52
    $g->addChild($node5 = new Node($dic, 'node5'));
53
    $g->addChild($clusterA = new Cluster($dic, 'A'));
54
    $clusterA->addChild($node0 = new Node($dic, 'node0', $nullTitle));
55
    $clusterA->addChild($node1 = new Node($dic, 'node1', $nullTitle));
56
    $clusterA->addChild($clusterB = new Cluster($dic, 'B', array(
57
      new Attribute($dic, 'label', 'Cluster B'),
58
    )));
59
60
    $clusterB->addChild($node2 = new Node($dic, 'node2', array(
61
      new Attribute($dic, 'color', 'blue'),
62
    )));
63
    $clusterB->addChild($node3 = new Node($dic, 'node3', $nullTitle));
64
65
    $clusterA->addChild($clusterC = new Cluster($dic, 'C', $nullTitle));
66
    $clusterB->addChild($clusterD = new Cluster($dic, 'D', $nullTitle));
67
68
    $clusterC->addChild($node4 = new Node($dic, 'node4', $nullTitle));
69
    $clusterD->addChild($node6 = new Node($dic, 'node6', $nullTitle));
70
71
    $g->addChild(new Edge($dic, $node0, $node1));
72
    $g->addChild(new Edge($dic, $node0, $node4));
73
    $g->addChild(new Edge($dic, $node2, $node3));
74
    $g->addChild(new Edge($dic, $node4, $node5));
75
    $g->addChild(new Edge($dic, $node5, $node6));
76
  }
77
78
  /**
79
   * Tests Graph->build()
80
   */
81
  public function testBuild() {
82
    $expected = <<<'EOT'
83
strict digraph G {
84
  node5;
85
  subgraph cluster_A {
86
    node0;
87
    node1;
88
    subgraph cluster_B {
89
      label="Cluster B";
90
91
      node2 [ color=blue ];
92
      node3;
93
      subgraph cluster_D {
94
        node6;
95
      } /* /subgraph cluster_D */
96
    } /* /subgraph cluster_B */
97
    subgraph cluster_C {
98
      node4;
99
    } /* /subgraph cluster_C */
100
  } /* /subgraph cluster_A */
101
  node0 -> node1;
102
  node0 -> node4;
103
  node2 -> node3;
104
  node4 -> node5;
105
  node5 -> node6;
106
} /* /digraph G */
107
108
EOT;
109
    $this->check($expected, "Image_GraphViz test 15943 passed.");
110
  }
111
}
112