Tests: Delete Link Manager plugin after running REST API plugins controller tests.

After running the multisite PHPUnit test suite, the following files remained, contributing towards a dirty working copy:
{{{
tests/phpunit/data/plugins/link-manager/link-manager.php
tests/phpunit/data/plugins/link-manager/readme.txt
}}}
These files should be deleted after running the tests.

This commit ensures the `link-manager` plugin is deleted during test tear down, which was previously done at the beginning of some test methods, but not afterwards.

Follow-up to [48242], [54300].

Props ironprogrammer.
Fixes #56629.

git-svn-id: https://develop.svn.wordpress.org/trunk@54301 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov 2022-09-25 02:41:22 +00:00
parent 395bae1776
commit 3574efb146

View File

@ -86,10 +86,15 @@ class WP_REST_Plugins_Controller_Test extends WP_Test_REST_Controller_Testcase {
if ( file_exists( WP_PLUGIN_DIR . '/test-plugin/test-plugin.php' ) ) {
$this->rmdir( WP_PLUGIN_DIR . '/test-plugin' );
}
if ( file_exists( DIR_TESTDATA . '/link-manager.zip' ) ) {
unlink( DIR_TESTDATA . '/link-manager.zip' );
}
if ( file_exists( WP_PLUGIN_DIR . '/link-manager/link-manager.php' ) ) {
$this->rmdir( WP_PLUGIN_DIR . '/link-manager' );
}
parent::tear_down();
}
@ -369,10 +374,6 @@ class WP_REST_Plugins_Controller_Test extends WP_Test_REST_Controller_Testcase {
* @ticket 50321
*/
public function test_create_item() {
if ( isset( get_plugins()['link-manager/link-manager.php'] ) ) {
delete_plugins( array( 'link-manager/link-manager.php' ) );
}
wp_set_current_user( self::$super_admin );
$this->setup_plugin_download();
@ -389,10 +390,6 @@ class WP_REST_Plugins_Controller_Test extends WP_Test_REST_Controller_Testcase {
* @ticket 50321
*/
public function test_create_item_and_activate() {
if ( isset( get_plugins()['link-manager/link-manager.php'] ) ) {
delete_plugins( array( 'link-manager/link-manager.php' ) );
}
wp_set_current_user( self::$super_admin );
$this->setup_plugin_download();
@ -415,10 +412,6 @@ class WP_REST_Plugins_Controller_Test extends WP_Test_REST_Controller_Testcase {
* @ticket 50321
*/
public function test_create_item_and_activate_errors_if_no_permission_to_activate_plugin() {
if ( isset( get_plugins()['link-manager/link-manager.php'] ) ) {
delete_plugins( array( 'link-manager/link-manager.php' ) );
}
wp_set_current_user( self::$super_admin );
$this->setup_plugin_download();
$this->disable_activate_permission( 'link-manager/link-manager.php' );
@ -441,10 +434,6 @@ class WP_REST_Plugins_Controller_Test extends WP_Test_REST_Controller_Testcase {
* @ticket 50321
*/
public function test_create_item_and_network_activate_rejected_if_not_multisite() {
if ( isset( get_plugins()['link-manager/link-manager.php'] ) ) {
delete_plugins( array( 'link-manager/link-manager.php' ) );
}
wp_set_current_user( self::$super_admin );
$this->setup_plugin_download();
@ -465,10 +454,6 @@ class WP_REST_Plugins_Controller_Test extends WP_Test_REST_Controller_Testcase {
* @ticket 50321
*/
public function test_create_item_and_network_activate() {
if ( isset( get_plugins()['link-manager/link-manager.php'] ) ) {
delete_plugins( array( 'link-manager/link-manager.php' ) );
}
wp_set_current_user( self::$super_admin );
$this->setup_plugin_download();