NavigationNodeHelperTest::testActiveTree()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 26
Code Lines 22

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 22
dl 0
loc 26
rs 9.568
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
/*
4
 * This file is part of the core-bundle package.
5
 *
6
 * (c) 2018 WEBEWEB
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace WBW\Bundle\CoreBundle\Tests\Helper\Assets;
13
14
use Symfony\Component\HttpFoundation\Request;
15
use WBW\Bundle\CoreBundle\Helper\Assets\NavigationNodeHelper;
16
use WBW\Bundle\CoreBundle\Tests\AbstractTestCase;
17
use WBW\Bundle\CoreBundle\Tests\Fixtures\TestFixtures;
18
use WBW\Library\Symfony\Assets\Navigation\NavigationTree;
19
20
/**
21
 * Navigation node helper test.
22
 *
23
 * @author webeweb <https://github.com/webeweb>
24
 * @package WBW\Bundle\CoreBundle\Tests\Helper\Assets
25
 */
26
class NavigationNodeHelperTest extends AbstractTestCase {
27
28
    /**
29
     * Navigation tree.
30
     *
31
     * @var NavigationTree
32
     */
33
    private $tree;
34
35
    /**
36
     * {@inheritDoc}
37
     */
38
    protected function setUp(): void {
39
        parent::setUp();
40
41
        // Set a Navigation tree mock.
42
        $this->tree = TestFixtures::getNavigationTree();
43
    }
44
45
    /**
46
     * Test activeTree()
47
     *
48
     * @return void
49
     */
50
    public function testActiveTree(): void {
51
52
        NavigationNodeHelper::activeTree($this->tree, Request::create("https://github.com/webeweb/core-bundle"));
53
54
        $this->assertTrue($this->tree->getNodeAt(0)->getActive());
55
56
        $this->assertFalse($this->tree->getNodeAt(0)->getNodeAt(0)->getActive());
57
        $this->assertFalse($this->tree->getNodeAt(0)->getNodeAt(1)->getActive());
58
        $this->assertFalse($this->tree->getNodeAt(0)->getNodeAt(2)->getActive());
59
        $this->assertFalse($this->tree->getNodeAt(0)->getNodeAt(3)->getActive());
60
        $this->assertTrue($this->tree->getNodeAt(0)->getNodeAt(4)->getActive());
61
        $this->assertFalse($this->tree->getNodeAt(0)->getNodeAt(5)->getActive());
62
        $this->assertFalse($this->tree->getNodeAt(0)->getNodeAt(6)->getActive());
63
        $this->assertFalse($this->tree->getNodeAt(0)->getNodeAt(7)->getActive());
64
        $this->assertFalse($this->tree->getNodeAt(0)->getNodeAt(8)->getActive());
65
        $this->assertFalse($this->tree->getNodeAt(0)->getNodeAt(9)->getActive());
66
        $this->assertFalse($this->tree->getNodeAt(0)->getNodeAt(10)->getActive());
67
        $this->assertFalse($this->tree->getNodeAt(0)->getNodeAt(11)->getActive());
68
        $this->assertFalse($this->tree->getNodeAt(0)->getNodeAt(12)->getActive());
69
        $this->assertFalse($this->tree->getNodeAt(0)->getNodeAt(13)->getActive());
70
        $this->assertFalse($this->tree->getNodeAt(0)->getNodeAt(14)->getActive());
71
        $this->assertFalse($this->tree->getNodeAt(0)->getNodeAt(15)->getActive());
72
        $this->assertFalse($this->tree->getNodeAt(0)->getNodeAt(16)->getActive());
73
        $this->assertFalse($this->tree->getNodeAt(0)->getNodeAt(17)->getActive());
74
        $this->assertFalse($this->tree->getNodeAt(0)->getNodeAt(18)->getActive());
75
        $this->assertFalse($this->tree->getNodeAt(0)->getNodeAt(19)->getActive());
76
    }
77
78
    /**
79
     * Test getBreadcrumbs()
80
     *
81
     * @return void
82
     */
83
    public function testGetBreadcrumbs(): void {
84
85
        NavigationNodeHelper::activeTree($this->tree, Request::create("https://github.com/webeweb/core-bundle"));
86
87
        $res = NavigationNodeHelper::getBreadcrumbs($this->tree);
88
        $this->assertCount(2, $res);
89
90
        $this->assertEquals("GitHub", $res[0]->getLabel());
91
        $this->assertEquals("Core bundle", $res[1]->getLabel());
92
    }
93
}
94