mirror of
https://github.com/yiisoft/yii2.git
synced 2025-08-18 17:21:26 +08:00
71 lines
1.8 KiB
PHP
71 lines
1.8 KiB
PHP
<?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 & 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 & Publications</a></li></ul>
|
|
HTML
|
|
, $output);
|
|
|
|
}
|
|
}
|