Chris@0: siteDirectory . '/profiles/testing_config_overrides';
Chris@0: mkdir($dest, 0777, TRUE);
Chris@0: $source = DRUPAL_ROOT . '/core/profiles/testing_config_overrides';
Chris@0: $iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($source, \RecursiveDirectoryIterator::SKIP_DOTS), \RecursiveIteratorIterator::SELF_FIRST);
Chris@0: foreach ($iterator as $item) {
Chris@0: if ($item->isDir()) {
Chris@0: mkdir($dest . DIRECTORY_SEPARATOR . $iterator->getSubPathName());
Chris@0: }
Chris@0: else {
Chris@0: copy($item, $dest . DIRECTORY_SEPARATOR . $iterator->getSubPathName());
Chris@0: }
Chris@0: }
Chris@0:
Chris@0: // Add a dependency that can not be met because User is installed before
Chris@0: // Action.
Chris@0: $config_file = $dest . DIRECTORY_SEPARATOR . InstallStorage::CONFIG_INSTALL_DIRECTORY . DIRECTORY_SEPARATOR . 'system.action.user_block_user_action.yml';
Chris@0: $action = Yaml::decode(file_get_contents($config_file));
Chris@0: $action['dependencies']['module'][] = 'action';
Chris@0: file_put_contents($config_file, Yaml::encode($action));
Chris@0:
Chris@0: parent::setUp();
Chris@0: }
Chris@0:
Chris@0: /**
Chris@0: * {@inheritdoc}
Chris@0: *
Chris@0: * Override the error method so we can test for the expected exception.
Chris@0: */
Chris@0: protected function error($message = '', $group = 'Other', array $caller = NULL) {
Chris@0: if ($group == 'User notice') {
Chris@0: // Since 'User notice' is set by trigger_error() which is used for debug
Chris@0: // set the message to a status of 'debug'.
Chris@0: return $this->assert('debug', $message, 'Debug', $caller);
Chris@0: }
Chris@0: if ($group == 'Drupal\Core\Config\UnmetDependenciesException') {
Chris@0: $this->expectedException = TRUE;
Chris@0: return FALSE;
Chris@0: }
Chris@0: return $this->assert('exception', $message, $group, $caller);
Chris@0: }
Chris@0:
Chris@0: /**
Chris@0: * {@inheritdoc}
Chris@0: */
Chris@0: protected function setUpSite() {
Chris@0: // This step is not reached due to the exception.
Chris@0: }
Chris@0:
Chris@0:
Chris@0: /**
Chris@0: * Confirms that the installation succeeded.
Chris@0: */
Chris@0: public function testInstalled() {
Chris@0: if ($this->expectedException) {
Chris@0: $this->pass('Expected Drupal\Core\Config\UnmetDependenciesException exception thrown');
Chris@0: }
Chris@0: else {
Chris@0: $this->fail('Expected Drupal\Core\Config\UnmetDependenciesException exception thrown');
Chris@0: }
Chris@0: $this->assertErrorLogged('Configuration objects provided by user have unmet dependencies: system.action.user_block_user_action (action)');
Chris@0: }
Chris@0:
Chris@0: }