2017-07-12 15:12:40 +00:00
|
|
|
<?php
|
|
|
|
|
2022-05-03 18:11:54 +00:00
|
|
|
namespace MediaWiki\Minerva;
|
2017-07-12 15:12:40 +00:00
|
|
|
|
2024-05-19 12:45:56 +00:00
|
|
|
use MediaWiki\Context\RequestContext;
|
2022-03-04 16:40:54 +00:00
|
|
|
use MediaWiki\Minerva\Skins\SkinMinerva;
|
2024-01-06 15:31:38 +00:00
|
|
|
use MediaWiki\Output\OutputPage;
|
2023-08-19 04:23:00 +00:00
|
|
|
use MediaWiki\Title\Title;
|
2021-10-11 22:53:10 +00:00
|
|
|
use MediaWikiIntegrationTestCase;
|
2017-07-12 15:12:40 +00:00
|
|
|
use Wikimedia\TestingAccessWrapper;
|
|
|
|
|
|
|
|
/**
|
2022-03-04 16:40:54 +00:00
|
|
|
* @coversDefaultClass \MediaWiki\Minerva\Skins\SkinMinerva
|
2017-07-14 23:56:16 +00:00
|
|
|
* @group MinervaNeue
|
2017-07-12 15:12:40 +00:00
|
|
|
*/
|
2021-10-11 22:53:10 +00:00
|
|
|
class SkinMinervaTest extends MediaWikiIntegrationTestCase {
|
2023-08-01 00:12:59 +00:00
|
|
|
private const ATTRIBUTE_NOTIFICATION_HREF = [
|
|
|
|
'key' => 'href',
|
|
|
|
'value' => '/wiki/Special:Notifications',
|
|
|
|
];
|
|
|
|
private const ATTRIBUTE_NOTIFICATION_DATA_EVENT_NAME = [
|
|
|
|
'key' => 'data-event-name',
|
|
|
|
'value' => 'ui.notifications',
|
|
|
|
];
|
|
|
|
|
|
|
|
private const ATTRIBUTE_NOTIFICATION_DATA_COUNTER_TEXT = [
|
|
|
|
'key' => 'data-counter-text',
|
|
|
|
'value' => "13",
|
|
|
|
];
|
|
|
|
private const ATTRIBUTE_NOTIFICATION_DATA_COUNTER_NUM = [
|
|
|
|
'key' => 'data-counter-num',
|
|
|
|
'value' => 13,
|
|
|
|
];
|
|
|
|
private const ATTRIBUTE_NOTIFICATION_TITLE = [
|
|
|
|
'key' => 'title',
|
|
|
|
'value' => "Your alerts",
|
|
|
|
];
|
|
|
|
|
2024-02-29 20:35:21 +00:00
|
|
|
private function newSkinMinerva() {
|
|
|
|
$services = $this->getServiceContainer();
|
|
|
|
return new SkinMinerva(
|
|
|
|
$services->getGenderCache(),
|
|
|
|
$services->getLinkRenderer(),
|
2024-03-24 09:01:40 +00:00
|
|
|
$services->getService( 'Minerva.LanguagesHelper' ),
|
2024-03-24 15:08:11 +00:00
|
|
|
$services->getService( 'Minerva.Menu.Definitions' ),
|
2024-05-19 12:30:25 +00:00
|
|
|
$services->getService( 'Minerva.Menu.PageActions' ),
|
2024-03-23 19:16:47 +00:00
|
|
|
$services->getService( 'Minerva.Permissions' ),
|
2024-03-23 17:20:57 +00:00
|
|
|
$services->getService( 'Minerva.SkinOptions' ),
|
2024-03-24 10:49:33 +00:00
|
|
|
$services->getService( 'Minerva.SkinUserPageHelper' ),
|
2024-02-29 20:35:21 +00:00
|
|
|
$services->getNamespaceInfo(),
|
|
|
|
$services->getRevisionLookup(),
|
2024-03-25 09:54:20 +00:00
|
|
|
$services->getUserIdentityUtils(),
|
2024-02-29 20:35:21 +00:00
|
|
|
$services->getUserOptionsManager()
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2021-01-15 20:57:04 +00:00
|
|
|
/**
|
|
|
|
* @param array $options
|
|
|
|
*/
|
2019-04-10 21:43:50 +00:00
|
|
|
private function overrideSkinOptions( $options ) {
|
2024-03-03 13:31:09 +00:00
|
|
|
$services = $this->getServiceContainer();
|
|
|
|
$mockOptions = new SkinOptions(
|
2024-03-24 10:49:33 +00:00
|
|
|
$services->getHookContainer(),
|
|
|
|
$services->getService( 'Minerva.SkinUserPageHelper' )
|
2024-03-03 13:31:09 +00:00
|
|
|
);
|
2019-04-10 21:43:50 +00:00
|
|
|
$mockOptions->setMultiple( $options );
|
|
|
|
$this->setService( 'Minerva.SkinOptions', $mockOptions );
|
2017-07-12 15:12:40 +00:00
|
|
|
}
|
|
|
|
|
2024-01-02 21:38:55 +00:00
|
|
|
public static function provideHasPageActions() {
|
|
|
|
return [
|
|
|
|
[ NS_MAIN, 'test', 'view', true ],
|
|
|
|
[ NS_SPECIAL, 'test', 'view', false ],
|
|
|
|
[ NS_MAIN, 'Main Page', 'view', false ],
|
|
|
|
[ NS_MAIN, 'test', 'history', false ]
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @dataProvider provideHasPageActions
|
|
|
|
* @covers ::hasPageActions
|
|
|
|
*/
|
|
|
|
public function testHasPageActions( int $namespace, string $title, string $action, bool $expected ) {
|
|
|
|
$context = new RequestContext();
|
|
|
|
$context->setTitle( Title::makeTitle( $namespace, $title ) );
|
|
|
|
$context->setActionName( $action );
|
|
|
|
|
2024-02-29 20:35:21 +00:00
|
|
|
$skin = $this->newSkinMinerva();
|
2024-01-02 21:38:55 +00:00
|
|
|
$skin->setContext( $context );
|
|
|
|
|
|
|
|
$this->assertEquals( $expected, TestingAccessWrapper::newFromObject( $skin )->hasPageActions() );
|
|
|
|
}
|
|
|
|
|
2024-09-06 13:43:03 +00:00
|
|
|
public function provideMoveWikibaseLinkToToolbox() {
|
|
|
|
// We still need to test this case whilst T66315 is partially rolled out with a feature flag
|
|
|
|
yield "wikibase link already in toolbar" => [ [
|
|
|
|
'TOOLBOX' => [
|
|
|
|
'wikibase' => [
|
|
|
|
'id' => 't-wikibase',
|
|
|
|
]
|
|
|
|
],
|
|
|
|
'wikibase-otherprojects' => [
|
|
|
|
]
|
|
|
|
], true ];
|
|
|
|
yield "wikibase link in other projects" => [ [
|
|
|
|
'TOOLBOX' => [
|
|
|
|
],
|
|
|
|
'wikibase-otherprojects' => [
|
|
|
|
[],
|
|
|
|
[
|
|
|
|
'id' => 't-wikibase',
|
|
|
|
]
|
|
|
|
]
|
|
|
|
], true ];
|
|
|
|
yield "no wikibase item connected" => [ [
|
|
|
|
'TOOLBOX' => [
|
|
|
|
],
|
|
|
|
'wikibase-otherprojects' => [
|
|
|
|
]
|
|
|
|
], false ];
|
|
|
|
yield "no sidebar exists" => [ [], false ];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @dataProvider provideMoveWikibaseLinkToToolbox
|
|
|
|
* @covers ::moveWikibaseLinkToToolbox
|
|
|
|
*/
|
|
|
|
public function testMoveWikibaseLinkToToolbox( array $sidebar, bool $linkExists ) {
|
|
|
|
$sidebar = SkinMinerva::moveWikibaseLinkToToolbox( $sidebar );
|
|
|
|
if ( $linkExists ) {
|
|
|
|
$this->assertArrayHasKey( 'wikibase', $sidebar['TOOLBOX'] );
|
|
|
|
} else {
|
|
|
|
$this->assertArrayNotHasKey( 'wikibase', $sidebar['TOOLBOX'] ?? [] );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-01-02 21:38:55 +00:00
|
|
|
public static function provideHasPageTabs() {
|
|
|
|
return [
|
|
|
|
[ [ SkinOptions::TABS_ON_SPECIALS => false ], NS_MAIN, 'test', 'view', true ],
|
|
|
|
[ [ SkinOptions::TABS_ON_SPECIALS => false ], NS_MAIN, 'Main Page', 'view', false ],
|
|
|
|
[ [ SkinOptions::TABS_ON_SPECIALS => false ], NS_TALK, 'Main Page', 'view', false ],
|
|
|
|
[ [ SkinOptions::TALK_AT_TOP => false ], NS_MAIN, 'test', 'view', false ],
|
|
|
|
[ [ SkinOptions::TALK_AT_TOP => false ], NS_SPECIAL, 'test', 'view', true ],
|
|
|
|
[ [ SkinOptions::TALK_AT_TOP => false ], NS_MAIN, 'test', 'history', true ],
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @dataProvider provideHasPageTabs
|
|
|
|
* @covers ::hasPageTabs
|
|
|
|
*/
|
|
|
|
public function testHasPageTabs( array $options, int $namespace, string $title, string $action, bool $expected ) {
|
|
|
|
// both tabs on specials and talk at top default to true
|
|
|
|
$this->overrideSkinOptions( $options );
|
|
|
|
|
|
|
|
$context = new RequestContext();
|
|
|
|
$context->setTitle( Title::makeTitle( $namespace, $title ) );
|
|
|
|
$context->setActionName( $action );
|
|
|
|
|
|
|
|
// hasPageTabs gets the action directly from the request rather than the context so we set it here as well
|
|
|
|
$context->getRequest()->setVal( 'action', $action );
|
|
|
|
|
2024-02-29 20:35:21 +00:00
|
|
|
$skin = $this->newSkinMinerva();
|
2024-01-02 21:38:55 +00:00
|
|
|
$skin->setContext( $context );
|
|
|
|
|
|
|
|
$this->assertEquals( $expected, TestingAccessWrapper::newFromObject( $skin )->hasPageTabs() );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @covers ::getTabsData
|
|
|
|
*/
|
|
|
|
public function testGetTabsData() {
|
|
|
|
$context = new RequestContext();
|
|
|
|
$context->setTitle( Title::makeTitle( NS_MAIN, 'test' ) );
|
|
|
|
|
2024-02-29 20:35:21 +00:00
|
|
|
$skin = $this->newSkinMinerva();
|
2024-01-02 21:38:55 +00:00
|
|
|
$skin->setContext( $context );
|
|
|
|
|
|
|
|
$contentNavigationUrls = [ 'associated-pages' => [ 'testkey' => 'testvalue' ] ];
|
|
|
|
$associatedPages = [ 'id' => 'test' ];
|
|
|
|
$data = TestingAccessWrapper::newFromObject( $skin )->getTabsData( $contentNavigationUrls, $associatedPages );
|
|
|
|
|
|
|
|
$this->assertEquals( [ 'items' => [ 'testvalue' ], 'id' => 'test' ], $data );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @covers ::getTabsData when hasPageTabs is false
|
|
|
|
*/
|
|
|
|
public function testGetTabsDataNoPageTabs() {
|
|
|
|
$context = new RequestContext();
|
|
|
|
$context->setTitle( Title::makeTitle( NS_MAIN, 'Main Page' ) );
|
|
|
|
|
2024-02-29 20:35:21 +00:00
|
|
|
$skin = $this->newSkinMinerva();
|
2024-01-02 21:38:55 +00:00
|
|
|
$skin->setContext( $context );
|
|
|
|
|
|
|
|
$contentNavigationUrls = [ 'associated-pages' => [ 'testkey' => 'testvalue' ] ];
|
|
|
|
$associatedPages = [ 'id' => 'test' ];
|
|
|
|
$data = TestingAccessWrapper::newFromObject( $skin )->getTabsData( $contentNavigationUrls, $associatedPages );
|
|
|
|
|
|
|
|
$this->assertEquals( [], $data );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @covers ::getTabsData when contentNavigationUrls is empty
|
|
|
|
*/
|
|
|
|
public function testGetTabsDataNoContentNavigationUrls() {
|
|
|
|
$context = new RequestContext();
|
|
|
|
$context->setTitle( Title::makeTitle( NS_MAIN, 'test' ) );
|
|
|
|
|
2024-02-29 20:35:21 +00:00
|
|
|
$skin = $this->newSkinMinerva();
|
2024-01-02 21:38:55 +00:00
|
|
|
$skin->setContext( $context );
|
|
|
|
|
|
|
|
$contentNavigationUrls = [];
|
|
|
|
$associatedPages = [ 'id' => 'test' ];
|
|
|
|
$data = TestingAccessWrapper::newFromObject( $skin )->getTabsData( $contentNavigationUrls, $associatedPages );
|
|
|
|
|
|
|
|
$this->assertEquals( [], $data );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @covers ::getTabsData when associatedPages has no id
|
|
|
|
*/
|
|
|
|
public function testGetTabsDataNoId() {
|
|
|
|
$context = new RequestContext();
|
|
|
|
$context->setTitle( Title::makeTitle( NS_MAIN, 'test' ) );
|
|
|
|
|
2024-02-29 20:35:21 +00:00
|
|
|
$skin = $this->newSkinMinerva();
|
2024-01-02 21:38:55 +00:00
|
|
|
$skin->setContext( $context );
|
|
|
|
|
|
|
|
$contentNavigationUrls = [ 'associated-pages' => [ 'testkey' => 'testvalue' ] ];
|
|
|
|
$associatedPages = [];
|
|
|
|
$data = TestingAccessWrapper::newFromObject( $skin )->getTabsData( $contentNavigationUrls, $associatedPages );
|
|
|
|
|
|
|
|
$this->assertEquals( [ 'items' => [ 'testvalue' ], 'id' => null ], $data );
|
|
|
|
}
|
|
|
|
|
2024-01-30 19:21:36 +00:00
|
|
|
/**
|
|
|
|
* @covers ::getHtmlElementAttributes when night mode is not enabled via feature flag or query params
|
|
|
|
*/
|
|
|
|
public function testGetHtmlElementAttributesNoNightMode() {
|
2024-02-29 20:35:21 +00:00
|
|
|
$skin = $this->newSkinMinerva();
|
2024-01-30 19:21:36 +00:00
|
|
|
|
|
|
|
$classes = $skin->getHtmlElementAttributes()['class'];
|
2024-03-18 19:14:23 +00:00
|
|
|
$this->assertStringNotContainsString( 'skin-theme-clientpref-', $classes );
|
2024-01-30 19:21:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @covers ::getHtmlElementAttributes when night mode is enabled via feature flag
|
|
|
|
*/
|
|
|
|
public function testGetHtmlElementAttributesNightMode() {
|
|
|
|
$this->overrideSkinOptions( [ SkinOptions::NIGHT_MODE => true ] );
|
|
|
|
|
2024-02-29 20:35:21 +00:00
|
|
|
$skin = $this->newSkinMinerva();
|
2024-01-30 19:21:36 +00:00
|
|
|
|
|
|
|
$classes = $skin->getHtmlElementAttributes()['class'];
|
2024-03-18 19:14:23 +00:00
|
|
|
$this->assertStringContainsString( 'skin-theme-clientpref-day', $classes );
|
2024-01-30 19:21:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2024-02-05 22:45:49 +00:00
|
|
|
* @covers ::getHtmlElementAttributes when night mode is set via query params
|
2024-01-30 19:21:36 +00:00
|
|
|
*/
|
|
|
|
public function testGetHtmlElementAttributesNightModeQueryParam() {
|
|
|
|
$context = new RequestContext();
|
|
|
|
$request = $context->getRequest();
|
|
|
|
$request->setVal( 'minervanightmode', '1' );
|
|
|
|
|
2024-02-29 20:35:21 +00:00
|
|
|
$skin = $this->newSkinMinerva();
|
2024-01-30 19:21:36 +00:00
|
|
|
$skin->setContext( $context );
|
|
|
|
|
2024-02-05 22:45:49 +00:00
|
|
|
$classes = $skin->getHtmlElementAttributes()['class'];
|
2024-03-18 19:14:23 +00:00
|
|
|
$this->assertStringContainsString( 'skin-theme-clientpref-night', $classes );
|
2024-02-05 22:45:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @covers ::getHtmlElementAttributes when night mode is set via query params to an invalid option
|
|
|
|
*/
|
|
|
|
public function testGetHtmlElementAttributesNightModeQueryParamInvalid() {
|
|
|
|
$context = new RequestContext();
|
|
|
|
$request = $context->getRequest();
|
|
|
|
$request->setVal( 'minervanightmode', '3' );
|
|
|
|
|
2024-02-29 20:35:21 +00:00
|
|
|
$skin = $this->newSkinMinerva();
|
2024-02-05 22:45:49 +00:00
|
|
|
$skin->setContext( $context );
|
|
|
|
|
2024-01-30 19:21:36 +00:00
|
|
|
$classes = $skin->getHtmlElementAttributes()['class'];
|
2024-03-18 19:14:23 +00:00
|
|
|
$this->assertStringContainsString( 'skin-theme-clientpref-day', $classes );
|
2024-02-01 23:05:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @covers ::getHtmlElementAttributes when night mode is enabled and the value is not default
|
|
|
|
*/
|
|
|
|
public function testGetHtmlElementAttributesNightModeUserOption() {
|
|
|
|
$this->overrideSkinOptions( [ SkinOptions::NIGHT_MODE => true ] );
|
|
|
|
|
2024-02-29 20:35:21 +00:00
|
|
|
$skin = $this->newSkinMinerva();
|
2024-02-01 23:05:55 +00:00
|
|
|
|
|
|
|
$user = $skin->getUser();
|
2024-03-18 19:14:23 +00:00
|
|
|
$this->getServiceContainer()->getUserOptionsManager()->setOption( $user, 'minerva-theme', 'day' );
|
2024-02-01 23:05:55 +00:00
|
|
|
|
|
|
|
$classes = $skin->getHtmlElementAttributes()['class'];
|
2024-03-18 19:14:23 +00:00
|
|
|
$this->assertStringContainsString( 'skin-theme-clientpref-day', $classes );
|
2024-01-30 19:21:36 +00:00
|
|
|
}
|
|
|
|
|
2024-02-05 22:45:49 +00:00
|
|
|
/**
|
|
|
|
* @covers ::getHtmlElementAttributes when night mode is enabled with non-default, and query param is invalid
|
|
|
|
*/
|
|
|
|
public function testGetHtmlElementAttributesNightModeUserOptionQueryParamInvalid() {
|
|
|
|
$this->overrideSkinOptions( [ SkinOptions::NIGHT_MODE => true ] );
|
|
|
|
|
|
|
|
$context = new RequestContext();
|
|
|
|
$request = $context->getRequest();
|
|
|
|
$request->setVal( 'minervanightmode', '3' );
|
|
|
|
|
2024-02-29 20:35:21 +00:00
|
|
|
$skin = $this->newSkinMinerva();
|
2024-02-05 22:45:49 +00:00
|
|
|
$skin->setContext( $context );
|
|
|
|
|
|
|
|
$user = $skin->getUser();
|
2024-03-18 19:14:23 +00:00
|
|
|
$this->getServiceContainer()->getUserOptionsManager()->setOption( $user, 'minerva-theme', 'day' );
|
2024-02-05 22:45:49 +00:00
|
|
|
|
|
|
|
$classes = $skin->getHtmlElementAttributes()['class'];
|
2024-03-18 19:14:23 +00:00
|
|
|
$this->assertStringContainsString( 'skin-theme-clientpref-day', $classes );
|
2024-02-05 22:45:49 +00:00
|
|
|
}
|
|
|
|
|
2017-07-12 15:12:40 +00:00
|
|
|
/**
|
|
|
|
* @covers ::setContext
|
|
|
|
* @covers ::hasCategoryLinks
|
|
|
|
*/
|
|
|
|
public function testHasCategoryLinksWhenOptionIsOff() {
|
|
|
|
$outputPage = $this->getMockBuilder( OutputPage::class )
|
|
|
|
->disableOriginalConstructor()
|
|
|
|
->getMock();
|
|
|
|
$outputPage->expects( $this->never() )
|
|
|
|
->method( 'getCategoryLinks' );
|
|
|
|
|
2019-08-01 16:18:18 +00:00
|
|
|
$this->overrideSkinOptions( [ SkinOptions::CATEGORIES => false ] );
|
2017-07-12 15:12:40 +00:00
|
|
|
$context = new RequestContext();
|
2022-03-10 21:39:37 +00:00
|
|
|
$context->setTitle( Title::makeTitle( NS_MAIN, 'Test' ) );
|
2017-07-12 15:12:40 +00:00
|
|
|
$context->setOutput( $outputPage );
|
|
|
|
|
2024-02-29 20:35:21 +00:00
|
|
|
$skin = $this->newSkinMinerva();
|
2017-07-12 15:12:40 +00:00
|
|
|
$skin->setContext( $context );
|
|
|
|
$skin = TestingAccessWrapper::newFromObject( $skin );
|
|
|
|
|
2021-11-13 17:58:14 +00:00
|
|
|
$this->assertFalse( $skin->hasCategoryLinks() );
|
2017-07-12 15:12:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @dataProvider provideHasCategoryLinks
|
|
|
|
* @param array $categoryLinks
|
|
|
|
* @param bool $expected
|
|
|
|
* @covers ::setContext
|
2017-12-29 20:26:59 +00:00
|
|
|
* @covers ::hasCategoryLinks
|
2017-07-12 15:12:40 +00:00
|
|
|
*/
|
|
|
|
public function testHasCategoryLinks( array $categoryLinks, $expected ) {
|
|
|
|
$outputPage = $this->getMockBuilder( OutputPage::class )
|
|
|
|
->disableOriginalConstructor()
|
|
|
|
->getMock();
|
|
|
|
$outputPage->expects( $this->once() )
|
|
|
|
->method( 'getCategoryLinks' )
|
2021-12-17 10:29:48 +00:00
|
|
|
->willReturn( $categoryLinks );
|
2017-07-12 15:12:40 +00:00
|
|
|
|
2019-08-01 16:18:18 +00:00
|
|
|
$this->overrideSkinOptions( [ SkinOptions::CATEGORIES => true ] );
|
2019-04-10 21:43:50 +00:00
|
|
|
|
2017-07-12 15:12:40 +00:00
|
|
|
$context = new RequestContext();
|
2022-03-10 21:39:37 +00:00
|
|
|
$context->setTitle( Title::makeTitle( NS_MAIN, 'Test' ) );
|
2017-07-12 15:12:40 +00:00
|
|
|
$context->setOutput( $outputPage );
|
|
|
|
|
2024-02-29 20:35:21 +00:00
|
|
|
$skin = $this->newSkinMinerva();
|
2017-07-12 15:12:40 +00:00
|
|
|
$skin->setContext( $context );
|
|
|
|
|
|
|
|
$skin = TestingAccessWrapper::newFromObject( $skin );
|
|
|
|
|
2022-03-04 19:11:16 +00:00
|
|
|
$this->assertEquals( $expected, $skin->hasCategoryLinks() );
|
2017-07-12 15:12:40 +00:00
|
|
|
}
|
|
|
|
|
2023-05-20 08:58:18 +00:00
|
|
|
public static function provideHasCategoryLinks() {
|
2017-07-12 15:12:40 +00:00
|
|
|
return [
|
|
|
|
[ [], false ],
|
|
|
|
[
|
|
|
|
[
|
|
|
|
'normal' => '<ul><li><a href="/wiki/Category:1">1</a></li></ul>'
|
|
|
|
],
|
|
|
|
true
|
|
|
|
],
|
|
|
|
[
|
|
|
|
[
|
|
|
|
'hidden' => '<ul><li><a href="/wiki/Category:Hidden">Hidden</a></li></ul>'
|
|
|
|
],
|
|
|
|
true
|
|
|
|
],
|
|
|
|
[
|
|
|
|
[
|
|
|
|
'normal' => '<ul><li><a href="/wiki/Category:1">1</a></li></ul>',
|
|
|
|
'hidden' => '<ul><li><a href="/wiki/Category:Hidden">Hidden</a></li></ul>'
|
|
|
|
],
|
|
|
|
true
|
|
|
|
],
|
|
|
|
[
|
|
|
|
[
|
|
|
|
'unexpected' => '<ul><li><a href="/wiki/Category:1">1</a></li></ul>'
|
|
|
|
],
|
|
|
|
false
|
|
|
|
],
|
|
|
|
];
|
|
|
|
}
|
2023-08-01 00:12:59 +00:00
|
|
|
|
|
|
|
public static function provideGetNotificationButtons() {
|
|
|
|
return [
|
|
|
|
[
|
|
|
|
[],
|
|
|
|
[]
|
|
|
|
],
|
|
|
|
//
|
|
|
|
// CIRCLE
|
|
|
|
//
|
|
|
|
[
|
2024-03-10 23:28:35 +00:00
|
|
|
[
|
2023-08-01 00:12:59 +00:00
|
|
|
'tag-name' => 'a',
|
|
|
|
'classes' => 'mw-echo-notifications-badge mw-echo-notification-badge-nojs '
|
|
|
|
. ' mw-echo-unseen-notifications',
|
|
|
|
'array-attributes' => [
|
|
|
|
self::ATTRIBUTE_NOTIFICATION_HREF,
|
|
|
|
self::ATTRIBUTE_NOTIFICATION_DATA_COUNTER_TEXT,
|
|
|
|
self::ATTRIBUTE_NOTIFICATION_DATA_COUNTER_NUM,
|
|
|
|
self::ATTRIBUTE_NOTIFICATION_TITLE,
|
|
|
|
[
|
|
|
|
'key' => 'id',
|
|
|
|
'value' => 'pt-notifications-alert',
|
|
|
|
],
|
|
|
|
],
|
|
|
|
'data-icon' => [
|
|
|
|
'icon' => 'circle'
|
|
|
|
],
|
|
|
|
'label' => 'Alerts (13)',
|
|
|
|
],
|
|
|
|
[
|
|
|
|
[
|
|
|
|
'name' => 'notifications-alert',
|
|
|
|
'id' => 'pt-notifications-alert',
|
|
|
|
'class' => 'notification-count notification-unseen mw-echo-unseen-notifications mw-list-item',
|
|
|
|
'array-links' => [
|
|
|
|
[
|
|
|
|
'icon' => 'circle',
|
|
|
|
'array-attributes' => [
|
|
|
|
self::ATTRIBUTE_NOTIFICATION_HREF,
|
|
|
|
self::ATTRIBUTE_NOTIFICATION_DATA_COUNTER_TEXT,
|
|
|
|
self::ATTRIBUTE_NOTIFICATION_DATA_COUNTER_NUM,
|
|
|
|
self::ATTRIBUTE_NOTIFICATION_TITLE,
|
|
|
|
[
|
|
|
|
'key' => 'class',
|
|
|
|
'value' => 'mw-echo-notifications-badge '
|
|
|
|
. 'mw-echo-notification-badge-nojs oo-ui-icon-bellOutline '
|
|
|
|
. 'mw-echo-unseen-notifications',
|
|
|
|
],
|
|
|
|
],
|
|
|
|
'text' => 'Alerts (13)'
|
|
|
|
]
|
|
|
|
]
|
|
|
|
]
|
|
|
|
]
|
|
|
|
|
|
|
|
],
|
|
|
|
//
|
|
|
|
// BELL
|
|
|
|
//
|
|
|
|
[
|
|
|
|
[
|
|
|
|
'tag-name' => 'a',
|
|
|
|
'classes' => 'mw-echo-notifications-badge mw-echo-notification-badge-nojs',
|
|
|
|
'array-attributes' => [
|
|
|
|
self::ATTRIBUTE_NOTIFICATION_HREF,
|
|
|
|
self::ATTRIBUTE_NOTIFICATION_DATA_COUNTER_TEXT,
|
|
|
|
self::ATTRIBUTE_NOTIFICATION_DATA_COUNTER_NUM,
|
|
|
|
self::ATTRIBUTE_NOTIFICATION_TITLE,
|
|
|
|
[
|
|
|
|
'key' => 'id',
|
|
|
|
'value' => 'pt-notifications-alert',
|
|
|
|
],
|
|
|
|
],
|
|
|
|
'data-icon' => [
|
2023-09-05 17:07:13 +00:00
|
|
|
'icon' => 'bellOutline-base20'
|
2023-08-01 00:12:59 +00:00
|
|
|
],
|
|
|
|
'label' => 'Alerts (13)',
|
|
|
|
],
|
|
|
|
[
|
|
|
|
[
|
|
|
|
'html-item' => 'n/a',
|
|
|
|
'name' => 'notifications-alert',
|
|
|
|
'html' => 'HTML',
|
|
|
|
'id' => 'pt-notifications-alert',
|
|
|
|
'class' => 'mw-list-item',
|
|
|
|
'array-links' => [
|
|
|
|
[
|
2023-09-05 17:07:13 +00:00
|
|
|
'icon' => 'bellOutline-base20',
|
2023-08-01 00:12:59 +00:00
|
|
|
'array-attributes' => [
|
|
|
|
self::ATTRIBUTE_NOTIFICATION_HREF,
|
|
|
|
self::ATTRIBUTE_NOTIFICATION_DATA_COUNTER_TEXT,
|
|
|
|
self::ATTRIBUTE_NOTIFICATION_DATA_COUNTER_NUM,
|
|
|
|
self::ATTRIBUTE_NOTIFICATION_TITLE,
|
|
|
|
[
|
|
|
|
'key' => 'class',
|
|
|
|
'value' => 'mw-echo-notifications-badge mw-echo-notification-badge-nojs',
|
|
|
|
],
|
|
|
|
],
|
|
|
|
'text' => 'Alerts (13)'
|
|
|
|
]
|
|
|
|
]
|
|
|
|
]
|
|
|
|
]
|
|
|
|
]
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @dataProvider provideGetNotificationButtons
|
|
|
|
* @param array $expected
|
|
|
|
* @param array $from
|
|
|
|
* @covers ::getNotificationButtons
|
|
|
|
*/
|
|
|
|
public function testGetNotificationButtons( $expected, $from ) {
|
|
|
|
$btns = SkinMinerva::getNotificationButtons( $from );
|
|
|
|
$this->assertEquals( $expected['classes'] ?? '', $btns[0]['classes'] ?? '' );
|
|
|
|
$this->assertEquals( $expected['data-attributes'] ?? [], $btns[0]['data-attributes'] ?? [] );
|
|
|
|
$this->assertEquals( $expected['data-icon'] ?? [], $btns[0]['data-icon'] ?? [] );
|
|
|
|
$this->assertEquals( $expected['data-label'] ?? '', $btns[0]['data-label'] ?? '' );
|
|
|
|
}
|
2017-07-12 15:12:40 +00:00
|
|
|
}
|