mockApplication(); } public function testEncodeLabel() { $output = Menu::widget([ 'route' => 'test/test', 'params' => [], 'encodeLabels' => true, 'items' => [ [ 'encode' => false, 'label' => ' Users', 'url' => '#', ], [ 'encode' => true, 'label' => 'Authors & Publications', 'url' => '#', ], ] ]); $this->assertEqualsWithoutLE(<<
  • Users
  • Authors & Publications
  • HTML , $output); $output = Menu::widget([ 'route' => 'test/test', 'params' => [], 'encodeLabels' => false, 'items' => [ [ 'encode' => false, 'label' => ' Users', 'url' => '#', ], [ 'encode' => true, 'label' => 'Authors & Publications', 'url' => '#', ], ] ]); $this->assertEqualsWithoutLE(<<
  • Users
  • Authors & Publications
  • HTML , $output); } /** * @see https://github.com/yiisoft/yii2/issues/8064 */ public function testTagOption() { $output = Menu::widget([ 'route' => 'test/test', 'params' => [], 'encodeLabels' => true, 'options' => [ 'tag' => false, ], 'items' => [ [ 'label' => 'item1', 'url' => '#', 'options' => ['tag' => 'div'], ], [ 'label' => 'item2', 'url' => '#', 'options' => ['tag' => false], ], ] ]); $this->assertEqualsWithoutLE(<<item1 item2 HTML , $output); $output = Menu::widget([ 'route' => 'test/test', 'params' => [], 'encodeLabels' => true, 'options' => [ 'tag' => false, ], 'items' => [ [ 'label' => 'item1', 'url' => '#', ], [ 'label' => 'item2', 'url' => '#', ], ], 'itemOptions' => ['tag' => false] ]); $this->assertEqualsWithoutLE(<<item1 item2 HTML , $output); } }