mirror of
https://gerrit.wikimedia.org/r/mediawiki/skins/MinervaNeue
synced 2024-12-24 03:23:33 +00:00
Group.php: Hard deprecate insertAfter() function
Hard deprecated the Group::insertAfter() function because it is not used in the Mediawiki codebase Bug: T311894 Change-Id: I209d3fd492713425a2727fd48c5870f983a39f9b
This commit is contained in:
parent
9aaf8537fa
commit
3efc6db04b
|
@ -130,7 +130,7 @@ final class Group {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Insert an entry after an existing one.
|
* Insert an entry after an existing one.
|
||||||
*
|
* @deprecated since 1.39
|
||||||
* @param string $targetName The name of the existing entry to insert
|
* @param string $targetName The name of the existing entry to insert
|
||||||
* the new entry after
|
* the new entry after
|
||||||
* @param string $name The name of the new entry
|
* @param string $name The name of the new entry
|
||||||
|
@ -143,7 +143,9 @@ final class Group {
|
||||||
* @throws DomainException When the existing entry doesn't exist
|
* @throws DomainException When the existing entry doesn't exist
|
||||||
*/
|
*/
|
||||||
public function insertAfter( $targetName, $name, $text, $url,
|
public function insertAfter( $targetName, $name, $text, $url,
|
||||||
$className = '', $icon = null, $trackable = false, $isJSOnly = false ) {
|
$className = '', $icon = null, $trackable = false, $isJSOnly = false
|
||||||
|
) {
|
||||||
|
wfDeprecated( __METHOD__, '1.39' );
|
||||||
$this->throwIfNotUnique( $name );
|
$this->throwIfNotUnique( $name );
|
||||||
$index = $this->search( $targetName );
|
$index = $this->search( $targetName );
|
||||||
|
|
||||||
|
|
|
@ -77,131 +77,6 @@ class GroupTest extends MediaWikiIntegrationTestCase {
|
||||||
$this->assertTrue( $menu->hasEntries() );
|
$this->assertTrue( $menu->hasEntries() );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @covers ::insertEntry
|
|
||||||
* @covers ::search
|
|
||||||
* @covers ::getEntries
|
|
||||||
* @covers ::insertAfter
|
|
||||||
*/
|
|
||||||
public function testInsertingAnEntryAfterAnother() {
|
|
||||||
$menu = new Group( 'p-test' );
|
|
||||||
$entryHome = SingleMenuEntry::create(
|
|
||||||
'home',
|
|
||||||
$this->homeComponent['text'],
|
|
||||||
$this->homeComponent['href'],
|
|
||||||
$this->homeComponent['class'],
|
|
||||||
$this->homeComponent['icon'],
|
|
||||||
true
|
|
||||||
);
|
|
||||||
$menu->insertEntry( $entryHome );
|
|
||||||
|
|
||||||
$entryOtherHome = SingleMenuEntry::create(
|
|
||||||
'another_home',
|
|
||||||
$this->homeComponent['text'],
|
|
||||||
$this->homeComponent['href'],
|
|
||||||
$this->homeComponent['class'],
|
|
||||||
$this->homeComponent['icon'],
|
|
||||||
true
|
|
||||||
);
|
|
||||||
$menu->insertEntry( $entryOtherHome );
|
|
||||||
$menu->insertAfter(
|
|
||||||
'home',
|
|
||||||
'nearby',
|
|
||||||
$this->nearbyComponent['text'],
|
|
||||||
$this->nearbyComponent['href'],
|
|
||||||
$this->nearbyComponent['class'],
|
|
||||||
$this->nearbyComponent['icon']
|
|
||||||
);
|
|
||||||
|
|
||||||
$expectedEntries = [
|
|
||||||
[
|
|
||||||
'name' => 'home',
|
|
||||||
'components' => [
|
|
||||||
[
|
|
||||||
'text' => $this->homeComponent['text'],
|
|
||||||
'href' => $this->homeComponent['href'],
|
|
||||||
'class' => 'mw-ui-icon mw-ui-icon-before mw-ui-icon-home menu__item--home',
|
|
||||||
'icon' => 'minerva-home',
|
|
||||||
'data-event-name' => 'menu.home'
|
|
||||||
]
|
|
||||||
],
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'name' => 'nearby',
|
|
||||||
'components' => [
|
|
||||||
[
|
|
||||||
'text' => $this->nearbyComponent['text'],
|
|
||||||
'href' => $this->nearbyComponent['href'],
|
|
||||||
'class' => 'mw-ui-icon mw-ui-icon-before mw-ui-icon-nearby menu__item--nearby',
|
|
||||||
'icon' => 'minerva-nearby'
|
|
||||||
]
|
|
||||||
],
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'name' => 'another_home',
|
|
||||||
'components' => [
|
|
||||||
[
|
|
||||||
'text' => $this->homeComponent['text'],
|
|
||||||
'href' => $this->homeComponent['href'],
|
|
||||||
'class' => 'mw-ui-icon mw-ui-icon-before mw-ui-icon-home menu__item--another_home',
|
|
||||||
'icon' => 'minerva-another_home',
|
|
||||||
'data-event-name' => 'menu.another_home'
|
|
||||||
]
|
|
||||||
],
|
|
||||||
],
|
|
||||||
];
|
|
||||||
|
|
||||||
$this->assertEquals( $expectedEntries, $menu->getEntries() );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @covers ::insertAfter
|
|
||||||
* @covers ::search
|
|
||||||
*/
|
|
||||||
public function testInsertAfterWhenTargetEntryDoesntExist() {
|
|
||||||
$menu = new Group( 'p-test' );
|
|
||||||
$this->expectException( DomainException::class );
|
|
||||||
$this->expectExceptionMessage( 'The "home" entry doesn\'t exist.' );
|
|
||||||
$menu->insertAfter(
|
|
||||||
'home',
|
|
||||||
'nearby',
|
|
||||||
$this->nearbyComponent['text'],
|
|
||||||
$this->nearbyComponent['href'],
|
|
||||||
$this->nearbyComponent['class'],
|
|
||||||
$this->nearbyComponent['icon']
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @covers ::insertAfter
|
|
||||||
*/
|
|
||||||
public function testInsertAfterWithAnEntryWithAnExistingName() {
|
|
||||||
$menu = new Group( 'p-test' );
|
|
||||||
$entryHome = SingleMenuEntry::create(
|
|
||||||
'home',
|
|
||||||
$this->homeComponent['text'],
|
|
||||||
$this->homeComponent['href'],
|
|
||||||
$this->homeComponent['class']
|
|
||||||
);
|
|
||||||
$menu->insertEntry( $entryHome );
|
|
||||||
$entryCar = SingleMenuEntry::create(
|
|
||||||
'car',
|
|
||||||
$this->homeComponent['text'],
|
|
||||||
$this->homeComponent['href'],
|
|
||||||
$this->homeComponent['class']
|
|
||||||
);
|
|
||||||
$menu->insertEntry( $entryCar );
|
|
||||||
$this->expectException( DomainException::class );
|
|
||||||
$this->expectExceptionMessage( 'The "car" entry already exists.' );
|
|
||||||
$menu->insertAfter(
|
|
||||||
'home',
|
|
||||||
'car',
|
|
||||||
$this->homeComponent['text'],
|
|
||||||
$this->homeComponent['href'],
|
|
||||||
$this->homeComponent['class']
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers ::insertEntry
|
* @covers ::insertEntry
|
||||||
*/
|
*/
|
||||||
|
@ -219,42 +94,6 @@ class GroupTest extends MediaWikiIntegrationTestCase {
|
||||||
$menu->insertEntry( $entryHome );
|
$menu->insertEntry( $entryHome );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @covers ::insertEntry
|
|
||||||
* @covers ::insertAfter
|
|
||||||
*/
|
|
||||||
public function testInsertingAnEntryAfterAnotherOne() {
|
|
||||||
$menu = new Group( 'p-test' );
|
|
||||||
$entryFirst = SingleMenuEntry::create(
|
|
||||||
'first',
|
|
||||||
$this->homeComponent['text'],
|
|
||||||
$this->homeComponent['href'],
|
|
||||||
$this->homeComponent['class']
|
|
||||||
);
|
|
||||||
$menu->insertEntry( $entryFirst );
|
|
||||||
|
|
||||||
$entryLast = SingleMenuEntry::create(
|
|
||||||
'last',
|
|
||||||
$this->homeComponent['text'],
|
|
||||||
$this->homeComponent['href'],
|
|
||||||
$this->homeComponent['class']
|
|
||||||
);
|
|
||||||
$menu->insertEntry( $entryLast );
|
|
||||||
$menu->insertAfter(
|
|
||||||
'first',
|
|
||||||
'middle',
|
|
||||||
$this->nearbyComponent['text'],
|
|
||||||
$this->nearbyComponent['href'],
|
|
||||||
$this->nearbyComponent['class'],
|
|
||||||
$this->nearbyComponent['icon']
|
|
||||||
);
|
|
||||||
$items = $menu->getEntries();
|
|
||||||
$this->assertCount( 3, $items );
|
|
||||||
$this->assertSame( 'first', $items[0]['name'] );
|
|
||||||
$this->assertSame( 'middle', $items[1]['name'] );
|
|
||||||
$this->assertSame( 'last', $items[2]['name'] );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers ::insertEntry
|
* @covers ::insertEntry
|
||||||
* @covers ::getEntries
|
* @covers ::getEntries
|
||||||
|
|
Loading…
Reference in a new issue