Select Git revision
CacheCollectorInterface.php
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
DependencyTest.php 7.84 KiB
<?php
/**
* @file
* Contains \Drupal\system\Tests\Module\DependencyTest.
*/
namespace Drupal\system\Tests\Module;
/**
* Tests module dependency functionality.
*/
class DependencyTest extends ModuleTestBase {
public static function getInfo() {
return array(
'name' => 'Module dependencies',
'description' => 'Enable module without dependency enabled.',
'group' => 'Module',
);
}
/**
* Attempts to enable the Content Translation module without Language enabled.
*/
function testEnableWithoutDependency() {
// Attempt to enable Content Translation without Language enabled.
$edit = array();
$edit['modules[Multilingual][content_translation][enable]'] = 'content_translation';
$this->drupalPostForm('admin/modules', $edit, t('Save configuration'));
$this->assertText(t('Some required modules must be enabled'), 'Dependency required.');
$this->assertModules(array('content_translation', 'language'), FALSE);
// Assert that the language tables weren't enabled.
$this->assertTableCount('language', FALSE);
$this->drupalPostForm(NULL, NULL, t('Continue'));
$this->assertText(t('The configuration options have been saved.'), 'Modules status has been updated.');
$this->assertModules(array('content_translation', 'language'), TRUE);
// Assert that the language YAML files were created.
$storage = $this->container->get('config.storage');
$this->assertTrue(count($storage->listAll('language.entity.')) > 0, 'Language config entity files exist.');
}
/**
* Attempts to enable a module with a missing dependency.
*/
function testMissingModules() {
// Test that the system_dependencies_test module is marked
// as missing a dependency.
$this->drupalGet('admin/modules');
$this->assertRaw(t('@module (<span class="admin-missing">missing</span>)', array('@module' => drupal_ucfirst('_missing_dependency'))), 'A module with missing dependencies is marked as such.');
$checkbox = $this->xpath('//input[@type="checkbox" and @disabled="disabled" and @name="modules[Testing][system_dependencies_test][enable]"]');
$this->assert(count($checkbox) == 1, 'Checkbox for the module is disabled.');
}
/**
* Tests enabling a module that depends on an incompatible version of a module.
*/
function testIncompatibleModuleVersionDependency() {
// Test that the system_incompatible_module_version_dependencies_test is
// marked as having an incompatible dependency.
$this->drupalGet('admin/modules');
$this->assertRaw(t('@module (<span class="admin-missing">incompatible with</span> version @version)', array(
'@module' => 'System incompatible module version test (>2.0)',
'@version' => '1.0',
)), 'A module that depends on an incompatible version of a module is marked as such.');
$checkbox = $this->xpath('//input[@type="checkbox" and @disabled="disabled" and @name="modules[Testing][system_incompatible_module_version_dependencies_test][enable]"]');