3 use MediaWiki\MainConfigNames
;
4 use MediaWiki\Title\Title
;
5 use Wikimedia\TestingAccessWrapper
;
7 // phpcs:ignore MediaWiki.Files.ClassMatchesFilename.NotMatch
8 class SkinQuickTemplateTest
extends QuickTemplate
{
9 public function execute() {
14 * @covers \SkinTemplate
18 * @author Bene* < benestar.wikimedia@gmail.com >
20 class SkinTemplateTest
extends MediaWikiIntegrationTestCase
{
22 * @dataProvider makeListItemProvider
24 public function testMakeListItem( $expected, $key, array $item, array $options, $message ) {
25 $template = $this->getMockForAbstractClass( BaseTemplate
::class );
26 $template->set( 'skin', new SkinFallback( [
28 'templateDirectory' => __DIR__
,
33 $template->makeListItem( $key, $item, $options ),
38 public static function makeListItemProvider() {
41 '<li class="class mw-list-item" title="itemtitle"><a href="url" title="title">text</a></li>',
45 'itemtitle' => 'itemtitle',
51 'Test makeListItem with normal values'
56 public static function provideGetFooterIcons() {
61 MainConfigNames
::FooterIcons
=> [],
69 MainConfigNames
::FooterIcons
=> [
72 'src' => '/w/resources/assets/poweredby_mediawiki_88x31.png',
73 'url' => 'https://www.mediawiki.org/',
74 'alt' => 'Powered by MediaWiki',
75 'srcset' => '/w/resources/assets/poweredby_mediawiki_132x47.png 1.5x,' .
76 ' /w/resources/assets/poweredby_mediawiki_176x62.png 2x',
84 'src' => '/w/resources/assets/poweredby_mediawiki_88x31.png',
85 'url' => 'https://www.mediawiki.org/',
86 'alt' => 'Powered by MediaWiki',
87 'srcset' => '/w/resources/assets/poweredby_mediawiki_132x47.png 1.5x,' .
88 ' /w/resources/assets/poweredby_mediawiki_176x62.png 2x',
94 'Width and height are hardcoded if not provided'
99 MainConfigNames
::FooterIcons
=> [
106 'Empty arrays are filtered out'
111 MainConfigNames
::FooterIcons
=> [
114 'alt' => 'Wikimedia Foundation',
115 'url' => 'https://wikimediafoundation.org'
121 'Icons with no icon are filtered out'
127 * @dataProvider provideGetFooterIcons
129 public function testGetFooterIcons( $globals, $expected, $msg ) {
130 $this->overrideConfigValues( $globals );
131 $wrapper = TestingAccessWrapper
::newFromObject( new SkinTemplate() );
132 $icons = $wrapper->getFooterIcons();
134 $this->assertEquals( $expected, $icons, $msg );
138 * @dataProvider provideContentNavigation
139 * @param array $contentNavigation
140 * @param array $expected
142 public function testInjectLegacyMenusIntoPersonalTools(
143 array $contentNavigation,
146 $wrapper = TestingAccessWrapper
::newFromObject( new SkinTemplate() );
150 $wrapper->injectLegacyMenusIntoPersonalTools( $contentNavigation )
154 public static function provideContentNavigation(): array {
156 'No userpage set' => [
157 'contentNavigation' => [
159 'notification 1' => []
173 'userpage set, no notifications' => [
174 'contentNavigation' => [
175 'notifications' => [],
190 'userpage set, notification defined' => [
191 'contentNavigation' => [
193 'notification 1' => []
205 'notification 1' => [],
210 'userpage set, notification defined, user interface preferences set' => [
211 'contentNavigation' => [
213 'notification 1' => []
221 'user-interface-preferences' => [
229 'notification 1' => [],
234 'no userpage, no notifications, no user-interface-preferences' => [
235 'contentNavigation' => [
251 public function testGenerateHTML() {
252 $wrapper = TestingAccessWrapper
::newFromObject(
253 new SkinTemplate( [ 'template' => 'SkinQuickTemplateTest', 'name' => 'test' ] )
256 $wrapper->getContext()->setTitle( Title
::makeTitle( NS_MAIN
, 'PrepareQuickTemplateTest' ) );
257 $tpl = $wrapper->prepareQuickTemplate();
258 $contentNav = $tpl->get( 'content_navigation' );
260 $this->assertEquals( [ 'namespaces', 'views', 'actions', 'variants' ], array_keys( $contentNav ) );