Commit cb5263f0 authored by catch's avatar catch

Issue #2225485 by alexpott, gremy: Fix config test modules namespacing.

parent 8c90c366
......@@ -137,14 +137,14 @@ function testInstallProfileConfigOverwrite() {
// Turn on the test module, which will attempt to replace the
// configuration data. This attempt to replace the active configuration
// should be ignored.
\Drupal::moduleHandler()->install(array('config_override_test'));
\Drupal::moduleHandler()->install(array('config_existing_default_config_test'));
// Verify that the test module has not been able to change the data.
$config = \Drupal::config($config_name);
$this->assertIdentical($config->get(), $expected_profile_data);
// Disable and uninstall the test module.
\Drupal::moduleHandler()->uninstall(array('config_override_test'));
\Drupal::moduleHandler()->uninstall(array('config_existing_default_config_test'));
// Verify that the data hasn't been altered by removing the test module.
$config = \Drupal::config($config_name);
......
......@@ -14,7 +14,7 @@
*/
class ConfigModuleOverridesTest extends DrupalUnitTestBase {
public static $modules = array('system', 'config', 'config_override');
public static $modules = array('system', 'config', 'config_override_test');
public static function getInfo() {
return array(
......@@ -55,11 +55,11 @@ public function testSimpleModuleOverrides() {
// Test overrides of completely new configuration objects. In normal runtime
// this should only happen for configuration entities as we should not be
// creating simple configuration objects on the fly.
$config = $config_factory->get('config_override.new');
$this->assertTrue($config->isNew(), 'The configuration object config_override.new is new');
$config = $config_factory->get('config_override_test.new');
$this->assertTrue($config->isNew(), 'The configuration object config_override_test.new is new');
$this->assertIdentical($config->get('module'), 'override');
$config_factory->setOverrideState(FALSE);
$config = \Drupal::config('config_override.new');
$config = \Drupal::config('config_override_test.new');
$this->assertIdentical($config->get('module'), NULL);
$config_factory->setOverrideState($old_state);
......
......@@ -39,29 +39,29 @@ public function setUp() {
* Tests enabling the provider of the default configuration first.
*/
public function testInstallOtherModuleFirst() {
$this->moduleHandler->install(array('config_other_module_config'));
$this->moduleHandler->install(array('config_other_module_config_test'));
// Check that the config entity doesn't exist before the config_test module
// is enabled. We cannot use the entity system because the config_test
// entity type does not exist.
$config = $this->container->get('config.factory')->get('config_test.dynamic.other_module');
$config = $this->container->get('config.factory')->get('config_test.dynamic.other_module_test');
$this->assertTrue($config->isNew(), 'Default configuration for other modules is not installed if that module is not enabled.');
// Install the module that provides the entity type. This installs the
// default configuration.
$this->moduleHandler->install(array('config_test'));
$this->assertTrue(entity_load('config_test', 'other_module', TRUE), 'Default configuration has been installed.');
$this->assertTrue(entity_load('config_test', 'other_module_test', TRUE), 'Default configuration has been installed.');
// Uninstall the module that provides the entity type. This will remove the
// default configuration.
$this->moduleHandler->uninstall(array('config_test'));
$config = $this->container->get('config.factory')->get('config_test.dynamic.other_module');
$config = $this->container->get('config.factory')->get('config_test.dynamic.other_module_test');
$this->assertTrue($config->isNew(), 'Default configuration for other modules is removed when the config entity provider is disabled.');
// Install the module that provides the entity type again. This installs the
// default configuration.
$this->moduleHandler->install(array('config_test'));
$other_module_config_entity = entity_load('config_test', 'other_module', TRUE);
$other_module_config_entity = entity_load('config_test', 'other_module_test', TRUE);
$this->assertTrue($other_module_config_entity, "Default configuration has been recreated.");
// Update the default configuration to test that the changes are preserved
......@@ -70,15 +70,15 @@ public function testInstallOtherModuleFirst() {
$other_module_config_entity->save();
// Uninstall the module that provides the default configuration.
$this->moduleHandler->uninstall(array('config_other_module_config'));
$this->assertTrue(entity_load('config_test', 'other_module', TRUE), 'Default configuration for other modules is not removed when the module that provides it is uninstalled.');
$this->moduleHandler->uninstall(array('config_other_module_config_test'));
$this->assertTrue(entity_load('config_test', 'other_module_test', TRUE), 'Default configuration for other modules is not removed when the module that provides it is uninstalled.');
// Default configuration provided by config_test should still exist.
$this->assertTrue(entity_load('config_test', 'dotted.default', TRUE), 'The configuration is not deleted.');
// Re-enable module to test that default config is unchanged.
$this->moduleHandler->install(array('config_other_module_config'));
$config_entity = entity_load('config_test', 'other_module', TRUE);
$this->moduleHandler->install(array('config_other_module_config_test'));
$config_entity = entity_load('config_test', 'other_module_test', TRUE);
$this->assertEqual($config_entity->get('style'), "The piano ain't got no wrong notes.", 'Re-enabling the module does not install default config over the existing config entity.');
}
......@@ -87,10 +87,10 @@ public function testInstallOtherModuleFirst() {
*/
public function testInstallConfigEnityModuleFirst() {
$this->moduleHandler->install(array('config_test'));
$this->assertFalse(entity_load('config_test', 'other_module', TRUE), 'Default configuration provided by config_other_module_config does not exist.');
$this->assertFalse(entity_load('config_test', 'other_module_test', TRUE), 'Default configuration provided by config_other_module_config_test does not exist.');
$this->moduleHandler->install(array('config_other_module_config'));
$this->assertTrue(entity_load('config_test', 'other_module', TRUE), 'Default configuration provided by config_other_module_config has been installed.');
$this->moduleHandler->install(array('config_other_module_config_test'));
$this->assertTrue(entity_load('config_test', 'other_module_test', TRUE), 'Default configuration provided by config_other_module_config_test has been installed.');
}
/**
......
......@@ -15,7 +15,7 @@
*/
class ConfigOverridesPriorityTest extends DrupalUnitTestBase {
public static $modules = array('system', 'config', 'config_override', 'language');
public static $modules = array('system', 'config', 'config_override_test', 'language');
public static function getInfo() {
return array(
......
name: 'Configuration override test'
name: 'Configuration existing default config test'
type: module
package: Testing
version: VERSION
core: 8.x
hidden: true
<?php
/**
* @file
* Test module containing a configuration file which matches another module.
*/
services:
config_override.overrider:
class: Drupal\config_override\ConfigOverrider
config_override_test.overrider:
class: Drupal\config_override_test\ConfigOverrider
tags:
- { name: config.factory.override}
config_override.low_priority_overrider:
class: Drupal\config_override\ConfigOverriderLowPriority
config_override_test.low_priority_overrider:
class: Drupal\config_override_test\ConfigOverriderLowPriority
tags:
- { name: config.factory.override, priority: -100 }
......@@ -2,16 +2,12 @@
/**
* @file
* Contains \Drupal\config_override\ConfigOverrider.
* Contains \Drupal\config_override_test\ConfigOverrider.
*/
namespace Drupal\config_override;
namespace Drupal\config_override_test;
use Drupal\Core\Config\ConfigEvents;
use Drupal\Core\Config\ConfigFactoryOverrideInterface;
use Drupal\Core\Config\ConfigModuleOverridesEvent;
use Drupal\Core\Config\StorageInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
/**
* Tests module overrides for configuration.
......@@ -27,8 +23,8 @@ public function loadOverrides($names) {
if (in_array('system.site', $names)) {
$overrides = $overrides + array('system.site' => array('name' => 'ZOMG overridden site name'));
}
if (in_array('config_override.new', $names)) {
$overrides = $overrides + array('config_override.new' => array('module' => 'override'));
if (in_array('config_override_test.new', $names)) {
$overrides = $overrides + array('config_override_test.new' => array('module' => 'override'));
}
}
return $overrides;
......
......@@ -2,10 +2,10 @@
/**
* @file
* Contains \Drupal\config_override\ConfigOverriderLowPriority.
* Contains \Drupal\config_override_test\ConfigOverriderLowPriority.
*/
namespace Drupal\config_override;
namespace Drupal\config_override_test;
use Drupal\Core\Config\ConfigFactoryOverrideInterface;
use Drupal\Core\Config\StorageInterface;
......
# Schema for the configuration files of the Invalid Configuration Name module.
invalid_object_name:
type: mapping
label: 'Invalid configuration'
mapping:
frittata:
type: string
label: 'String'
name: 'Invalid configuration name'
type: module
package: Core
version: VERSION
core: 8.x
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment