From 3574efb146a5173b374b90db9b3879ed142cbe30 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Sun, 25 Sep 2022 02:41:22 +0000 Subject: [PATCH] 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 --- .../rest-api/rest-plugins-controller.php | 25 ++++--------------- 1 file changed, 5 insertions(+), 20 deletions(-) diff --git a/tests/phpunit/tests/rest-api/rest-plugins-controller.php b/tests/phpunit/tests/rest-api/rest-plugins-controller.php index 3cea054301..fee1aa0494 100644 --- a/tests/phpunit/tests/rest-api/rest-plugins-controller.php +++ b/tests/phpunit/tests/rest-api/rest-plugins-controller.php @@ -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();