mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-09-06 09:00:28 +00:00
Introduces a new "Requires Plugins" plugin header so that plugin developers can list the slugs of the plugins theirs depends on. This will inform users of the requirements, and provide links to the WordPress.org Plugins Repository that they can click to install and activate the dependencies first. Plugins whose requirements are not met cannot be installed or activated, and they will be deactivated automatically if their requirements become unmet. Plugins that others rely on cannot be deactivated or deleted until their dependent plugins are deactivated or deleted. In memory of Alex Mills and Alex King. WordPress Remembers. Props ahoereth, afragen, alanfuller, alexkingorg, amykamala, anonymized_10690803, apeatling, ashfame, atimmer, audrasjb, aristath, azaozz, batmoo, beaulebens, blobaugh, bobbingwide, boonebgorges, brianhenryie, chanthaboune, chrisdavidmiles, coolmann, costdev, courane01, danielbachhuber, davidperez, dd32, Denis-de-Bernardy, dingo_d, DJPaul, dougal, DrewAPicture, ethitter, filosofo, georgestephanis, giuseppemazzapica-1, goldenapples, griffinjt, hellofromTonya, husobj, ideag, jarednova, jbobich, jbrinley, jltallon, joedolson, johnciacia, johnjamesjacoby, joppuyo, jsmoriss, karmatosed, kebbet, knutsp, kraftbj, kraftner, kurtpayne, lkraav, logikal16, luisherranz, man4toman, markjaquith, matt, mbijon, megphillips91, mikeschinkel, mordauk, morehawes, mrwweb, mte90, mukesh27, mzaweb, nacin, norcross, nvwd, nwjames, obliviousharmony, ocean90, oglekler, paaljoachim, pauldewouters, pbaylies, pbiron, peterwilsoncc, Philipp15b, poena, pogidude, retlehs, rmccue, ryan, sabreuse, sc0ttkclark, scribu, sereedmedia, SergeyBiryukov, ShaneF, shidouhikari, soean, spacedmonkey, stephenh1988, swissspidy, taylorde, tazotodua, threadi, TimothyBlynJacobs, TJNowell, tollmanz, toscho, tropicalista, Viper007Bond, westi, whiteshadow, williamsba1, wpsmith, ZaneMatthew. Fixes #22316. git-svn-id: https://develop.svn.wordpress.org/trunk@57545 602fd350-edb4-49c9-b593-d223f7449a82
128 lines
3.6 KiB
PHP
128 lines
3.6 KiB
PHP
<?php
|
|
/**
|
|
* Tests for the WP_Plugin_Dependencies::has_circular_dependency() method.
|
|
*
|
|
* @package WordPress
|
|
*/
|
|
|
|
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
|
|
*/
|
|
class Tests_Admin_WPPluginDependencies_HasCircularDependency extends WP_PluginDependencies_UnitTestCase {
|
|
|
|
/**
|
|
* Tests that a plugin with a circular dependency will return true.
|
|
*
|
|
* @ticket 22316
|
|
*
|
|
* @dataProvider data_circular_dependencies
|
|
*
|
|
* @param string $plugin_to_check The plugin file of the plugin to check.
|
|
* @param array[] $plugins An array of plugins.
|
|
*/
|
|
public function test_should_return_true_when_a_plugin_has_circular_dependency( $plugin_to_check, $plugins ) {
|
|
$this->set_property_value( 'plugins', $plugins );
|
|
self::$instance::initialize();
|
|
|
|
$this->assertTrue( self::$instance::has_circular_dependency( $plugin_to_check ) );
|
|
}
|
|
|
|
/**
|
|
* Data provider.
|
|
*
|
|
* @return array[]
|
|
*/
|
|
public function data_circular_dependencies() {
|
|
return array(
|
|
'a plugin that depends on itself' => array(
|
|
'plugin_to_check' => 'dependency/dependency.php',
|
|
'plugins' => array(
|
|
'dependency/dependency.php' => array(
|
|
'Name' => 'Dependency 1',
|
|
'RequiresPlugins' => 'dependency',
|
|
),
|
|
),
|
|
),
|
|
'two plugins' => array(
|
|
'plugin_to_check' => 'dependency/dependency.php',
|
|
'plugins' => array(
|
|
'dependency/dependency.php' => array(
|
|
'Name' => 'Dependency 1',
|
|
'RequiresPlugins' => 'dependency2',
|
|
),
|
|
'dependency2/dependency2.php' => array(
|
|
'Name' => 'Dependency 2',
|
|
'RequiresPlugins' => 'dependency',
|
|
),
|
|
),
|
|
),
|
|
'three plugins' => array(
|
|
'plugin_to_check' => 'dependency/dependency.php',
|
|
'plugins' => array(
|
|
'dependency/dependency.php' => array(
|
|
'Name' => 'Dependency 1',
|
|
'RequiresPlugins' => 'dependency2',
|
|
),
|
|
'dependency2/dependency2.php' => array(
|
|
'Name' => 'Dependency 2',
|
|
'RequiresPlugins' => 'dependency3',
|
|
),
|
|
'dependency3/dependency3.php' => array(
|
|
'Name' => 'Dependency 3',
|
|
'RequiresPlugins' => 'dependency',
|
|
),
|
|
),
|
|
),
|
|
'four plugins' => array(
|
|
'plugin_to_check' => 'dependency/dependency.php',
|
|
'plugins' => array(
|
|
'dependency/dependency.php' => array(
|
|
'Name' => 'Dependency 1',
|
|
'RequiresPlugins' => 'dependency4',
|
|
),
|
|
'dependency2/dependency2.php' => array(
|
|
'Name' => 'Dependency 2',
|
|
'RequiresPlugins' => 'dependency3',
|
|
),
|
|
'dependency3/dependency3.php' => array(
|
|
'Name' => 'Dependency 3',
|
|
'RequiresPlugins' => 'dependency',
|
|
),
|
|
'dependency4/dependency4.php' => array(
|
|
'Name' => 'Dependency 4',
|
|
'RequiresPlugins' => 'dependency2',
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Tests that a plugin with no circular dependencies will return false.
|
|
*
|
|
* @ticket 22316
|
|
*/
|
|
public function test_should_return_false_when_a_plugin_has_no_circular_dependency() {
|
|
$this->set_property_value(
|
|
'plugins',
|
|
array(
|
|
'dependency/dependency.php' => array(
|
|
'Name' => 'Dependency 1',
|
|
'RequiresPlugins' => 'dependency2',
|
|
),
|
|
)
|
|
);
|
|
|
|
self::$instance::initialize();
|
|
|
|
$this->assertFalse( self::$instance::has_circular_dependency( 'dependent/dependent.php' ) );
|
|
}
|
|
}
|