From e85543f68b294da9d648120d7aec03213cba41c2 Mon Sep 17 00:00:00 2001 From: Boone Gorges Date: Tue, 30 Dec 2014 19:30:07 +0000 Subject: [PATCH] When no plugins are active, return an empty array from `validate_active_plugins()`. This creates parity with the behavior of the function when plugins *are* active, but none are invalid. It also makes it possible to write unit tests for the function. Props sgrant. Fixes #30860. git-svn-id: https://develop.svn.wordpress.org/trunk@31003 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/includes/plugin.php | 2 +- tests/phpunit/tests/admin/includesPlugin.php | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/wp-admin/includes/plugin.php b/src/wp-admin/includes/plugin.php index e2e37761d8..d4029073da 100644 --- a/src/wp-admin/includes/plugin.php +++ b/src/wp-admin/includes/plugin.php @@ -884,7 +884,7 @@ function validate_active_plugins() { } if ( empty( $plugins ) ) - return; + return array(); $invalid = array(); diff --git a/tests/phpunit/tests/admin/includesPlugin.php b/tests/phpunit/tests/admin/includesPlugin.php index d4d197de49..b6dd5c2614 100644 --- a/tests/phpunit/tests/admin/includesPlugin.php +++ b/tests/phpunit/tests/admin/includesPlugin.php @@ -292,6 +292,13 @@ class Tests_Admin_includesPlugin extends WP_UnitTestCase { $this->assertTrue( isset( $result[ $plugin[ 0 ] ] ) ); } + /** + * @covers ::validate_active_plugins + */ + public function test_validate_active_plugins_empty() { + $this->assertEquals( array(), validate_active_plugins() ); + } + /** * @covers ::is_uninstallable_plugin */