diff --git a/tests/phpunit/tests/admin/plugin-dependencies/getDependencies.php b/tests/phpunit/tests/admin/plugin-dependencies/GetDependenciesTest.php similarity index 79% rename from tests/phpunit/tests/admin/plugin-dependencies/getDependencies.php rename to tests/phpunit/tests/admin/plugin-dependencies/GetDependenciesTest.php index ca9510493e222..cec1effd9664b 100644 --- a/tests/phpunit/tests/admin/plugin-dependencies/getDependencies.php +++ b/tests/phpunit/tests/admin/plugin-dependencies/GetDependenciesTest.php @@ -5,15 +5,20 @@ * @package WordPress */ +namespace WordPress\Tests\Admin\PluginDependencies; + +use WP_Plugin_Dependencies; +use WP_PluginDependencies_UnitTestCase; + require_once __DIR__ . '/base.php'; /** * @group admin * @group plugins * - * @covers WP_Plugin_Dependencies::get_dependencies + * @covers \WP_Plugin_Dependencies::get_dependencies */ -class Tests_Admin_WPPluginDependencies_GetDependencies extends WP_PluginDependencies_UnitTestCase { +class GetDependenciesTest extends WP_PluginDependencies_UnitTestCase { /** * Tests that a plugin with no dependencies will return an empty array. diff --git a/tests/phpunit/tests/admin/plugin-dependencies/getDependencyData.php b/tests/phpunit/tests/admin/plugin-dependencies/GetDependencyDataTest.php similarity index 89% rename from tests/phpunit/tests/admin/plugin-dependencies/getDependencyData.php rename to tests/phpunit/tests/admin/plugin-dependencies/GetDependencyDataTest.php index 79b235d2f21a1..915602dd62541 100644 --- a/tests/phpunit/tests/admin/plugin-dependencies/getDependencyData.php +++ b/tests/phpunit/tests/admin/plugin-dependencies/GetDependencyDataTest.php @@ -5,16 +5,21 @@ * @package WordPress */ +namespace WordPress\Tests\Admin\PluginDependencies; + +use WP_Plugin_Dependencies; +use WP_PluginDependencies_UnitTestCase; + require_once __DIR__ . '/base.php'; /** * @group admin * @group plugins * - * @covers WP_Plugin_Dependencies::get_dependency_data - * @covers WP_Plugin_Dependencies::get_dependency_api_data + * @covers \WP_Plugin_Dependencies::get_dependency_data + * @covers \WP_Plugin_Dependencies::get_dependency_api_data */ -class Tests_Admin_WPPluginDependencies_GetDependencyData extends WP_PluginDependencies_UnitTestCase { +class GetDependencyDataTest extends WP_PluginDependencies_UnitTestCase { /** * Tests that dependency data is retrieved. diff --git a/tests/phpunit/tests/admin/plugin-dependencies/getDependencyFilepath.php b/tests/phpunit/tests/admin/plugin-dependencies/GetDependencyFilepathTest.php similarity index 84% rename from tests/phpunit/tests/admin/plugin-dependencies/getDependencyFilepath.php rename to tests/phpunit/tests/admin/plugin-dependencies/GetDependencyFilepathTest.php index 04b4948e63f72..7c5c6ab25692f 100644 --- a/tests/phpunit/tests/admin/plugin-dependencies/getDependencyFilepath.php +++ b/tests/phpunit/tests/admin/plugin-dependencies/GetDependencyFilepathTest.php @@ -5,17 +5,22 @@ * @package WordPress */ +namespace WordPress\Tests\Admin\PluginDependencies; + +use WP_Plugin_Dependencies; +use WP_PluginDependencies_UnitTestCase; + require_once __DIR__ . '/base.php'; /** * @group admin * @group plugins * - * @covers WP_Plugin_Dependencies::get_dependency_filepath - * @covers WP_Plugin_Dependencies::get_dependency_filepaths - * @covers WP_Plugin_Dependencies::get_plugin_dirnames + * @covers \WP_Plugin_Dependencies::get_dependency_filepath + * @covers \WP_Plugin_Dependencies::get_dependency_filepaths + * @covers \WP_Plugin_Dependencies::get_plugin_dirnames */ -class Tests_Admin_WPPluginDependencies_GetDependencyFilepath extends WP_PluginDependencies_UnitTestCase { +class GetDependencyFilepathTest extends WP_PluginDependencies_UnitTestCase { /** * Tests that false is returned if Plugin Dependencies has not been initialized. @@ -50,7 +55,7 @@ public function test_should_return_false_before_initialization() { * * @param string[] $dependency_slug The dependency slug. * @param string[] $plugins An array of plugin paths. - * @param string|false $expected The expected result. + * @param string|false $expected The expected result. */ public function test_should_return_filepaths_for_installed_dependencies( $dependency_slug, $plugins, $expected ) { $this->set_property_value( 'plugins', $plugins ); @@ -85,28 +90,28 @@ public function data_get_dependency_filepath() { 'expected' => false, ), 'a plugin that ends with slug/' => array( - 'dependency_slugs' => 'dependency', - 'plugins' => array( + 'dependency_slug' => 'dependency', + 'plugins' => array( 'addon-for-dependency/dependency.php' => array( 'RequiresPlugins' => '' ), 'dependent/dependent.php' => array( 'RequiresPlugins' => 'dependency' ), ), - 'expected' => false, + 'expected' => false, ), 'a plugin that does not exist' => array( - 'dependency_slugs' => 'dependency2', - 'plugins' => array( + 'dependency_slug' => 'dependency2', + 'plugins' => array( 'dependency/dependency.php' => array( 'RequiresPlugins' => '' ), 'dependent/dependent.php' => array( 'RequiresPlugins' => 'dependency2' ), ), - 'expected' => false, + 'expected' => false, ), 'a plugin that exists' => array( - 'dependency_slugs' => 'dependency', - 'plugins' => array( + 'dependency_slug' => 'dependency', + 'plugins' => array( 'dependency/dependency.php' => array( 'RequiresPlugins' => '' ), 'dependent/dependent.php' => array( 'RequiresPlugins' => 'dependency' ), ), - 'expected' => 'dependency/dependency.php', + 'expected' => 'dependency/dependency.php', ), ); } diff --git a/tests/phpunit/tests/admin/plugin-dependencies/getDependencyNames.php b/tests/phpunit/tests/admin/plugin-dependencies/GetDependencyNamesTest.php similarity index 93% rename from tests/phpunit/tests/admin/plugin-dependencies/getDependencyNames.php rename to tests/phpunit/tests/admin/plugin-dependencies/GetDependencyNamesTest.php index 2b4fd7ef7922d..8d6f130ed29d0 100644 --- a/tests/phpunit/tests/admin/plugin-dependencies/getDependencyNames.php +++ b/tests/phpunit/tests/admin/plugin-dependencies/GetDependencyNamesTest.php @@ -5,18 +5,24 @@ * @package WordPress */ +namespace WordPress\Tests\Admin\PluginDependencies; + +use WP_Error; +use WP_Plugin_Dependencies; +use WP_PluginDependencies_UnitTestCase; + require_once __DIR__ . '/base.php'; /** * @group admin * @group plugins * - * @covers WP_Plugin_Dependencies::get_dependency_names - * @covers WP_Plugin_Dependencies::get_dependency_api_data - * @covers WP_Plugin_Dependencies::get_dependencies - * @covers WP_Plugin_Dependencies::get_dependency_filepaths + * @covers \WP_Plugin_Dependencies::get_dependency_names + * @covers \WP_Plugin_Dependencies::get_dependency_api_data + * @covers \WP_Plugin_Dependencies::get_dependencies + * @covers \WP_Plugin_Dependencies::get_dependency_filepaths */ -class Tests_Admin_WPPluginDependencies_GetDependencyNames extends WP_PluginDependencies_UnitTestCase { +class GetDependencyNamesTest extends WP_PluginDependencies_UnitTestCase { /** * Mocks an API response. diff --git a/tests/phpunit/tests/admin/plugin-dependencies/getDependentFilepath.php b/tests/phpunit/tests/admin/plugin-dependencies/GetDependentFilepathTest.php similarity index 84% rename from tests/phpunit/tests/admin/plugin-dependencies/getDependentFilepath.php rename to tests/phpunit/tests/admin/plugin-dependencies/GetDependentFilepathTest.php index 1cfdb30b137bf..0d4218d9cb54f 100644 --- a/tests/phpunit/tests/admin/plugin-dependencies/getDependentFilepath.php +++ b/tests/phpunit/tests/admin/plugin-dependencies/GetDependentFilepathTest.php @@ -5,16 +5,21 @@ * @package WordPress */ +namespace WordPress\Tests\Admin\PluginDependencies; + +use WP_Plugin_Dependencies; +use WP_PluginDependencies_UnitTestCase; + require_once __DIR__ . '/base.php'; /** * @group admin * @group plugins * - * @covers WP_Plugin_Dependencies::get_dependent_filepath - * @covers WP_Plugin_Dependencies::get_plugin_dirnames + * @covers \WP_Plugin_Dependencies::get_dependent_filepath + * @covers \WP_Plugin_Dependencies::get_plugin_dirnames */ -class Tests_Admin_WPPluginDependencies_GetDependentFilepath extends WP_PluginDependencies_UnitTestCase { +class GetDependentFilepathTest extends WP_PluginDependencies_UnitTestCase { /** * Tests that the expected dependent filepath is retrieved. @@ -24,7 +29,7 @@ class Tests_Admin_WPPluginDependencies_GetDependentFilepath extends WP_PluginDep * @dataProvider data_get_dependent_filepath * * @param string $dependent_slug The dependent slug. - * @param string[] $plugins An array of plugin data. + * @param array $plugins An array of plugin data. * @param string|false $expected The expected result. */ public function test_should_return_filepaths_for_installed_dependents( $dependent_slug, $plugins, $expected ) { diff --git a/tests/phpunit/tests/admin/plugin-dependencies/getDependentNames.php b/tests/phpunit/tests/admin/plugin-dependencies/GetDependentNamesTest.php similarity index 78% rename from tests/phpunit/tests/admin/plugin-dependencies/getDependentNames.php rename to tests/phpunit/tests/admin/plugin-dependencies/GetDependentNamesTest.php index 751e588c21231..7462ee6bd076a 100644 --- a/tests/phpunit/tests/admin/plugin-dependencies/getDependentNames.php +++ b/tests/phpunit/tests/admin/plugin-dependencies/GetDependentNamesTest.php @@ -5,18 +5,23 @@ * @package WordPress */ +namespace WordPress\Tests\Admin\PluginDependencies; + +use WP_Plugin_Dependencies; +use WP_PluginDependencies_UnitTestCase; + require_once __DIR__ . '/base.php'; /** * @group admin * @group plugins * - * @covers WP_Plugin_Dependencies::get_dependent_names - * @covers WP_Plugin_Dependencies::get_plugins - * @covers WP_Plugin_Dependencies::convert_to_slug - * @covers WP_Plugin_Dependencies::get_dependents + * @covers \WP_Plugin_Dependencies::get_dependent_names + * @covers \WP_Plugin_Dependencies::get_plugins + * @covers \WP_Plugin_Dependencies::convert_to_slug + * @covers \WP_Plugin_Dependencies::get_dependents */ -class Tests_Admin_WPPluginDependencies_GetDependentNames extends WP_PluginDependencies_UnitTestCase { +class GetDependentNamesTest extends WP_PluginDependencies_UnitTestCase { /** * Tests that dependent names are retrieved. diff --git a/tests/phpunit/tests/admin/plugin-dependencies/getDependents.php b/tests/phpunit/tests/admin/plugin-dependencies/GetDependentsTest.php similarity index 81% rename from tests/phpunit/tests/admin/plugin-dependencies/getDependents.php rename to tests/phpunit/tests/admin/plugin-dependencies/GetDependentsTest.php index da8522bfb7818..be9a14cc0c102 100644 --- a/tests/phpunit/tests/admin/plugin-dependencies/getDependents.php +++ b/tests/phpunit/tests/admin/plugin-dependencies/GetDependentsTest.php @@ -5,15 +5,20 @@ * @package WordPress */ +namespace WordPress\Tests\Admin\PluginDependencies; + +use WP_Plugin_Dependencies; +use WP_PluginDependencies_UnitTestCase; + require_once __DIR__ . '/base.php'; /** * @group admin * @group plugins * - * @covers WP_Plugin_Dependencies::get_dependents + * @covers \WP_Plugin_Dependencies::get_dependents */ -class Tests_Admin_WPPluginDependencies_GetDependents extends WP_PluginDependencies_UnitTestCase { +class GetDependentsTest extends WP_PluginDependencies_UnitTestCase { /** * Tests that a plugin with no dependents will return an empty array. diff --git a/tests/phpunit/tests/admin/plugin-dependencies/HasActiveDependentsTest.php b/tests/phpunit/tests/admin/plugin-dependencies/HasActiveDependentsTest.php new file mode 100644 index 0000000000000..d1b88d2631a5f --- /dev/null +++ b/tests/phpunit/tests/admin/plugin-dependencies/HasActiveDependentsTest.php @@ -0,0 +1,126 @@ +set_property_value( 'dependencies', $dependencies ); + + if ( ! empty( $active_plugins ) ) { + update_option( 'active_plugins', $active_plugins ); + } + + $this->assertSame( $expected, self::$instance::has_active_dependents( $plugin_to_check ) ); + } + + /** + * Data provider for test_has_active_dependents. + * + * @return array[] + */ + public function data_has_active_dependents() { + return array( + 'no dependents for plugin' => array( + 'dependencies' => array( 'dependent/dependent.php' => array( 'dependency' ) ), + 'active_plugins' => array( 'dependent/dependent.php' ), + 'plugin_to_check' => 'dependency2/dependency2.php', + 'expected' => false, + ), + 'active dependent exists' => array( + 'dependencies' => array( 'dependent/dependent.php' => array( 'dependency' ) ), + 'active_plugins' => array( 'dependent/dependent.php' ), + 'plugin_to_check' => 'dependency/dependency.php', + 'expected' => true, + ), + 'one inactive and one active dependent' => array( + 'dependencies' => array( + 'dependent2/dependent2.php' => array( 'dependency' ), + 'dependent/dependent.php' => array( 'dependency' ), + ), + 'active_plugins' => array( 'dependent/dependent.php' ), + 'plugin_to_check' => 'dependency/dependency.php', + 'expected' => true, + ), + 'one active and one inactive dependent' => array( + 'dependencies' => array( + 'dependent/dependent.php' => array( 'dependency' ), + 'dependent2/dependent2.php' => array( 'dependency' ), + ), + 'active_plugins' => array( 'dependent/dependent.php' ), + 'plugin_to_check' => 'dependency/dependency.php', + 'expected' => true, + ), + 'earlier plugin has active dependents, checking earlier plugin' => array( + 'dependencies' => array( + 'dependent/dependent.php' => array( 'dependency' ), + 'dependent2/dependent2.php' => array( 'dependency2' ), + ), + 'active_plugins' => array( 'dependent/dependent.php' ), + 'plugin_to_check' => 'dependency/dependency.php', + 'expected' => true, + ), + 'later plugin has active dependents, checking later plugin' => array( + 'dependencies' => array( + 'dependent/dependent.php' => array( 'dependency' ), + 'dependent2/dependent2.php' => array( 'dependency2' ), + ), + 'active_plugins' => array( 'dependent2/dependent2.php' ), + 'plugin_to_check' => 'dependency2/dependency2.php', + 'expected' => true, + ), + 'dependent is inactive' => array( + 'dependencies' => array( 'dependent/dependent.php' => array( 'dependency' ) ), + 'active_plugins' => array(), + 'plugin_to_check' => 'dependency/dependency.php', + 'expected' => false, + ), + 'earlier plugin has no active dependents, checking earlier plugin' => array( + 'dependencies' => array( + 'dependent/dependent.php' => array( 'dependency' ), + 'dependent2/dependent2.php' => array( 'dependency2' ), + ), + 'active_plugins' => array( 'dependent2/dependent2.php' ), + 'plugin_to_check' => 'dependency/dependency.php', + 'expected' => false, + ), + 'later plugin has no active dependents, checking later plugin' => array( + 'dependencies' => array( + 'dependent/dependent.php' => array( 'dependency' ), + 'dependent2/dependent2.php' => array( 'dependency2' ), + ), + 'active_plugins' => array( 'dependent/dependent.php' ), + 'plugin_to_check' => 'dependency2/dependency2.php', + 'expected' => false, + ), + ); + } +} diff --git a/tests/phpunit/tests/admin/plugin-dependencies/hasCircularDependency.php b/tests/phpunit/tests/admin/plugin-dependencies/HasCircularDependencyTest.php similarity index 91% rename from tests/phpunit/tests/admin/plugin-dependencies/hasCircularDependency.php rename to tests/phpunit/tests/admin/plugin-dependencies/HasCircularDependencyTest.php index 10d00d96b7637..08a09ace5bd70 100644 --- a/tests/phpunit/tests/admin/plugin-dependencies/hasCircularDependency.php +++ b/tests/phpunit/tests/admin/plugin-dependencies/HasCircularDependencyTest.php @@ -5,17 +5,22 @@ * @package WordPress */ +namespace WordPress\Tests\Admin\PluginDependencies; + +use WP_Plugin_Dependencies; +use WP_PluginDependencies_UnitTestCase; + require_once __DIR__ . '/base.php'; /** * @group admin * @group plugins * - * @covers WP_Plugin_Dependencies::has_circular_dependency - * @covers WP_Plugin_Dependencies::get_circular_dependencies - * @covers WP_Plugin_Dependencies::check_for_circular_dependencies + * @covers \WP_Plugin_Dependencies::has_circular_dependency + * @covers \WP_Plugin_Dependencies::get_circular_dependencies + * @covers \WP_Plugin_Dependencies::check_for_circular_dependencies */ -class Tests_Admin_WPPluginDependencies_HasCircularDependency extends WP_PluginDependencies_UnitTestCase { +class HasCircularDependencyTest extends WP_PluginDependencies_UnitTestCase { /** * Tests that false is returned if Plugin Dependencies has not been initialized. diff --git a/tests/phpunit/tests/admin/plugin-dependencies/hasDependencies.php b/tests/phpunit/tests/admin/plugin-dependencies/HasDependenciesTest.php similarity index 78% rename from tests/phpunit/tests/admin/plugin-dependencies/hasDependencies.php rename to tests/phpunit/tests/admin/plugin-dependencies/HasDependenciesTest.php index bd59b6acfea98..9372ce3516f73 100644 --- a/tests/phpunit/tests/admin/plugin-dependencies/hasDependencies.php +++ b/tests/phpunit/tests/admin/plugin-dependencies/HasDependenciesTest.php @@ -5,15 +5,20 @@ * @package WordPress */ +namespace WordPress\Tests\Admin\PluginDependencies; + +use WP_Plugin_Dependencies; +use WP_PluginDependencies_UnitTestCase; + require_once __DIR__ . '/base.php'; /** * @group admin * @group plugins * - * @covers WP_Plugin_Dependencies::has_dependencies + * @covers \WP_Plugin_Dependencies::has_dependencies */ -class Tests_Admin_WPPluginDependencies_HasDependencies extends WP_PluginDependencies_UnitTestCase { +class HasDependenciesTest extends WP_PluginDependencies_UnitTestCase { /** * Tests that a plugin with dependencies will return true. diff --git a/tests/phpunit/tests/admin/plugin-dependencies/hasDependents.php b/tests/phpunit/tests/admin/plugin-dependencies/HasDependentsTest.php similarity index 83% rename from tests/phpunit/tests/admin/plugin-dependencies/hasDependents.php rename to tests/phpunit/tests/admin/plugin-dependencies/HasDependentsTest.php index 43093537ba992..2c7857f38f4e8 100644 --- a/tests/phpunit/tests/admin/plugin-dependencies/hasDependents.php +++ b/tests/phpunit/tests/admin/plugin-dependencies/HasDependentsTest.php @@ -5,16 +5,21 @@ * @package WordPress */ +namespace WordPress\Tests\Admin\PluginDependencies; + +use WP_Plugin_Dependencies; +use WP_PluginDependencies_UnitTestCase; + require_once __DIR__ . '/base.php'; /** * @group admin * @group plugins * - * @covers WP_Plugin_Dependencies::has_dependents - * @covers WP_Plugin_Dependencies::convert_to_slug + * @covers \WP_Plugin_Dependencies::has_dependents + * @covers \WP_Plugin_Dependencies::convert_to_slug */ -class Tests_Admin_WPPluginDependencies_HasDependents extends WP_PluginDependencies_UnitTestCase { +class HasDependentsTest extends WP_PluginDependencies_UnitTestCase { /** * Tests that a plugin with dependents will return true. diff --git a/tests/phpunit/tests/admin/plugin-dependencies/HasUnmetDependenciesTest.php b/tests/phpunit/tests/admin/plugin-dependencies/HasUnmetDependenciesTest.php new file mode 100644 index 0000000000000..9d9fa180d61b1 --- /dev/null +++ b/tests/phpunit/tests/admin/plugin-dependencies/HasUnmetDependenciesTest.php @@ -0,0 +1,111 @@ +set_property_value( 'dependencies', $dependencies ); + + if ( ! empty( $dependency_filepaths ) ) { + $this->set_property_value( 'dependency_filepaths', $dependency_filepaths ); + } + + if ( ! empty( $active_plugins ) ) { + update_option( 'active_plugins', $active_plugins ); + } + + $this->assertSame( $expected, self::$instance::has_unmet_dependencies( $plugin_to_check ) ); + } + + /** + * Data provider for test_has_unmet_dependencies. + * + * @return array[] + */ + public function data_has_unmet_dependencies() { + return array( + 'no dependencies for plugin' => array( + 'dependencies' => array( 'dependent/dependent.php' => array( 'dependency' ) ), + 'dependency_filepaths' => array(), + 'active_plugins' => array(), + 'plugin_to_check' => 'dependent2/dependent2.php', + 'expected' => false, + ), + 'dependencies are installed and active' => array( + 'dependencies' => array( 'dependent/dependent.php' => array( 'dependency' ) ), + 'dependency_filepaths' => array( 'dependency' => 'dependency/dependency.php' ), + 'active_plugins' => array( 'dependency/dependency.php' ), + 'plugin_to_check' => 'dependent/dependent.php', + 'expected' => false, + ), + 'dependency is not installed' => array( + 'dependencies' => array( 'dependent/dependent.php' => array( 'dependency' ) ), + 'dependency_filepaths' => array(), + 'active_plugins' => array(), + 'plugin_to_check' => 'dependent/dependent.php', + 'expected' => true, + ), + 'dependency is inactive' => array( + 'dependencies' => array( 'dependent/dependent.php' => array( 'dependency' ) ), + 'dependency_filepaths' => array( 'dependency' => 'dependency/dependency.php' ), + 'active_plugins' => array(), + 'plugin_to_check' => 'dependent/dependent.php', + 'expected' => true, + ), + 'one active and one inactive dependency' => array( + 'dependencies' => array( 'dependent/dependent.php' => array( 'dependency', 'dependency2' ) ), + 'dependency_filepaths' => array( + 'dependency' => 'dependency/dependency.php', + 'dependency2' => 'dependency2/dependency2.php', + ), + 'active_plugins' => array( 'dependency/dependency.php' ), + 'plugin_to_check' => 'dependent/dependent.php', + 'expected' => true, + ), + 'one active and one uninstalled dependency' => array( + 'dependencies' => array( 'dependent/dependent.php' => array( 'dependency', 'dependency2' ) ), + 'dependency_filepaths' => array( 'dependency' => 'dependency/dependency.php' ), + 'active_plugins' => array( 'dependency/dependency.php' ), + 'plugin_to_check' => 'dependent/dependent.php', + 'expected' => true, + ), + 'one inactive and one uninstalled dependency' => array( + 'dependencies' => array( 'dependent/dependent.php' => array( 'dependency', 'dependency2' ) ), + 'dependency_filepaths' => array( 'dependency' => 'dependency/dependency.php' ), + 'active_plugins' => array(), + 'plugin_to_check' => 'dependent/dependent.php', + 'expected' => true, + ), + ); + } +} diff --git a/tests/phpunit/tests/admin/plugin-dependencies/initialize.php b/tests/phpunit/tests/admin/plugin-dependencies/InitializeTest.php similarity index 93% rename from tests/phpunit/tests/admin/plugin-dependencies/initialize.php rename to tests/phpunit/tests/admin/plugin-dependencies/InitializeTest.php index 375e30c4bd6e2..6ec475f2938c5 100644 --- a/tests/phpunit/tests/admin/plugin-dependencies/initialize.php +++ b/tests/phpunit/tests/admin/plugin-dependencies/InitializeTest.php @@ -5,15 +5,20 @@ * @package WordPress */ +namespace WordPress\Tests\Admin\PluginDependencies; + +use WP_Plugin_Dependencies; +use WP_PluginDependencies_UnitTestCase; + require_once __DIR__ . '/base.php'; /** * @group admin * @group plugins * - * @covers WP_Plugin_Dependencies::initialize + * @covers \WP_Plugin_Dependencies::initialize */ -class Tests_Admin_WPPluginDependencies_Initialize extends WP_PluginDependencies_UnitTestCase { +class InitializeTest extends WP_PluginDependencies_UnitTestCase { /** * Tests that initialization runs only once. @@ -82,9 +87,6 @@ public function data_static_properties_set_during_initialization() { * * @ticket 22316 * - * @covers WP_Plugin_Dependencies::get_dependency_api_data - * @covers WP_Plugin_Dependencies::get_plugins - * * @dataProvider data_screens * * @global string $pagenow The filename of the current screen. @@ -133,7 +135,6 @@ public function data_screens() { * * @ticket 22316 * - * @covers WP_Plugin_Dependencies::get_dependency_api_data */ public function test_should_not_set_dependency_api_data() { self::$instance::initialize(); @@ -148,9 +149,6 @@ public function test_should_not_set_dependency_api_data() { * * @ticket 22316 * - * @covers WP_Plugin_Dependencies::read_dependencies_from_plugin_headers - * @covers WP_Plugin_Dependencies::sanitize_dependency_slugs - * * @dataProvider data_should_sanitize_slugs * * @param string $requires_plugins The unsanitized dependency slug(s). @@ -272,8 +270,6 @@ public function data_should_sanitize_slugs() { * * @ticket 22316 * - * @covers WP_Plugin_Dependencies::read_dependencies_from_plugin_headers - * @covers WP_Plugin_Dependencies::convert_to_slug */ public function test_should_slugify_dependent_files() { $plugins = get_plugins(); diff --git a/tests/phpunit/tests/admin/plugin-dependencies/hasActiveDependents.php b/tests/phpunit/tests/admin/plugin-dependencies/hasActiveDependents.php deleted file mode 100644 index b4d52433767b9..0000000000000 --- a/tests/phpunit/tests/admin/plugin-dependencies/hasActiveDependents.php +++ /dev/null @@ -1,201 +0,0 @@ -set_property_value( - 'dependencies', - array( 'dependent/dependent.php' => array( 'dependency' ) ) - ); - - update_option( 'active_plugins', array( 'dependent/dependent.php' ) ); - - $this->assertFalse( self::$instance::has_active_dependents( 'dependency2/dependency2.php' ) ); - } - - /** - * Tests that a plugin with active dependents will return true. - * - * @ticket 22316 - */ - public function test_should_return_true_when_a_plugin_has_active_dependents() { - $this->set_property_value( - 'dependencies', - array( 'dependent/dependent.php' => array( 'dependency' ) ) - ); - - update_option( 'active_plugins', array( 'dependent/dependent.php' ) ); - - $this->assertTrue( self::$instance::has_active_dependents( 'dependency/dependency.php' ) ); - } - - /** - * Tests that a plugin with one inactive and one active dependent will return true. - * - * @ticket 22316 - */ - public function test_should_return_true_when_a_plugin_has_one_inactive_and_one_active_dependent() { - $this->set_property_value( - 'dependencies', - array( - 'dependent2/dependent2.php' => array( 'dependency' ), - 'dependent/dependent.php' => array( 'dependency' ), - ) - ); - - update_option( 'active_plugins', array( 'dependent/dependent.php' ) ); - - $this->assertTrue( self::$instance::has_active_dependents( 'dependency/dependency.php' ) ); - } - - /** - * Tests that a plugin with one active and one inactive dependent will return true. - * - * @ticket 22316 - */ - public function test_should_return_true_when_a_plugin_has_one_active_and_one_inactive_dependent() { - $this->set_property_value( - 'dependencies', - array( - 'dependent/dependent.php' => array( 'dependency' ), - 'dependent2/dependent2.php' => array( 'dependency' ), - ) - ); - - update_option( 'active_plugins', array( 'dependent/dependent.php' ) ); - - $this->assertTrue( self::$instance::has_active_dependents( 'dependency/dependency.php' ) ); - } - - /** - * Tests that when a plugin with active dependents is earlier in the list, - * it will return true if a later plugin has no active dependents. - * - * @ticket 22316 - */ - public function test_should_return_true_when_the_earlier_plugin_has_active_dependents_but_the_later_plugin_does_not() { - $this->set_property_value( - 'dependencies', - array( 'dependent2/dependent2.php' => array( 'dependency' ) ) - ); - - $this->set_property_value( - 'dependencies', - array( - 'dependent/dependent.php' => array( 'dependency' ), - 'dependent2/dependent2.php' => array( 'dependency2' ), - ) - ); - - update_option( 'active_plugins', array( 'dependent/dependent.php' ) ); - - $this->assertTrue( self::$instance::has_active_dependents( 'dependency/dependency.php' ) ); - } - - /** - * Tests that when a plugin with active dependents is later in the list, - * it will return true if an earlier plugin has no active dependents. - * - * @ticket 22316 - */ - public function test_should_return_true_when_the_later_plugin_has_active_dependents_but_the_earlier_plugin_does_not() { - $this->set_property_value( - 'dependencies', - array( 'dependent2/dependent2.php' => array( 'dependency' ) ) - ); - - $this->set_property_value( - 'dependencies', - array( - 'dependent/dependent.php' => array( 'dependency' ), - 'dependent2/dependent2.php' => array( 'dependency2' ), - ) - ); - - update_option( 'active_plugins', array( 'dependent2/dependent2.php' ) ); - - $this->assertTrue( self::$instance::has_active_dependents( 'dependency2/dependency2.php' ) ); - } - - /** - * Tests that a plugin with no dependents will return false. - * - * @ticket 22316 - */ - public function test_should_return_false_when_a_plugin_has_no_active_dependents() { - $this->set_property_value( - 'dependencies', - array( 'dependent/dependent.php' => array( 'dependency' ) ) - ); - - $this->assertFalse( self::$instance::has_active_dependents( 'dependency/dependency.php' ) ); - } - - /** - * Tests that when a plugin with no active dependents is earlier in the list, - * it will return false if a later plugin has active dependents. - * - * @ticket 22316 - */ - public function test_should_return_false_when_the_earlier_plugin_has_no_active_dependents_but_the_later_plugin_does() { - $this->set_property_value( - 'dependencies', - array( 'dependent2/dependent2.php' => array( 'dependency' ) ) - ); - - $this->set_property_value( - 'dependencies', - array( - 'dependent/dependent.php' => array( 'dependency' ), - 'dependent2/dependent2.php' => array( 'dependency2' ), - ) - ); - - update_option( 'active_plugins', array( 'dependent2/dependent2.php' ) ); - - $this->assertFalse( self::$instance::has_active_dependents( 'dependency/dependency.php' ) ); - } - - /** - * Tests that when a plugin with no active dependents is later in the list, - * it will return false if an earlier plugin has active dependents. - * - * @ticket 22316 - */ - public function test_should_return_false_when_the_later_plugin_has_no_active_dependents_but_the_earlier_plugin_does() { - $this->set_property_value( - 'dependencies', - array( 'dependent2/dependent2.php' => array( 'dependency' ) ) - ); - - $this->set_property_value( - 'dependencies', - array( - 'dependent/dependent.php' => array( 'dependency' ), - 'dependent2/dependent2.php' => array( 'dependency2' ), - ) - ); - - update_option( 'active_plugins', array( 'dependent/dependent.php' ) ); - - $this->assertFalse( self::$instance::has_active_dependents( 'dependency2/dependency2.php' ) ); - } -} diff --git a/tests/phpunit/tests/admin/plugin-dependencies/hasUnmetDependencies.php b/tests/phpunit/tests/admin/plugin-dependencies/hasUnmetDependencies.php deleted file mode 100644 index 28ed59354f714..0000000000000 --- a/tests/phpunit/tests/admin/plugin-dependencies/hasUnmetDependencies.php +++ /dev/null @@ -1,146 +0,0 @@ -set_property_value( 'dependencies', array( 'dependent/dependent.php' => array( 'dependency' ) ) ); - $this->assertFalse( self::$instance::has_unmet_dependencies( 'dependent2/dependent2.php' ) ); - } - - /** - * Tests that a plugin whose dependencies are installed and active will return false. - * - * @ticket 22316 - */ - public function test_should_return_false_when_a_plugin_has_no_unmet_dependencies() { - $this->set_property_value( - 'dependencies', - array( 'dependent/dependent.php' => array( 'dependency' ) ) - ); - - $this->set_property_value( - 'dependency_filepaths', - array( 'dependency' => 'dependency/dependency.php' ) - ); - - update_option( 'active_plugins', array( 'dependency/dependency.php' ) ); - - $this->assertFalse( self::$instance::has_unmet_dependencies( 'dependent/dependent.php' ) ); - } - - /** - * Tests that a plugin with a dependency that is not installed will return true. - * - * @ticket 22316 - */ - public function test_should_return_true_when_a_plugin_has_a_dependency_that_is_not_installed() { - self::$instance::initialize(); - $this->set_property_value( - 'dependencies', - array( 'dependent/dependent.php' => array( 'dependency' ) ) - ); - - $this->assertTrue( self::$instance::has_unmet_dependencies( 'dependent/dependent.php' ) ); - } - - /** - * Tests that a plugin with a dependency that is inactive will return true. - * - * @ticket 22316 - */ - public function test_should_return_true_when_a_plugin_has_a_dependency_that_is_inactive() { - $this->set_property_value( - 'dependencies', - array( 'dependent/dependent.php' => array( 'dependency' ) ) - ); - - $this->set_property_value( - 'dependency_filepaths', - array( 'dependency' => 'dependency/dependency.php' ) - ); - - $this->assertTrue( self::$instance::has_unmet_dependencies( 'dependent/dependent.php' ) ); - } - - /** - * Tests that a plugin with one dependency that is active and one dependency that is inactive will return true. - * - * @ticket 22316 - */ - public function test_should_return_true_when_a_plugin_has_one_active_dependency_and_one_inactive_dependency() { - $this->set_property_value( - 'dependencies', - array( 'dependent/dependent.php' => array( 'dependency', 'dependency2' ) ) - ); - - $this->set_property_value( - 'dependency_filepaths', - array( - 'dependency' => 'dependency/dependency.php', - 'dependency2' => 'dependency2/dependency2.php', - ) - ); - - update_option( 'active_plugins', array( 'dependency/dependency.php' ) ); - - $this->assertTrue( self::$instance::has_unmet_dependencies( 'dependent/dependent.php' ) ); - } - - /** - * Tests that a plugin with one dependency that is active and one dependency that is not installed will return true. - * - * @ticket 22316 - */ - public function test_should_return_true_when_a_plugin_has_one_active_dependency_and_one_that_is_not_installed() { - $this->set_property_value( - 'dependencies', - array( 'dependent/dependent.php' => array( 'dependency', 'dependency2' ) ) - ); - - $this->set_property_value( - 'dependency_filepaths', - array( 'dependency' => 'dependency/dependency.php' ) - ); - - update_option( 'active_plugins', array( 'dependency/dependency.php' ) ); - - $this->assertTrue( self::$instance::has_unmet_dependencies( 'dependent/dependent.php' ) ); - } - - /** - * Tests that a plugin with one dependency that is inactive and one dependency that is not installed will return true. - * - * @ticket 22316 - */ - public function test_should_return_true_when_a_plugin_has_one_inactive_dependency_and_one_that_is_not_installed() { - $this->set_property_value( - 'dependencies', - array( 'dependent/dependent.php' => array( 'dependency', 'dependency2' ) ) - ); - - $this->set_property_value( - 'dependency_filepaths', - array( 'dependency' => 'dependency/dependency.php' ) - ); - - $this->assertTrue( self::$instance::has_unmet_dependencies( 'dependent/dependent.php' ) ); - } -}