Skip to content

Commit ddf42fe

Browse files
author
Mikaël Capelle
committed
Add test class for breadcrumbs and navbar.
1 parent 49238f7 commit ddf42fe

File tree

2 files changed

+106
-0
lines changed

2 files changed

+106
-0
lines changed
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
<?php
2+
3+
namespace Bootstrap\Test\TestCase\View\Helper;
4+
5+
use Bootstrap\View\Helper\BootstrapBreadcrumbsHelper;
6+
use Cake\TestSuite\TestCase;
7+
use Cake\View\View;
8+
9+
class BootstrapBreadcrumbsHelperTest extends TestCase {
10+
11+
/**
12+
* Instance of the BoostrapBreadcrumbsHelper.
13+
*
14+
* @var BootstrapBreadcrumbsHelper
15+
*/
16+
public $breadcrumbs;
17+
18+
/**
19+
* Setup
20+
*
21+
* @return void
22+
*/
23+
public function setUp() {
24+
parent::setUp();
25+
$view = new View();
26+
$this->breadcrumbs = new BootstrapBreadcrumbsHelper($view);
27+
}
28+
29+
30+
/**
31+
* Tests the render method
32+
*
33+
* @return void
34+
*/
35+
public function testRender()
36+
{
37+
$this->assertSame('', $this->breadcrumbs->render());
38+
$this->breadcrumbs
39+
->add('Home', '/', ['class' => 'first', 'innerAttrs' => ['data-foo' => 'bar']])
40+
->add('Some text', ['controller' => 'tests_apps', 'action' => 'some_method'])
41+
->add('Final crumb', null, ['class' => 'final',
42+
'innerAttrs' => ['class' => 'final-link']]);
43+
$result = $this->breadcrumbs->render(
44+
['data-stuff' => 'foo and bar']
45+
);
46+
$expected = [
47+
['ol' => [
48+
'class' => 'breadcrumb',
49+
'data-stuff' => 'foo and bar'
50+
]],
51+
['li' => ['class' => 'first']],
52+
['a' => ['href' => '/', 'data-foo' => 'bar']],
53+
'Home',
54+
'/a',
55+
'/li',
56+
['li' => []],
57+
['a' => ['href' => '/some_alias']],
58+
'Some text',
59+
'/a',
60+
'/li',
61+
['li' => ['class' => 'active final']],
62+
'Final crumb',
63+
'/li',
64+
'/ol'
65+
];
66+
$this->assertHtml($expected, $result);
67+
}
68+
69+
};
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
3+
namespace Bootstrap\Test\TestCase\View\Helper;
4+
5+
use Bootstrap\View\Helper\BootstrapNavbarHelper;
6+
use Cake\TestSuite\TestCase;
7+
use Cake\View\View;
8+
9+
class BootstrapNavbarHelperTest extends TestCase {
10+
11+
/**
12+
* Setup
13+
*
14+
* @return void
15+
*/
16+
public function setUp() {
17+
parent::setUp();
18+
$this->View = new View();
19+
$this->Navbar = new BootstrapNavbarHelper($this->View);
20+
}
21+
22+
/**
23+
* Tear Down
24+
*
25+
* @return void
26+
*/
27+
public function tearDown() {
28+
parent::tearDown();
29+
unset($this->Navbar);
30+
unset($this->View);
31+
}
32+
33+
public function testCreate() {
34+
35+
}
36+
37+
};

0 commit comments

Comments
 (0)