diff --git a/core/modules/system/lib/Drupal/system/Tests/Module/ModuleApiTest.php b/core/modules/system/lib/Drupal/system/Tests/Extension/ModuleHandlerTest.php similarity index 90% rename from core/modules/system/lib/Drupal/system/Tests/Module/ModuleApiTest.php rename to core/modules/system/lib/Drupal/system/Tests/Extension/ModuleHandlerTest.php index 313a7cb..15806ec 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Module/ModuleApiTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Extension/ModuleHandlerTest.php @@ -2,25 +2,25 @@ /** * @file - * Definition of Drupal\system\Tests\Module\ModuleApiTest. + * Contains \Drupal\system\Tests\Extension\ModuleHandlerTest. */ -namespace Drupal\system\Tests\Module; +namespace Drupal\system\Tests\Extension; use Drupal\Core\DependencyInjection\ContainerBuilder; use Drupal\simpletest\DrupalUnitTestBase; use Symfony\Component\HttpFoundation\Response; /** - * Unit tests for the module API. + * Tests ModuleHandler functionality. */ -class ModuleApiTest extends DrupalUnitTestBase { +class ModuleHandlerTest extends DrupalUnitTestBase { public static function getInfo() { return array( - 'name' => 'Module API', - 'description' => 'Test low-level module functions.', - 'group' => 'Module', + 'name' => 'Module handler', + 'description' => 'Tests ModuleHandler functionality.', + 'group' => 'Extension', ); } @@ -42,17 +42,17 @@ function testModuleList() { $module_list[] = 'testing'; sort($module_list); - // Compare this list to the one returned by the extension handler. We expect + // Compare this list to the one returned by the module handler. We expect // them to match, since all default profile modules have a weight equal to 0 // (except for block.module, which has a lower weight but comes first in // the alphabet anyway). - $this->assertModuleList($module_list, t('Testing profile')); + $this->assertModuleList($module_list, 'Testing profile'); // Try to install a new module. $this->moduleHandler()->install(array('ban')); $module_list[] = 'ban'; sort($module_list); - $this->assertModuleList($module_list, t('After adding a module')); + $this->assertModuleList($module_list, 'After adding a module'); // Try to mess with the module weights. module_set_weight('ban', 20); @@ -60,7 +60,7 @@ function testModuleList() { // Move ban to the end of the array. unset($module_list[array_search('ban', $module_list)]); $module_list[] = 'ban'; - $this->assertModuleList($module_list, t('After changing weights')); + $this->assertModuleList($module_list, 'After changing weights'); // Test the fixed list feature. $fixed_list = array( @@ -70,20 +70,21 @@ function testModuleList() { $this->moduleHandler()->setModuleList($fixed_list); $new_module_list = array_combine(array_keys($fixed_list), array_keys($fixed_list)); $this->assertModuleList($new_module_list, t('When using a fixed list')); - } /** - * Assert that the extension handler returns the expected values. + * Asserts that ModuleHandler returns the expected values. * - * @param $expected_values + * @param array $expected_values * The expected values, sorted by weight and module name. + * @param string $condition + * Context identifier to use for the assertion message. */ - protected function assertModuleList(Array $expected_values, $condition) { + protected function assertModuleList(array $expected_values, $condition) { $expected_values = array_values(array_unique($expected_values)); $enabled_modules = array_keys($this->moduleHandler()->getModuleList()); $enabled_modules = sort($enabled_modules); - $this->assertEqual($expected_values, $enabled_modules, format_string('@condition: extension handler returns correct results', array('@condition' => $condition))); + $this->assertEqual($expected_values, $enabled_modules, format_string('@condition: ModuleHandler returns correct results', array('@condition' => $condition))); } /** @@ -214,11 +215,11 @@ function testDependencyResolution() { // Finally, verify that the modules were enabled in the correct order. $enable_order = \Drupal::state()->get('module_test.install_order') ?: array(); - $xmlrpc_position = array_search('help', $enable_order); - $ban_position = array_search('config', $enable_order); - $forum_position = array_search('color', $enable_order); - $xmlrpc_before_ban = $xmlrpc_position !== FALSE && $ban_position !== FALSE && $xmlrpc_position < $ban_position; - $ban_before_forum = $ban_position !== FALSE && $forum_position !== FALSE && $ban_position < $forum_position; + $help_position = array_search('help', $enable_order); + $config_position = array_search('config', $enable_order); + $color_position = array_search('color', $enable_order); + $xmlrpc_before_ban = $help_position !== FALSE && $config_position !== FALSE && $help_position < $config_position; + $ban_before_forum = $config_position !== FALSE && $color_position !== FALSE && $config_position < $color_position; $this->assertTrue($xmlrpc_before_ban && $ban_before_forum, 'Modules were enabled in the correct order.'); } diff --git a/core/scripts/run-tests.sh b/core/scripts/run-tests.sh index 7089239..1ba298e 100755 --- a/core/scripts/run-tests.sh +++ b/core/scripts/run-tests.sh @@ -64,7 +64,7 @@ exit; } -$test_list = array('Drupal\system\Tests\Module\ModuleApiTest', 'Drupal\system\Tests\Module\DependencyTest'); +$test_list = array('Drupal\system\Tests\Extension\ModuleHandlerTest', 'Drupal\system\Tests\Module\DependencyTest'); // Try to allocate unlimited time to run the tests. drupal_set_time_limit(0);