tests: @expectedException is deprecated

Bug: T234597
Change-Id: Ib694f60dabc9a8ac94fb10ed187892af8f36377e
This commit is contained in:
Max Semenik 2019-10-15 19:28:43 -07:00 committed by James D. Forrester
parent 6e8ca25d46
commit abbe5a3714
4 changed files with 14 additions and 30 deletions

View file

@ -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" />

View file

@ -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 );
}

View file

@ -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 );
}
}

View file

@ -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 );
}