BreadcrumbTest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 3
c 1
b 0
f 1
lcom 1
cbo 2
dl 0
loc 47
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
B testCreation() 0 25 1
A testActivate() 0 9 1
A testSet() 0 8 1
1
<?php
2
/*
3
 * This file is part of the 2martens Web Platform.
4
 *
5
 * (c) Jim Martens <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace TwoMartens\Bundle\CoreBundle\Tests\Model;
12
13
use TwoMartens\Bundle\CoreBundle\Model\Breadcrumb;
14
15
/**
16
 * Tests the Breadcrumb class.
17
 *
18
 * @author Jim Martens <[email protected]>
19
 */
20
class BreadcrumbTest extends \PHPUnit_Framework_TestCase
21
{
22
    public function testCreation()
23
    {
24
        $breadcrumb = new Breadcrumb('acp.home', 'Dashboard');
25
        $this->assertFalse($breadcrumb->isActive());
26
        $this->assertEquals('acp.home', $breadcrumb->getPath());
27
        $this->assertEquals('Dashboard', $breadcrumb->getTitle());
28
29
        // even the empty string should work
30
        $breadcrumb = new Breadcrumb('', '');
31
        $this->assertFalse($breadcrumb->isActive());
32
        $this->assertEquals('', $breadcrumb->getPath());
33
        $this->assertEquals('', $breadcrumb->getTitle());
34
35
        // leading and trailing spaces should not make a difference
36
        $breadcrumb = new Breadcrumb('     133 7    ', '    1337       ');
37
        $this->assertFalse($breadcrumb->isActive());
38
        $this->assertEquals('133 7', $breadcrumb->getPath());
39
        $this->assertEquals('1337', $breadcrumb->getTitle());
40
41
        // the strings should be taken as is (expect for leading/trailing spaces); no operations should be performed
42
        $breadcrumb = new Breadcrumb('     133+7    ', '    1337       ');
43
        $this->assertFalse($breadcrumb->isActive());
44
        $this->assertEquals('133+7', $breadcrumb->getPath());
45
        $this->assertEquals('1337', $breadcrumb->getTitle());
46
    }
47
48
    public function testActivate()
49
    {
50
        $breadcrumb = new Breadcrumb('acp.home', 'Dashboard');
51
        $this->assertFalse($breadcrumb->isActive());
52
        $breadcrumb->activate();
53
        $this->assertTrue($breadcrumb->isActive());
54
        $breadcrumb->deactivate();
55
        $this->assertFalse($breadcrumb->isActive());
56
    }
57
58
    public function testSet()
59
    {
60
        $breadcrumb = new Breadcrumb('acp.schwachsinn', 'Bastille');
61
        $breadcrumb->setTitle('Alea-Iacta-Est');
62
        $this->assertEquals('Alea-Iacta-Est', $breadcrumb->getTitle());
63
        $breadcrumb->setPath('Harz');
64
        $this->assertEquals('Harz', $breadcrumb->getPath());
65
    }
66
}
67