Tests: Simplify PluralFormsTest::test_exceptions()
.
Previously, the test had to use an older pattern for catching the generic `Exception` exceptions for compatibility with PHPUnit 3.6 on PHP 5.2. Now that WordPress supports PHPUnit 5.4 as the minimum version, the `expectException()` method can be used directly. Follow-up to [41725], [41730]. See #51344. git-svn-id: https://develop.svn.wordpress.org/trunk@48999 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
ba20847ef5
commit
2f491fba50
@ -199,25 +199,17 @@ class PluralFormsTest extends WP_UnitTestCase {
|
||||
/**
|
||||
* Ensures that an exception is thrown when an invalid plural form is encountered.
|
||||
*
|
||||
* The `@expectedException Exception` notation for PHPUnit cannot be used because expecting an
|
||||
* exception of type `Exception` is not supported before PHPUnit 3.7. The CI tests for PHP 5.2
|
||||
* run on PHPUnit 3.6.
|
||||
*
|
||||
* @ticket 41562
|
||||
* @dataProvider data_exceptions
|
||||
*/
|
||||
public function test_exceptions( $expression, $expected_exception, $call_get ) {
|
||||
try {
|
||||
$plural_forms = new Plural_Forms( $expression );
|
||||
if ( $call_get ) {
|
||||
$plural_forms->get( 1 );
|
||||
}
|
||||
} catch ( Exception $e ) {
|
||||
$this->assertSame( $expected_exception, $e->getMessage() );
|
||||
return;
|
||||
}
|
||||
public function test_exceptions( $expression, $expected_message, $call_get ) {
|
||||
$this->expectException( 'Exception' );
|
||||
$this->expectExceptionMessage( $expected_message );
|
||||
|
||||
$this->fail( 'Expected exception was not thrown.' );
|
||||
$plural_forms = new Plural_Forms( $expression );
|
||||
if ( $call_get ) {
|
||||
$plural_forms->get( 1 );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user