Chris@0: [ Chris@0: 'requirements_warning' => 172800, Chris@0: 'requirements_error' => 1209600, Chris@0: ], Chris@0: 'logging' => 1, Chris@0: ]; Chris@0: // The expected active configuration altered by the install profile. Chris@0: $expected_profile_data = [ Chris@0: 'threshold' => [ Chris@0: 'requirements_warning' => 259200, Chris@0: 'requirements_error' => 1209600, Chris@0: ], Chris@0: 'logging' => 1, Chris@0: ]; Chris@0: $expected_profile_data['_core']['default_config_hash'] = Crypt::hashBase64(serialize($expected_profile_data)); Chris@0: Chris@0: // Verify that the original data matches. We have to read the module config Chris@0: // file directly, because the install profile default system.cron.yml Chris@0: // configuration file was used to create the active configuration. Chris@0: $config_dir = drupal_get_path('module', 'system') . '/' . InstallStorage::CONFIG_INSTALL_DIRECTORY; Chris@0: $this->assertTrue(is_dir($config_dir)); Chris@0: $source_storage = new FileStorage($config_dir); Chris@0: $data = $source_storage->read($config_name); Chris@0: $this->assertIdentical($data, $expected_original_data); Chris@0: Chris@0: // Verify that active configuration matches the expected data, which was Chris@0: // created from the testing install profile's system.cron.yml file. Chris@0: $config = $this->config($config_name); Chris@0: $this->assertIdentical($config->get(), $expected_profile_data); Chris@0: Chris@0: // Ensure that the configuration entity has the expected dependencies and Chris@0: // overrides. Chris@0: $action = Action::load('user_block_user_action'); Chris@0: $this->assertEqual($action->label(), 'Overridden block the selected user(s)'); Chris@0: $action = Action::load('user_cancel_user_action'); Chris@0: $this->assertEqual($action->label(), 'Cancel the selected user account(s)', 'Default configuration that is not overridden is not affected.'); Chris@0: Chris@0: // Ensure that optional configuration can be overridden. Chris@0: $tour = Tour::load('language'); Chris@0: $this->assertEqual(count($tour->getTips()), 1, 'Optional configuration can be overridden. The language tour only has one tip'); Chris@0: $tour = Tour::load('language-add'); Chris@0: $this->assertEqual(count($tour->getTips()), 3, 'Optional configuration that is not overridden is not affected.'); Chris@0: Chris@0: // Ensure that optional configuration from a profile is created if Chris@0: // dependencies are met. Chris@0: $this->assertEqual(Tour::load('testing_config_overrides')->label(), 'Config override test'); Chris@0: Chris@0: // Ensure that optional configuration from a profile is not created if Chris@0: // dependencies are not met. Cannot use the entity system since the entity Chris@0: // type does not exist. Chris@0: $optional_dir = drupal_get_path('module', 'testing_config_overrides') . '/' . InstallStorage::CONFIG_OPTIONAL_DIRECTORY; Chris@0: $optional_storage = new FileStorage($optional_dir); Chris@0: foreach (['config_test.dynamic.dotted.default', 'config_test.dynamic.override', 'config_test.dynamic.override_unmet'] as $id) { Chris@0: $this->assertTrue(\Drupal::config($id)->isNew(), "The config_test entity $id contained in the profile's optional directory does not exist."); Chris@0: // Make that we don't get false positives from the assertion above. Chris@0: $this->assertTrue($optional_storage->exists($id), "The config_test entity $id does exist in the profile's optional directory."); Chris@0: } Chris@0: Chris@0: // Install the config_test module and ensure that the override from the Chris@0: // install profile is used. Optional configuration can override Chris@0: // configuration in a modules config/install directory. Chris@0: $this->container->get('module_installer')->install(['config_test']); Chris@0: $this->rebuildContainer(); Chris@0: $config_test_storage = \Drupal::entityManager()->getStorage('config_test'); Chris@0: $this->assertEqual($config_test_storage->load('dotted.default')->label(), 'Default install profile override', 'The config_test entity is overridden by the profile optional configuration.'); Chris@0: // Test that override of optional configuration does work. Chris@0: $this->assertEqual($config_test_storage->load('override')->label(), 'Override', 'The optional config_test entity is overridden by the profile optional configuration.'); Chris@0: // Test that override of optional configuration which introduces an unmet Chris@0: // dependency does not get created. Chris@0: $this->assertNull($config_test_storage->load('override_unmet'), 'The optional config_test entity with unmet dependencies is not created.'); Chris@0: $this->assertNull($config_test_storage->load('completely_new'), 'The completely new optional config_test entity with unmet dependencies is not created.'); Chris@0: Chris@0: // Installing dblog creates the optional configuration. Chris@0: $this->container->get('module_installer')->install(['dblog']); Chris@0: $this->rebuildContainer(); Chris@0: $this->assertEqual($config_test_storage->load('override_unmet')->label(), 'Override', 'The optional config_test entity is overridden by the profile optional configuration and is installed when its dependencies are met.'); Chris@17: $config_test_new = $config_test_storage->load('completely_new'); Chris@17: $this->assertEqual($config_test_new->label(), 'Completely new optional configuration', 'The optional config_test entity is provided by the profile optional configuration and is installed when its dependencies are met.'); Chris@17: $config_test_new->delete(); Chris@17: Chris@17: // Install another module that provides optional configuration and ensure Chris@17: // that deleted profile configuration is not re-created. Chris@17: $this->container->get('module_installer')->install(['config_other_module_config_test']); Chris@17: $this->rebuildContainer(); Chris@17: $config_test_storage = \Drupal::entityManager()->getStorage('config_test'); Chris@17: $this->assertNull($config_test_storage->load('completely_new')); Chris@0: } Chris@0: Chris@0: }