aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaimona Eaytoy <daimona.wiki@gmail.com>2023-06-10 02:29:51 +0200
committerDannyS712 <dannys712.wiki@gmail.com>2024-01-19 22:01:12 +0000
commit2520f3d1c4054f4e2e19fd8a0ccd3792cc9772c9 (patch)
tree104082c2cab908d5cd25ff7198987a36e988fb11
parent1d6776fdbccf956e1ce4747a9c39dd8a05cdea88 (diff)
downloadmediawikicore-2520f3d1c4054f4e2e19fd8a0ccd3792cc9772c9.tar.gz
mediawikicore-2520f3d1c4054f4e2e19fd8a0ccd3792cc9772c9.zip
Replace more usages of deprecated MWException
Bug: T328220 Change-Id: Ie9b56bcf5e962e275d80570cad98d676da505894
-rw-r--r--includes/Category/CategoryViewer.php5
-rw-r--r--includes/Html/FormOptions.php7
-rw-r--r--includes/Html/Html.php5
-rw-r--r--includes/Output/OutputPage.php17
-rw-r--r--includes/StubObject/StubObject.php5
-rw-r--r--includes/collation/CollationFactory.php5
-rw-r--r--includes/editpage/EditPage.php5
-rw-r--r--includes/filerepo/file/OldLocalFile.php2
-rw-r--r--includes/historyblob/DiffHistoryBlob.php10
-rw-r--r--includes/language/Language.php7
-rw-r--r--includes/page/MovePage.php4
-rw-r--r--includes/poolcounter/PoolCounterConnectionManager.php9
-rw-r--r--includes/preferences/DefaultPreferencesFactory.php5
-rw-r--r--includes/registration/ExtensionRegistry.php6
-rw-r--r--includes/revisiondelete/RevDelList.php3
-rw-r--r--includes/skins/components/SkinComponentSearch.php5
-rw-r--r--tests/phpunit/includes/Html/HtmlTest.php2
-rw-r--r--tests/phpunit/includes/Output/OutputPageTest.php10
-rw-r--r--tests/phpunit/unit/includes/Html/FormOptionsTest.php2
-rw-r--r--tests/phpunit/unit/includes/registration/ExtensionRegistryTest.php3
20 files changed, 43 insertions, 74 deletions
diff --git a/includes/Category/CategoryViewer.php b/includes/Category/CategoryViewer.php
index d15297eeb5d0..ef9cbe6cde1b 100644
--- a/includes/Category/CategoryViewer.php
+++ b/includes/Category/CategoryViewer.php
@@ -30,6 +30,7 @@ use IContextSource;
use ILanguageConverter;
use ImageGalleryBase;
use ImageGalleryClassNotFoundException;
+use InvalidArgumentException;
use LinkCache;
use MediaWiki\HookContainer\ProtectedHookAccessorTrait;
use MediaWiki\Html\Html;
@@ -40,7 +41,6 @@ use MediaWiki\Page\PageIdentity;
use MediaWiki\Page\PageReference;
use MediaWiki\Title\Title;
use MediaWiki\Title\TitleValue;
-use MWException;
use Wikimedia\Rdbms\SelectQueryBuilder;
class CategoryViewer extends ContextSource {
@@ -763,7 +763,6 @@ class CategoryViewer extends ContextSource {
*
* @param PageReference $page The title (usually $this->title)
* @param string $section Which section
- * @throws MWException
* @return LinkTarget
*/
private function addFragmentToTitle( PageReference $page, string $section ): LinkTarget {
@@ -778,7 +777,7 @@ class CategoryViewer extends ContextSource {
$fragment = 'mw-category-media';
break;
default:
- throw new MWException( __METHOD__ .
+ throw new InvalidArgumentException( __METHOD__ .
" Invalid section $section." );
}
diff --git a/includes/Html/FormOptions.php b/includes/Html/FormOptions.php
index 859b7fa4c4f6..d621a33b2f97 100644
--- a/includes/Html/FormOptions.php
+++ b/includes/Html/FormOptions.php
@@ -29,6 +29,7 @@
namespace MediaWiki\Html;
use ArrayAccess;
+use InvalidArgumentException;
use MediaWiki\Request\WebRequest;
use MWException;
@@ -115,11 +116,9 @@ class FormOptions implements ArrayAccess {
* Used to find out which type the data is. All types are defined in the 'Type constants' section
* of this class.
*
- * Detection of the INTNULL type is not supported; INT will be assumed if the data is an integer,
- * MWException will be thrown if it's null.
+ * Detection of the INTNULL type is not supported; INT will be assumed if the data is an integer.
*
* @param mixed $data Value to guess the type for
- * @throws MWException If unable to guess the type
* @return int Type constant
*/
public static function guessType( $data ) {
@@ -134,7 +133,7 @@ class FormOptions implements ArrayAccess {
} elseif ( is_array( $data ) ) {
return self::ARR;
} else {
- throw new MWException( 'Unsupported datatype' );
+ throw new InvalidArgumentException( 'Unsupported datatype' );
}
}
diff --git a/includes/Html/Html.php b/includes/Html/Html.php
index c1a69fb0cc2c..e57b1ad60b55 100644
--- a/includes/Html/Html.php
+++ b/includes/Html/Html.php
@@ -30,7 +30,7 @@ use InvalidArgumentException;
use MediaWiki\MainConfigNames;
use MediaWiki\MediaWikiServices;
use MediaWiki\Request\ContentSecurityPolicy;
-use MWException;
+use UnexpectedValueException;
/**
* This class is a collection of static functions that serve two purposes:
@@ -505,7 +505,6 @@ class Html {
* you can omit the key, e.g., [ 'checked' ] instead of
* [ 'checked' => 'checked' ] or such.
*
- * @throws MWException If an attribute that doesn't allow lists is set to an array
* @return string HTML fragment that goes between element name and '>'
* (starting with a space if at least one attribute is output)
*/
@@ -585,7 +584,7 @@ class Html {
// phpcs:ignore Generic.PHP.DiscourageGoto
goto not_bool; // NOSONAR
} elseif ( is_array( $value ) ) {
- throw new MWException( "HTML attribute $key can not contain a list of values" );
+ throw new UnexpectedValueException( "HTML attribute $key can not contain a list of values" );
}
if ( isset( self::$boolAttribs[$key] ) ) {
diff --git a/includes/Output/OutputPage.php b/includes/Output/OutputPage.php
index d50c52d1b95f..bd82e6230f56 100644
--- a/includes/Output/OutputPage.php
+++ b/includes/Output/OutputPage.php
@@ -60,12 +60,12 @@ use MediaWiki\Title\TitleValue;
use MediaWiki\Utils\MWTimestamp;
use Message;
use MWDebug;
-use MWException;
use OOUI\Element;
use OOUI\Theme;
use Parser;
use ParserOptions;
use RequestContext;
+use RuntimeException;
use Skin;
use TextContent;
use Wikimedia\AtEase\AtEase;
@@ -2036,8 +2036,6 @@ class OutputPage extends ContextSource {
* @param bool $linestart Is this the start of a line? (Defaults to true)
* @param PageReference|null $title Optional title to use; default of `null`
* means use current page title.
- * @throws MWException if $title is not provided and OutputPage::getTitle()
- * is null
* @since 1.32
*/
public function addWikiTextAsInterface(
@@ -2045,7 +2043,7 @@ class OutputPage extends ContextSource {
) {
$title ??= $this->getTitle();
if ( !$title ) {
- throw new MWException( 'Title is null' );
+ throw new RuntimeException( 'Title is null' );
}
$this->addWikiTextTitleInternal( $text, $title, $linestart, /*interface*/true );
}
@@ -2084,8 +2082,6 @@ class OutputPage extends ContextSource {
* @param bool $linestart Is this the start of a line? (Defaults to true)
* @param PageReference|null $title Optional title to use; default of `null`
* means use current page title.
- * @throws MWException if $title is not provided and OutputPage::getTitle()
- * is null
* @since 1.32
*/
public function addWikiTextAsContent(
@@ -2093,7 +2089,7 @@ class OutputPage extends ContextSource {
) {
$title ??= $this->getTitle();
if ( !$title ) {
- throw new MWException( 'Title is null' );
+ throw new RuntimeException( 'Title is null' );
}
$this->addWikiTextTitleInternal( $text, $title, $linestart, /*interface*/false );
}
@@ -2445,7 +2441,6 @@ class OutputPage extends ContextSource {
*
* @param string $text Wikitext in the page content language
* @param bool $linestart Is this the start of a line? (Defaults to true)
- * @throws MWException
* @return string HTML
* @since 1.32
*/
@@ -2468,7 +2463,6 @@ class OutputPage extends ContextSource {
*
* @param string $text Wikitext in the user interface language
* @param bool $linestart Is this the start of a line? (Defaults to true)
- * @throws MWException
* @return string HTML
* @since 1.32
*/
@@ -2493,7 +2487,6 @@ class OutputPage extends ContextSource {
*
* @param string $text Wikitext in the user interface language
* @param bool $linestart Is this the start of a line? (Defaults to true)
- * @throws MWException
* @return string HTML
* @since 1.32
*/
@@ -2512,14 +2505,12 @@ class OutputPage extends ContextSource {
* @param bool $interface Use interface language (instead of content language) while parsing
* language sensitive magic words like GRAMMAR and PLURAL. This also disables
* LanguageConverter.
- * @throws MWException
* @return ParserOutput
*/
private function parseInternal( $text, $title, $linestart, $interface ) {
if ( $title === null ) {
- throw new MWException( 'Empty $mTitle in ' . __METHOD__ );
+ throw new RuntimeException( 'Empty $mTitle in ' . __METHOD__ );
}
-
$popts = $this->parserOptions();
$oldInterface = $popts->setInterfaceMessage( (bool)$interface );
diff --git a/includes/StubObject/StubObject.php b/includes/StubObject/StubObject.php
index c5c9fe40b966..b96a82934499 100644
--- a/includes/StubObject/StubObject.php
+++ b/includes/StubObject/StubObject.php
@@ -26,7 +26,7 @@
namespace MediaWiki\StubObject;
-use MWException;
+use LogicException;
use Wikimedia\ObjectFactory\ObjectFactory;
/**
@@ -211,7 +211,6 @@ class StubObject {
* @param int $level Level to go in the stack trace to get the function
* who called this function.
* @return object The unstubbed version of itself
- * @throws MWException
*/
// phpcs:ignore PSR2.Methods.MethodDeclaration.Underscore
public function _unstub( $name = '_unstub', $level = 2 ) {
@@ -224,7 +223,7 @@ class StubObject {
if ( get_class( $GLOBALS[$this->global] ) != $this->class ) {
$caller = wfGetCaller( $level );
if ( ++$recursionLevel > 2 ) {
- throw new MWException( "Unstub loop detected on call of "
+ throw new LogicException( "Unstub loop detected on call of "
. "\${$this->global}->$name from $caller\n" );
}
wfDebug( "Unstubbing \${$this->global} on call of "
diff --git a/includes/collation/CollationFactory.php b/includes/collation/CollationFactory.php
index 0f01180a6912..3274e0eb38a7 100644
--- a/includes/collation/CollationFactory.php
+++ b/includes/collation/CollationFactory.php
@@ -22,11 +22,11 @@
namespace MediaWiki\Collation;
use Collation;
+use InvalidArgumentException;
use MediaWiki\Config\ServiceOptions;
use MediaWiki\HookContainer\HookContainer;
use MediaWiki\HookContainer\HookRunner;
use MediaWiki\MainConfigNames;
-use MWException;
use Wikimedia\ObjectFactory\ObjectFactory;
/**
@@ -137,7 +137,6 @@ class CollationFactory {
}
/**
- * @throws MWException
* @param string $collationName
* @return Collation
*/
@@ -173,7 +172,7 @@ class CollationFactory {
$this->hookRunner->onCollation__factory( $collationName, $collationObject );
if ( !$collationObject instanceof Collation ) {
- throw new MWException( __METHOD__ . ": unknown collation type \"$collationName\"" );
+ throw new InvalidArgumentException( __METHOD__ . ": unknown collation type \"$collationName\"" );
}
return $collationObject;
diff --git a/includes/editpage/EditPage.php b/includes/editpage/EditPage.php
index 7e7c35cd79b2..e75cd3954471 100644
--- a/includes/editpage/EditPage.php
+++ b/includes/editpage/EditPage.php
@@ -21,6 +21,7 @@
namespace MediaWiki\EditPage;
use Article;
+use BadMethodCallException;
use CategoryPage;
use Content;
use ContentHandler;
@@ -880,7 +881,7 @@ class EditPage implements IEditObject {
// fallback to a placeholder for this situation (T330943)
return $this->placeholderTempUser;
} elseif ( $this->tempUserCreateActive ) {
- throw new MWException(
+ throw new BadMethodCallException(
"Can't use the request user for preview with IP masking enabled" );
} else {
return $this->context->getUser();
@@ -897,7 +898,7 @@ class EditPage implements IEditObject {
if ( $this->savedTempUser ) {
return $this->savedTempUser;
} elseif ( $this->tempUserCreateActive ) {
- throw new MWException(
+ throw new BadMethodCallException(
"Can't use the request user for storage with IP masking enabled" );
} else {
return $this->context->getUser();
diff --git a/includes/filerepo/file/OldLocalFile.php b/includes/filerepo/file/OldLocalFile.php
index 4321735dca4b..16fe9b83229c 100644
--- a/includes/filerepo/file/OldLocalFile.php
+++ b/includes/filerepo/file/OldLocalFile.php
@@ -247,7 +247,7 @@ class OldLocalFile extends LocalFile {
$this->$name = $value;
}
} else {
- throw new MWException( "Could not find data for image '{$this->archive_name}'." );
+ throw new RuntimeException( "Could not find data for image '{$this->archive_name}'." );
}
}
diff --git a/includes/historyblob/DiffHistoryBlob.php b/includes/historyblob/DiffHistoryBlob.php
index fec18491a50b..1168567e6c64 100644
--- a/includes/historyblob/DiffHistoryBlob.php
+++ b/includes/historyblob/DiffHistoryBlob.php
@@ -73,18 +73,17 @@ class DiffHistoryBlob implements HistoryBlob {
public function __construct() {
if ( !function_exists( 'gzdeflate' ) ) {
- throw new MWException( "Need zlib support to read or write DiffHistoryBlob\n" );
+ throw new RuntimeException( "Need zlib support to read or write DiffHistoryBlob\n" );
}
}
/**
- * @throws MWException
* @param string $text
* @return string
*/
public function addItem( $text ) {
if ( $this->mFrozen ) {
- throw new MWException( __METHOD__ . ": Cannot add more items after sleep/wakeup" );
+ throw new BadMethodCallException( __METHOD__ . ": Cannot add more items after sleep/wakeup" );
}
$this->mItems[] = $text;
@@ -115,12 +114,9 @@ class DiffHistoryBlob implements HistoryBlob {
return $this->getItem( $this->mDefaultKey );
}
- /**
- * @throws MWException
- */
private function compress() {
if ( !function_exists( 'xdiff_string_rabdiff' ) ) {
- throw new MWException( "Need xdiff support to write DiffHistoryBlob\n" );
+ throw new RuntimeException( "Need xdiff support to write DiffHistoryBlob\n" );
}
if ( isset( $this->mDiffs ) ) {
// Already compressed
diff --git a/includes/language/Language.php b/includes/language/Language.php
index bf3c5230a665..dfdcce8a3dda 100644
--- a/includes/language/Language.php
+++ b/includes/language/Language.php
@@ -2648,15 +2648,10 @@ class Language implements Bcp47Code {
}
/**
- * TODO: $s is not always a string per T218883
- *
* @param string $s
* @return string
*/
- public function checkTitleEncoding( $s ) {
- if ( is_array( $s ) ) {
- throw new MWException( 'Given array to checkTitleEncoding.' );
- }
+ public function checkTitleEncoding( string $s ) {
if ( StringUtils::isUtf8( $s ) ) {
return $s;
}
diff --git a/includes/page/MovePage.php b/includes/page/MovePage.php
index bfb84d2ff501..800831329a13 100644
--- a/includes/page/MovePage.php
+++ b/includes/page/MovePage.php
@@ -50,6 +50,7 @@ use MediaWiki\User\UserIdentity;
use MWException;
use RepoGroup;
use RequestContext;
+use RuntimeException;
use StringUtils;
use WatchedItemStoreInterface;
use Wikimedia\Rdbms\IConnectionProvider;
@@ -976,7 +977,8 @@ class MovePage {
$msg = 'Failed to create null revision while moving page ID ' .
$oldid . ' to ' . $nt->getPrefixedDBkey() . " (page ID $id)";
- throw new MWException( $msg );
+ // XXX This should be handled more gracefully
+ throw new RuntimeException( $msg );
}
$nullRevision = $this->revisionStore->insertRevisionOn( $nullRevision, $dbw );
diff --git a/includes/poolcounter/PoolCounterConnectionManager.php b/includes/poolcounter/PoolCounterConnectionManager.php
index 79149b9cb80b..2458cb1f9dcd 100644
--- a/includes/poolcounter/PoolCounterConnectionManager.php
+++ b/includes/poolcounter/PoolCounterConnectionManager.php
@@ -20,8 +20,8 @@
namespace MediaWiki\PoolCounter;
+use InvalidArgumentException;
use MediaWiki\Status\Status;
-use MWException;
use Wikimedia\IPUtils;
/**
@@ -54,15 +54,14 @@ class PoolCounterConnectionManager {
/**
* @param array $conf
- * @throws MWException
*/
public function __construct( $conf ) {
+ if ( !count( $conf['servers'] ) ) {
+ throw new InvalidArgumentException( __METHOD__ . ': no servers configured' );
+ }
$this->hostNames = $conf['servers'];
$this->timeout = $conf['timeout'] ?? 0.1;
$this->connect_timeout = $conf['connect_timeout'] ?? 0;
- if ( !count( $this->hostNames ) ) {
- throw new MWException( __METHOD__ . ': no servers configured' );
- }
}
/**
diff --git a/includes/preferences/DefaultPreferencesFactory.php b/includes/preferences/DefaultPreferencesFactory.php
index 439085e66179..118055eba5ba 100644
--- a/includes/preferences/DefaultPreferencesFactory.php
+++ b/includes/preferences/DefaultPreferencesFactory.php
@@ -54,7 +54,6 @@ use MediaWiki\User\UserGroupMembership;
use MediaWiki\User\UserTimeCorrection;
use Message;
use MessageLocalizer;
-use MWException;
use OOUI\ButtonWidget;
use OOUI\FieldLayout;
use OOUI\HtmlSnippet;
@@ -241,7 +240,6 @@ class DefaultPreferencesFactory implements PreferencesFactory {
}
/**
- * @throws MWException
* @param User $user
* @param IContextSource $context
* @return array
@@ -312,7 +310,6 @@ class DefaultPreferencesFactory implements PreferencesFactory {
/**
* Loads existing values for a given array of preferences
- * @throws MWException
* @param User $user
* @param IContextSource $context
* @param array &$defaultPreferences Array to load values for
@@ -357,7 +354,7 @@ class DefaultPreferencesFactory implements PreferencesFactory {
$info['default'] = $globalDefault;
} else {
$globalDefault = json_encode( $globalDefault );
- throw new MWException(
+ throw new UnexpectedValueException(
"Default '$globalDefault' is invalid for preference $name of user " . $user->getName()
);
}
diff --git a/includes/registration/ExtensionRegistry.php b/includes/registration/ExtensionRegistry.php
index 76f9e01ddd2a..de844d9064bd 100644
--- a/includes/registration/ExtensionRegistry.php
+++ b/includes/registration/ExtensionRegistry.php
@@ -290,17 +290,13 @@ class ExtensionRegistry {
$this->lazyAttributes = [];
}
- /**
- * @throws MWException If the queue is already marked as finished (no further things should
- * be loaded then).
- */
public function loadFromQueue() {
if ( !$this->queued ) {
return;
}
if ( $this->finished ) {
- throw new MWException(
+ throw new LogicException(
"The following paths tried to load late: "
. implode( ', ', array_keys( $this->queued ) )
);
diff --git a/includes/revisiondelete/RevDelList.php b/includes/revisiondelete/RevDelList.php
index f3d32b9a9119..91b226308697 100644
--- a/includes/revisiondelete/RevDelList.php
+++ b/includes/revisiondelete/RevDelList.php
@@ -357,13 +357,12 @@ abstract class RevDelList extends RevisionListBase {
* comment: The log comment
* authorActors: The array of the actor IDs of the offenders
* tags: The array of change tags to apply to the log entry
- * @throws MWException
*/
private function updateLog( $logType, $params ) {
// Get the URL param's corresponding DB field
$field = RevisionDeleter::getRelationType( $this->getType() );
if ( !$field ) {
- throw new MWException( "Bad log URL param type!" );
+ throw new UnexpectedValueException( "Bad log URL param type!" );
}
// Add params for affected page and ids
$logParams = $this->getLogParams( $params );
diff --git a/includes/skins/components/SkinComponentSearch.php b/includes/skins/components/SkinComponentSearch.php
index ebcee9ede33c..04d84fd7c72f 100644
--- a/includes/skins/components/SkinComponentSearch.php
+++ b/includes/skins/components/SkinComponentSearch.php
@@ -2,6 +2,7 @@
namespace MediaWiki\Skin;
+use InvalidArgumentException;
use MediaWiki\Config\Config;
use MediaWiki\Html\Html;
use MediaWiki\Linker\Linker;
@@ -9,7 +10,6 @@ use MediaWiki\MainConfigNames;
use MediaWiki\Title\Title;
use Message;
use MessageLocalizer;
-use MWException;
/**
* This program is free software; you can redistribute it and/or modify
@@ -90,7 +90,6 @@ class SkinComponentSearch implements SkinComponent {
* @param string $mode representing the type of button wanted
* either `go` OR `fulltext`.
* @param array $attrs (optional)
- * @throws MWException if bad value of $mode passed in
* @return string of HTML button
*/
private function makeSearchButton( string $mode, array $attrs = [] ) {
@@ -114,7 +113,7 @@ class SkinComponentSearch implements SkinComponent {
);
return Html::element( 'input', $realAttrs );
default:
- throw new MWException( 'Unknown mode passed to ' . __METHOD__ );
+ throw new InvalidArgumentException( 'Unknown mode passed to ' . __METHOD__ );
}
}
diff --git a/tests/phpunit/includes/Html/HtmlTest.php b/tests/phpunit/includes/Html/HtmlTest.php
index 77704ca126bf..6a0a12905d85 100644
--- a/tests/phpunit/includes/Html/HtmlTest.php
+++ b/tests/phpunit/includes/Html/HtmlTest.php
@@ -267,7 +267,7 @@ class HtmlTest extends MediaWikiIntegrationTestCase {
public function testExpandAttributes_ArrayOnNonListValueAttribute_ThrowsException() {
// Real-life test case found in the Popups extension (see Gerrit cf0fd64),
// when used with an outdated BetaFeatures extension (see Gerrit deda1e7)
- $this->expectException( MWException::class );
+ $this->expectException( UnexpectedValueException::class );
Html::expandAttributes( [
'src' => [
'ltr' => 'ltr.svg',
diff --git a/tests/phpunit/includes/Output/OutputPageTest.php b/tests/phpunit/includes/Output/OutputPageTest.php
index b9d909778ddd..b9bb846a48ec 100644
--- a/tests/phpunit/includes/Output/OutputPageTest.php
+++ b/tests/phpunit/includes/Output/OutputPageTest.php
@@ -1821,7 +1821,7 @@ class OutputPageTest extends MediaWikiIntegrationTestCase {
}
public function testAddWikiTextAsInterfaceNoTitle() {
- $this->expectException( MWException::class );
+ $this->expectException( RuntimeException::class );
$this->expectExceptionMessage( 'Title is null' );
$op = $this->newInstance( [], null, 'notitle' );
@@ -1829,7 +1829,7 @@ class OutputPageTest extends MediaWikiIntegrationTestCase {
}
public function testAddWikiTextAsContentNoTitle() {
- $this->expectException( MWException::class );
+ $this->expectException( RuntimeException::class );
$this->expectExceptionMessage( 'Title is null' );
$op = $this->newInstance( [], null, 'notitle' );
@@ -1991,21 +1991,21 @@ class OutputPageTest extends MediaWikiIntegrationTestCase {
}
public function testParseAsContentNullTitle() {
- $this->expectException( MWException::class );
+ $this->expectException( RuntimeException::class );
$this->expectExceptionMessage( 'Empty $mTitle in MediaWiki\Output\OutputPage::parseInternal' );
$op = $this->newInstance( [], null, 'notitle' );
$op->parseAsContent( '' );
}
public function testParseAsInterfaceNullTitle() {
- $this->expectException( MWException::class );
+ $this->expectException( RuntimeException::class );
$this->expectExceptionMessage( 'Empty $mTitle in MediaWiki\Output\OutputPage::parseInternal' );
$op = $this->newInstance( [], null, 'notitle' );
$op->parseAsInterface( '' );
}
public function testParseInlineAsInterfaceNullTitle() {
- $this->expectException( MWException::class );
+ $this->expectException( RuntimeException::class );
$this->expectExceptionMessage( 'Empty $mTitle in MediaWiki\Output\OutputPage::parseInternal' );
$op = $this->newInstance( [], null, 'notitle' );
$op->parseInlineAsInterface( '' );
diff --git a/tests/phpunit/unit/includes/Html/FormOptionsTest.php b/tests/phpunit/unit/includes/Html/FormOptionsTest.php
index a100879ba4c1..e8918f67c357 100644
--- a/tests/phpunit/unit/includes/Html/FormOptionsTest.php
+++ b/tests/phpunit/unit/includes/Html/FormOptionsTest.php
@@ -44,7 +44,7 @@ class FormOptionsTest extends MediaWikiUnitTestCase {
* @covers MediaWiki\Html\FormOptions::guessType
*/
public function testGuessTypeOnNullThrowException() {
- $this->expectException( MWException::class );
+ $this->expectException( InvalidArgumentException::class );
$this->expectExceptionMessage( 'Unsupported datatype' );
FormOptions::guessType( null );
}
diff --git a/tests/phpunit/unit/includes/registration/ExtensionRegistryTest.php b/tests/phpunit/unit/includes/registration/ExtensionRegistryTest.php
index ae8839d20abc..5802ee814a9c 100644
--- a/tests/phpunit/unit/includes/registration/ExtensionRegistryTest.php
+++ b/tests/phpunit/unit/includes/registration/ExtensionRegistryTest.php
@@ -7,7 +7,6 @@ use ExtensionRegistry;
use LogicException;
use MediaWiki\Settings\SettingsBuilder;
use MediaWikiUnitTestCase;
-use MWException;
use Wikimedia\ScopedCallback;
use Wikimedia\TestingAccessWrapper;
@@ -85,7 +84,7 @@ class ExtensionRegistryTest extends MediaWikiUnitTestCase {
$registry = $this->getRegistry();
$registry->finish();
$registry->queue( "{$this->dataDir}/good.json" );
- $this->expectException( MWException::class );
+ $this->expectException( LogicException::class );
$this->expectExceptionMessage(
"The following paths tried to load late: {$this->dataDir}/good.json" );
$registry->loadFromQueue();