2019-06-27 02:04:42 +00:00
|
|
|
<?php
|
|
|
|
|
2019-07-01 18:06:01 +00:00
|
|
|
namespace Tests\MediaWiki\Minerva\Menu\Entries;
|
2019-06-27 02:04:42 +00:00
|
|
|
|
2019-07-01 18:06:01 +00:00
|
|
|
use MediaWiki\Minerva\Menu\Entries\HomeMenuEntry;
|
2019-06-27 02:04:42 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @group MinervaNeue
|
2019-07-01 18:06:01 +00:00
|
|
|
* @coversDefaultClass \MediaWiki\Minerva\Menu\Entries\HomeMenuEntry
|
2019-06-27 02:04:42 +00:00
|
|
|
*/
|
|
|
|
class HomeMenuEntryTest extends \MediaWikiUnitTestCase {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @covers ::__construct
|
|
|
|
* @covers ::getName
|
|
|
|
* @covers ::getCSSClasses
|
|
|
|
* @covers ::getComponents
|
|
|
|
*/
|
|
|
|
public function testConstruct() {
|
|
|
|
$name = 'foo';
|
|
|
|
$text = 'bar';
|
|
|
|
$url = 'http://baz';
|
|
|
|
$entry = new HomeMenuEntry( $name, $text, $url );
|
|
|
|
$this->assertSame( $name, $entry->getName() );
|
|
|
|
$this->assertSame( [], $entry->getCSSClasses() );
|
|
|
|
$this->assertSame( [ [
|
|
|
|
'text' => $text,
|
|
|
|
'href' => $url,
|
|
|
|
'class' => 'mw-ui-icon mw-ui-icon-before mw-ui-icon-minerva-foo',
|
2019-08-08 21:43:04 +00:00
|
|
|
'data-event-name' => 'menu.foo'
|
2019-06-27 02:04:42 +00:00
|
|
|
] ], $entry->getComponents() );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @covers ::overrideCssClass
|
|
|
|
* @covers ::overrideText
|
|
|
|
* @covers ::getComponents
|
|
|
|
*/
|
|
|
|
public function testOverride() {
|
|
|
|
$entry = new HomeMenuEntry( 'foo', 'bar', 'http://baz' );
|
|
|
|
$component = current( $entry->getComponents() );
|
|
|
|
$this->assertSame( 'bar', $component['text'] );
|
|
|
|
$this->assertSame(
|
|
|
|
'mw-ui-icon mw-ui-icon-before mw-ui-icon-minerva-foo',
|
|
|
|
$component['class']
|
|
|
|
);
|
|
|
|
$entry->overrideText( 'blah' )
|
|
|
|
->overrideCssClass( 'classy' );
|
|
|
|
$component = current( $entry->getComponents() );
|
|
|
|
$this->assertSame( 'blah', $component['text'] );
|
|
|
|
$this->assertSame(
|
|
|
|
'classy',
|
|
|
|
$component['class']
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|