Commit 01600bf6 by Carsten Brandt

added test case for menu widget

fixes #5080
parent 6230aa75
<?php
namespace yiiunit\framework\widgets;
use yii\widgets\Menu;
use yii\widgets\Spaceless;
/**
* @group widgets
*/
class MenuTest extends \yiiunit\TestCase
{
protected function setUp()
{
parent::setUp();
$this->mockApplication();
}
public function testEncodeLabel()
{
$output = Menu::widget([
'route' => 'test/test',
'params' => [],
'encodeLabels' => true,
'items' => [
[
'encode' => false,
'label' => '<span class="glyphicon glyphicon-user"></span> Users',
'url' => '#',
],
[
'encode' => true,
'label' => 'Authors & Publications',
'url' => '#',
],
]
]);
$this->assertEquals(<<<HTML
<ul><li><a href="#"><span class="glyphicon glyphicon-user"></span> Users</a></li>
<li><a href="#">Authors &amp; Publications</a></li></ul>
HTML
, $output);
$output = Menu::widget([
'route' => 'test/test',
'params' => [],
'encodeLabels' => false,
'items' => [
[
'encode' => false,
'label' => '<span class="glyphicon glyphicon-user"></span> Users',
'url' => '#',
],
[
'encode' => true,
'label' => 'Authors & Publications',
'url' => '#',
],
]
]);
$this->assertEquals(<<<HTML
<ul><li><a href="#"><span class="glyphicon glyphicon-user"></span> Users</a></li>
<li><a href="#">Authors &amp; Publications</a></li></ul>
HTML
, $output);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment