mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Math
synced 2024-11-23 23:25:02 +00:00
tests: @expectedException is deprecated
Bug: T234597 Change-Id: Ib694f60dabc9a8ac94fb10ed187892af8f36377e
This commit is contained in:
parent
6e8ca25d46
commit
abbe5a3714
|
@ -7,8 +7,6 @@
|
|||
<exclude name="MediaWiki.Commenting.FunctionComment.MissingDocumentationPublic" />
|
||||
<exclude name="MediaWiki.WhiteSpace.SpaceBeforeSingleLineComment.NewLineComment" />
|
||||
<exclude name="PSR12.Properties.ConstantVisibility.NotFound" />
|
||||
<exclude name="MediaWiki.Commenting.PhpunitAnnotations.ForbiddenExpectedException" />
|
||||
<exclude name="MediaWiki.Commenting.PhpunitAnnotations.ForbiddenExpectedExceptionMessage" />
|
||||
</rule>
|
||||
<file>.</file>
|
||||
<arg name="extensions" value="php,php5,inc" />
|
||||
|
|
|
@ -42,19 +42,15 @@ class MathFormatterTest extends MediaWikiTestCase {
|
|||
$this->assertSame( SnakFormatter::FORMAT_PLAIN, $formatter->getFormat(), 'test getFormat' );
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException InvalidArgumentException
|
||||
*/
|
||||
public function testNotStringValue() {
|
||||
$formatter = new MathFormatter( SnakFormatter::FORMAT_PLAIN );
|
||||
$this->expectException( InvalidArgumentException::class );
|
||||
$formatter->format( new NumberValue( 0 ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException InvalidArgumentException
|
||||
*/
|
||||
public function testNullValue() {
|
||||
$formatter = new MathFormatter( SnakFormatter::FORMAT_PLAIN );
|
||||
$this->expectException( InvalidArgumentException::class );
|
||||
$formatter->format( null );
|
||||
}
|
||||
|
||||
|
|
|
@ -66,56 +66,50 @@ class MathRestbaseInterfaceTest extends MediaWikiTestCase {
|
|||
$this->assertContains( '<mtext>H</mtext>', $rbi->getMathML() );
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException MWException
|
||||
* @expectedExceptionMessage TeX input is invalid.
|
||||
*/
|
||||
public function testException() {
|
||||
$input = '\\newcommand';
|
||||
$rbi = new MathRestbaseInterface( $input );
|
||||
$this->expectException( MWException::class );
|
||||
$this->expectExceptionMessage( 'TeX input is invalid.' );
|
||||
$rbi->getMathML();
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException MWException
|
||||
* @expectedExceptionMessage TeX input is invalid.
|
||||
*/
|
||||
public function testExceptionSvg() {
|
||||
$input = '\\newcommand';
|
||||
$rbi = new MathRestbaseInterface( $input );
|
||||
$this->expectException( MWException::class );
|
||||
$this->expectExceptionMessage( 'TeX input is invalid.' );
|
||||
$rbi->getFullSvgUrl();
|
||||
}
|
||||
|
||||
/**
|
||||
* Incorporate the "details" in the error message, if the check requests passes, but the
|
||||
* mml/svg/complete endpoints returns an error
|
||||
* @expectedException MWException
|
||||
* @expectedExceptionMessage Cannot get mml. TeX parse error: Missing close brace
|
||||
*/
|
||||
public function testLateError() {
|
||||
// phpcs:ignore Generic.Files.LineLength.TooLong
|
||||
$input = '{"type":"https://mediawiki.org/wiki/HyperSwitch/errors/bad_request","title":"Bad Request","method":"POST","detail":["TeX parse error: Missing close brace"],"uri":"/complete"}';
|
||||
$this->expectException( MWException::class );
|
||||
$this->expectExceptionMessage( 'Cannot get mml. TeX parse error: Missing close brace' );
|
||||
MathRestbaseInterface::throwContentError( 'mml', $input );
|
||||
}
|
||||
|
||||
/**
|
||||
* Incorporate the "details" in the error message, if the check requests passes, but the
|
||||
* mml/svg/complete endpoints returns an error
|
||||
* @expectedException MWException
|
||||
* @expectedExceptionMessage Cannot get mml. TeX parse error: Missing close brace
|
||||
*/
|
||||
public function testLateErrorString() {
|
||||
// phpcs:ignore Generic.Files.LineLength.TooLong
|
||||
$input = '{"type":"https://mediawiki.org/wiki/HyperSwitch/errors/bad_request","title":"Bad Request","method":"POST","detail": "TeX parse error: Missing close brace","uri":"/complete"}';
|
||||
$this->expectException( MWException::class );
|
||||
$this->expectExceptionMessage( 'Cannot get mml. TeX parse error: Missing close brace' );
|
||||
MathRestbaseInterface::throwContentError( 'mml', $input );
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException MWException
|
||||
* @expectedExceptionMessage Cannot get mml. Server problem.
|
||||
*/
|
||||
public function testLateErrorNoDetail() {
|
||||
$input = '';
|
||||
$this->expectException( MWException::class );
|
||||
$this->expectExceptionMessage( 'Cannot get mml. Server problem.' );
|
||||
MathRestbaseInterface::throwContentError( 'mml', $input );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,19 +37,15 @@ class MathValidatorTest extends MediaWikiTestCase {
|
|||
parent::tearDown();
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException InvalidArgumentException
|
||||
*/
|
||||
public function testNotStringValue() {
|
||||
$validator = new MathValidator();
|
||||
$this->expectException( InvalidArgumentException::class );
|
||||
$validator->validate( new NumberValue( 0 ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException InvalidArgumentException
|
||||
*/
|
||||
public function testNullValue() {
|
||||
$validator = new MathValidator();
|
||||
$this->expectException( InvalidArgumentException::class );
|
||||
$validator->validate( null );
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue