tests: @expectedException is deprecated

Bug: T234597
Change-Id: I5e0906a58add32b4d28449e8e59f1d32dc77c771
This commit is contained in:
Max Semenik 2019-10-19 19:26:08 -07:00
parent 59493f06b9
commit 40f483b074
3 changed files with 11 additions and 11 deletions

View file

@ -2,8 +2,6 @@
<ruleset>
<rule ref="./vendor/mediawiki/mediawiki-codesniffer/MediaWiki">
<exclude name="Generic.Files.OneObjectStructurePerFile.MultipleFound" />
<exclude name="MediaWiki.Commenting.PhpunitAnnotations.ForbiddenExpectedException" />
<exclude name="MediaWiki.Commenting.PhpunitAnnotations.ForbiddenExpectedExceptionMessage" />
<exclude name="MediaWiki.NamingConventions.LowerCamelFunctionsName.FunctionName"/>
<exclude name="MediaWiki.WhiteSpace.SpaceBeforeSingleLineComment.NewLineComment"/>
<exclude name="PSR12.Properties.ConstantVisibility.NotFound" />

View file

@ -2,6 +2,7 @@
namespace Tests\MediaWiki\Minerva\Menu;
use DomainException;
use MediaWiki\Minerva\Menu\Entries\IMenuEntry;
use MediaWiki\Minerva\Menu\Group;
@ -112,14 +113,14 @@ class GroupTest extends \MediaWikiTestCase {
}
/**
* @expectedException \DomainException
* @expectedExceptionMessage The "home" entry doesn't exist.
* @covers ::insertAfter
* @covers ::search
* @covers \MediaWiki\Minerva\Menu\Entries\MenuEntry::addComponent
*/
public function testInsertAfterWhenTargetEntryDoesntExist() {
$menu = new Group();
$this->expectException( DomainException::class );
$this->expectExceptionMessage( 'The "home" entry doesn\'t exist.' );
$menu->insertAfter( 'home', 'nearby' )
->addComponent(
$this->nearbyComponent['text'],
@ -129,25 +130,25 @@ class GroupTest extends \MediaWikiTestCase {
}
/**
* @expectedException \DomainException
* @expectedExceptionMessage The "car" entry already exists.
* @covers ::insertAfter
*/
public function testInsertAfterWithAnEntryWithAnExistingName() {
$menu = new Group();
$menu->insert( 'home' );
$menu->insert( 'car' );
$this->expectException( DomainException::class );
$this->expectExceptionMessage( 'The "car" entry already exists.' );
$menu->insertAfter( 'home', 'car' );
}
/**
* @expectedException \DomainException
* @expectedExceptionMessage The "home" entry already exists.
* @covers ::insert
*/
public function testInsertingAnEntryWithAnExistingName() {
$menu = new Group();
$menu->insert( 'home' );
$this->expectException( DomainException::class );
$this->expectExceptionMessage( 'The "home" entry already exists.' );
$menu->insert( 'home' );
}
@ -254,10 +255,10 @@ class GroupTest extends \MediaWikiTestCase {
/**
* @covers ::getEntryByName
* @covers ::search
* @expectedException \DomainException
*/
public function testGetEntryByNameException() {
$menu = new Group();
$this->expectException( DomainException::class );
$menu->getEntryByName( 'home' );
}

View file

@ -3,6 +3,7 @@
namespace Tests\MediaWiki\Minerva;
use MediaWiki\Minerva\SkinOptions;
use OutOfBoundsException;
/**
* Class SkinMinervaTest
@ -50,19 +51,19 @@ class SkinOptionsTest extends \MediaWikiUnitTestCase {
/**
* @covers ::get
* @expectedException \OutOfBoundsException
*/
public function testGettingUnknownKeyShouldThrowException() {
$options = new SkinOptions();
$this->expectException( OutOfBoundsException::class );
$options->get( 'non_existing_key' );
}
/**
* @covers ::get
* @expectedException \OutOfBoundsException
*/
public function testSettingUnknownKeyShouldThrowException() {
$options = new SkinOptions();
$this->expectException( OutOfBoundsException::class );
$options->setMultiple( [
'non_existing_key' => 1
] );