Chris@17: copyTestingOverrides();
Chris@17: }
Chris@17:
Chris@17: /**
Chris@17: * {@inheritdoc}
Chris@17: */
Chris@17: protected function setUp() {
Chris@17: // During set up an UnmetDependenciesException should be thrown, which will
Chris@17: // be re-thrown by TestHttpClientMiddleware as a standard Exception.
Chris@17: try {
Chris@17: parent::setUp();
Chris@17: }
Chris@17: catch (\Exception $exception) {
Chris@17: $this->expectedException = $exception;
Chris@17: }
Chris@17: }
Chris@17:
Chris@17: /**
Chris@17: * Copy the testing_config_overrides install profile.
Chris@17: *
Chris@17: * So we can change the configuration to include a dependency that can not be
Chris@17: * met. File API functions are not available yet.
Chris@17: */
Chris@17: protected function copyTestingOverrides() {
Chris@17: $dest = $this->siteDirectory . '/profiles/testing_config_overrides';
Chris@17: mkdir($dest, 0777, TRUE);
Chris@17: $source = DRUPAL_ROOT . '/core/profiles/testing_config_overrides';
Chris@17: $iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($source, \RecursiveDirectoryIterator::SKIP_DOTS), \RecursiveIteratorIterator::SELF_FIRST);
Chris@17: foreach ($iterator as $item) {
Chris@17: if ($item->isDir()) {
Chris@17: mkdir($dest . DIRECTORY_SEPARATOR . $iterator->getSubPathName());
Chris@17: }
Chris@17: else {
Chris@17: copy($item, $dest . DIRECTORY_SEPARATOR . $iterator->getSubPathName());
Chris@17: }
Chris@17: }
Chris@17:
Chris@17: // Add a dependency that can not be met because User is installed before
Chris@17: // Action.
Chris@17: $config_file = $dest . DIRECTORY_SEPARATOR . InstallStorage::CONFIG_INSTALL_DIRECTORY . DIRECTORY_SEPARATOR . 'system.action.user_block_user_action.yml';
Chris@17: $action = Yaml::decode(file_get_contents($config_file));
Chris@17: $action['dependencies']['module'][] = 'action';
Chris@17: file_put_contents($config_file, Yaml::encode($action));
Chris@17: }
Chris@17:
Chris@17: /**
Chris@17: * Confirms that the installation succeeded.
Chris@17: */
Chris@17: public function testInstalled() {
Chris@17: if ($this->expectedException) {
Chris@17: $this->assertContains('Configuration objects provided by user have unmet dependencies: system.action.user_block_user_action (action)', $this->expectedException->getMessage());
Chris@17: $this->assertContains('Drupal\Core\Config\UnmetDependenciesException', $this->expectedException->getMessage());
Chris@17: }
Chris@17: else {
Chris@17: $this->fail('Expected Drupal\Core\Config\UnmetDependenciesException exception not thrown');
Chris@17: }
Chris@17: }
Chris@17:
Chris@17: }