IG15019Test::testBuild()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
/**
4
 * @file
5
 * Grafizzi\Graph\Tests\IG15019Test: 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\Cluster;
28
use Grafizzi\Graph\Node;
29
30
require 'vendor/autoload.php';
31
32
/**
33
 * A recreation of Image_GraphViz bug_15019.phpt
34
 *
35
 * Image_GraphViz version author: Philippe Jausions <[email protected]>
36
 *
37
 * Bug 15019: "addCluster using attributes twice"
38
 *
39
 * Note 1: IG test does not actually test using attributes twice.
40
 * Note 2: IG test expects an abnormal result: attribute "0" being set to "".
41
 *   Since this is an incorrect behavior, Grafizzi does not reproduce it.
42
 */
43
class IG15019Test extends BaseGraphTest {
44
45
  public $expected = <<<EOT
46
strict digraph Bug {
47
  subgraph cluster_0 {
48
    fontcolor=black;
49
    style=filled;
50
    label=Cluster;
51
52
    "Node";
53
  } /* /subgraph cluster_0 */
54
} /* /digraph Bug */
55
56
EOT;
57
58
  public function setUp() : void {
59
    parent::setUpExtended('Bug', 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...
60
    $g = $this->Graph;
61
    $dic = $this->dic;
62
    $g->setDirected(true);
63
64
    $g->addChild($cluster0 = new Cluster($dic, 0, array(
65
      new Attribute($dic, 'fontcolor', 'black'),
66
      new Attribute($dic, 'style', 'filled'),
67
      new Attribute($dic, 'label', 'Cluster'),
68
    )));
69
    $cluster0->addChild($node = new Node($dic, 'Node'));
70
  }
71
72
  /**
73
   * Tests Graph->build()
74
   */
75
  public function testBuild() {
76
    $this->check($this->expected, "Image_GraphViz bug test 15019 passed.");
77
  }
78
79
  /**
80
   * @depends testBuild
81
   */
82
  public function testBuild2() {
83
    // 0 is the id of the cluster in setUp().
84
    $cluster0 = $this->Graph->getChildByName(0);
85
    $this->assertNotNull($cluster0, "Numbered cluster found in graph.");
86
    // Add the same attribute a second time.
87
    $cluster0->setAttribute(new Attribute($this->dic, 'style', 'filled'));
88
89
    $this->check($this->expected, "Image_GraphViz bug test 15019 redone passed.");
90
  }
91
}
92