|
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
|
|
|
|