2021-07-09 17:53:24 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace yiiunit\extensions\bootstrap5;
|
|
|
|
|
|
|
|
use yii\bootstrap5\Breadcrumbs;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @group bootstrap5
|
|
|
|
*/
|
|
|
|
class BreadcrumbsTest extends TestCase
|
|
|
|
{
|
|
|
|
public function testRender()
|
|
|
|
{
|
|
|
|
Breadcrumbs::$counter = 0;
|
|
|
|
$out = Breadcrumbs::widget([
|
|
|
|
'homeLink' => ['label' => 'Home', 'url' => '#'],
|
|
|
|
'links' => [
|
|
|
|
['label' => 'Library', 'url' => '#'],
|
|
|
|
['label' => 'Data']
|
|
|
|
]
|
|
|
|
]);
|
|
|
|
|
|
|
|
$expected = <<<HTML
|
|
|
|
<nav aria-label="breadcrumb"><ol id="w0" class="breadcrumb"><li class="breadcrumb-item"><a href="#">Home</a></li>
|
|
|
|
<li class="breadcrumb-item"><a href="#">Library</a></li>
|
|
|
|
<li class="breadcrumb-item active" aria-current="page">Data</li>
|
|
|
|
</ol></nav>
|
|
|
|
HTML;
|
2022-01-05 16:49:44 +08:00
|
|
|
$this->assertEqualsWithoutLE($expected, $out);
|
|
|
|
}
|
2021-07-09 17:53:24 +08:00
|
|
|
|
2022-01-05 16:49:44 +08:00
|
|
|
public function testRenderWithoutHomeLink()
|
|
|
|
{
|
|
|
|
Breadcrumbs::$counter = 0;
|
|
|
|
$out = Breadcrumbs::widget([
|
|
|
|
'homeLink' => false,
|
|
|
|
'links' => [
|
|
|
|
['label' => 'Library', 'url' => '#'],
|
|
|
|
['label' => 'Data']
|
|
|
|
]
|
|
|
|
]);
|
|
|
|
|
|
|
|
$expected = <<<HTML
|
|
|
|
<nav aria-label="breadcrumb"><ol id="w0" class="breadcrumb"><li class="breadcrumb-item"><a href="#">Library</a></li>
|
|
|
|
<li class="breadcrumb-item active" aria-current="page">Data</li>
|
|
|
|
</ol></nav>
|
|
|
|
HTML;
|
2021-07-09 17:53:24 +08:00
|
|
|
|
|
|
|
$this->assertEqualsWithoutLE($expected, $out);
|
|
|
|
}
|
|
|
|
}
|