GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

itCreatesTwoLevelsEvenIfNoArtifactIdsAreGiven()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 6
rs 9.4285
cc 1
eloc 4
nc 1
nop 0
1
<?php
2
3
/**
4
 * Copyright (c) Enalean, 2012. All Rights Reserved.
5
 *
6
 * This file is a part of Tuleap.
7
 *
8
 * Tuleap is free software; you can redistribute it and/or modify
9
 * it under the terms of the GNU General Public License as published by
10
 * the Free Software Foundation; either version 2 of the License, or
11
 * (at your option) any later version.
12
 *
13
 * Tuleap is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
 * GNU General Public License for more details.
17
 *
18
 * You should have received a copy of the GNU General Public License
19
 * along with Tuleap. If not, see <http://www.gnu.org/licenses/>.
20
 */
21
22
require_once dirname(__FILE__) .'/bootstrap.php';
23
require_once 'common/TreeNode/TreeNodeMapper.class.php';
24
25
class Cardwall_ArtifactNodeTreeProvider4Tests extends Cardwall_RendererBoardBuilder {
26
    public function getCards(array $artifact_ids, $swimline_id) {
27
        return parent::getCards($artifact_ids, $swimline_id);
0 ignored issues
show
Bug introduced by
The method getCards() does not exist on Cardwall_RendererBoardBuilder. Did you maybe mean getCardsPresenters()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
28
    }
29
30
    public function wrapInAThreeLevelArtifactTree(array $cards, $swimline_id) {
31
        return parent::wrapInAThreeLevelArtifactTree($cards, $swimline_id);
32
    }
33
}
34
35
class Cardwall_ArtifactNodeTreeProviderTest extends TuleapTestCase {
36
37
    public function setUp() {
38
        parent::setUp();
39
        $this->node_factory     = mock('Cardwall_CardInCellPresenterNodeFactory');
40
        $this->artifact_factory = mock('Tracker_ArtifactFactory');
41
        $this->provider = new Cardwall_ArtifactNodeTreeProvider4Tests($this->node_factory, $this->artifact_factory);
0 ignored issues
show
Bug introduced by
The call to Cardwall_ArtifactNodeTre...er4Tests::__construct() misses a required argument $swimline_factory.

This check looks for function calls that miss required arguments.

Loading history...
42
    }
43
44
    public function itCreatesTwoLevelsEvenIfNoArtifactIdsAreGiven() {
45
        $root_node = $this->provider->wrapInAThreeLevelArtifactTree(array(), 'whatever');
46
47
        $this->assertTrue($root_node->hasChildren());
48
        $this->assertFalse($root_node->getChild(0)->hasChildren());
49
    }
50
51
    public function itHasASwimlineId() {
52
        $root_node = $this->provider->wrapInAThreeLevelArtifactTree(array(), 'Dat Id');
53
54
        $this->assertEqual($root_node->getChild(0)->getId(), 'Dat Id');
55
    }
56
57
    public function itCreatesAThreeLevelTreeBecauseItMustLookLikeTheNodeTreeFromAMilestone() {
58
        $artifact4 = aMockArtifact()->withId(4)->build();
59
60
        $root_node = $this->provider->wrapInAThreeLevelArtifactTree(array(new ArtifactNode($artifact4)), 'whatever');
61
62
        $this->assertTrue($root_node->hasChildren());
63
        $this->assertTrue($root_node->getChild(0)->hasChildren());
64
        $cards = $root_node->getChild(0)->getChildren();
65
66
        $this->assertEqual(1, count($cards));
67
        $card = $cards[0];
68
        $id   = $card->getId();
69
        $this->assertEqual($id, 4);
70
        $artifact = $card->getArtifact();
71
        $this->assertIdentical($artifact, $artifact4);
72
73
    }
74
75
    public function itCreatesAnArtifactNodeForEveryArtifactId() {
76
        $swmiline_id = 7;
77
78
        $artifact4 = aMockArtifact()->withId(4)->build();
79
        $artifact5 = aMockArtifact()->withId(5)->build();
80
        $artifact6 = aMockArtifact()->withId(6)->build();
81
82
        $node4 = new Cardwall_CardInCellPresenterNode(new Cardwall_CardInCellPresenter(new Cardwall_CardPresenter($artifact4, mock('Cardwall_CardFields'), '*', mock('Cardwall_UserPreferences_UserPreferencesDisplayUser'), 0, array()), 4));
83
        $node5 = new Cardwall_CardInCellPresenterNode(new Cardwall_CardInCellPresenter(new Cardwall_CardPresenter($artifact5, mock('Cardwall_CardFields'), '*', mock('Cardwall_UserPreferences_UserPreferencesDisplayUser'), 0, array()), 5));
84
        $node6 = new Cardwall_CardInCellPresenterNode(new Cardwall_CardInCellPresenter(new Cardwall_CardPresenter($artifact6, mock('Cardwall_CardFields'), '*', mock('Cardwall_UserPreferences_UserPreferencesDisplayUser'), 0, array()), 6));
85
86
        stub($this->artifact_factory)->getArtifactById(4)->returns($artifact4);
87
        stub($this->artifact_factory)->getArtifactById(5)->returns($artifact5);
88
        stub($this->artifact_factory)->getArtifactById(6)->returns($artifact6);
89
90
        stub($this->node_factory)->getCardInCellPresenterNode($artifact4, $swmiline_id)->returns($node4);
91
        stub($this->node_factory)->getCardInCellPresenterNode($artifact5, $swmiline_id)->returns($node5);
92
        stub($this->node_factory)->getCardInCellPresenterNode($artifact6, $swmiline_id)->returns($node6);
93
94
        $cards = $this->provider->getCards(array(4, 5, 6), $swmiline_id);
95
96
        $this->assertEqual(3, count($cards));
97
        foreach ($cards as $card) {
98
            $id = $card->getId();
99
            $this->assertBetweenClosedInterval($id, 4, 6);
100
            $artifact = $card->getArtifact();
101
            $this->assertBetweenClosedInterval($artifact->getId(), 4, 6);
102
            $this->assertIsA($artifact, 'Tracker_Artifact');
103
        }
104
105
    }
106
107
}
108
?>
109