Tests: Consistently use the expectException() method instead of the older @expectedException annotation.

See https://thephp.cc/news/2016/02/questioning-phpunit-best-practices

The method is available since PHPUnit 5.2, and WordPress currently supports PHPUnit 5.4 as the minimum version.

Follow-up to [48993].

See #51344.

git-svn-id: https://develop.svn.wordpress.org/trunk@48996 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov
2020-09-18 13:22:22 +00:00
parent f78acee893
commit d46af0956d
10 changed files with 22 additions and 27 deletions
@@ -163,7 +163,7 @@ class Tests_Privacy_WpPrivacyGeneratePersonalDataExportFile extends WP_UnitTestC
public function test_rejects_remove_requests() {
$request_id = wp_create_user_request( 'removal-requester@example.com', 'remove_personal_data' );
$this->setExpectedException( 'WPDieException' );
$this->expectException( 'WPDieException' );
$this->expectOutputString( '{"success":false,"data":"Invalid request ID when generating export file."}' );
wp_privacy_generate_personal_data_export_file( $request_id );
}
@@ -174,7 +174,7 @@ class Tests_Privacy_WpPrivacyGeneratePersonalDataExportFile extends WP_UnitTestC
* @ticket 44233
*/
public function test_invalid_request_id() {
$this->setExpectedException( 'WPDieException' );
$this->expectException( 'WPDieException' );
$this->expectOutputString( '{"success":false,"data":"Invalid request ID when generating export file."}' );
wp_privacy_generate_personal_data_export_file( 123456789 );
}
@@ -194,7 +194,7 @@ class Tests_Privacy_WpPrivacyGeneratePersonalDataExportFile extends WP_UnitTestC
)
);
$this->setExpectedException( 'WPDieException' );
$this->expectException( 'WPDieException' );
$this->expectOutputString( '{"success":false,"data":"Invalid email address when generating export file."}' );
wp_privacy_generate_personal_data_export_file( $request_id );
}
@@ -208,7 +208,7 @@ class Tests_Privacy_WpPrivacyGeneratePersonalDataExportFile extends WP_UnitTestC
// Create a file with the folder name to ensure the function cannot create a folder.
touch( untrailingslashit( self::$exports_dir ) );
$this->setExpectedException( 'WPDieException' );
$this->expectException( 'WPDieException' );
$this->expectOutputString( '{"success":false,"data":"Unable to create export folder."}' );
wp_privacy_generate_personal_data_export_file( self::$export_request_id );
}