ConfigInstallProfileUnmetDependenciesTest.php in Zircon Profile 8.0
File
core/modules/config/src/Tests/ConfigInstallProfileUnmetDependenciesTest.php
View source
<?php
namespace Drupal\config\Tests;
use Drupal\Component\Serialization\Yaml;
use Drupal\Core\Config\InstallStorage;
use Drupal\simpletest\InstallerTestBase;
class ConfigInstallProfileUnmetDependenciesTest extends InstallerTestBase {
protected $profile = 'testing_config_overrides';
protected $expectedException = FALSE;
protected function setUp() {
$dest = $this->siteDirectory . '/profiles/testing_config_overrides';
mkdir($dest, 0777, TRUE);
$source = DRUPAL_ROOT . '/core/profiles/testing_config_overrides';
$iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($source, \RecursiveDirectoryIterator::SKIP_DOTS), \RecursiveIteratorIterator::SELF_FIRST);
foreach ($iterator as $item) {
if ($item
->isDir()) {
mkdir($dest . DIRECTORY_SEPARATOR . $iterator
->getSubPathName());
}
else {
copy($item, $dest . DIRECTORY_SEPARATOR . $iterator
->getSubPathName());
}
}
$config_file = $dest . DIRECTORY_SEPARATOR . InstallStorage::CONFIG_INSTALL_DIRECTORY . DIRECTORY_SEPARATOR . 'system.action.user_block_user_action.yml';
$action = Yaml::decode(file_get_contents($config_file));
$action['dependencies']['module'][] = 'action';
file_put_contents($config_file, Yaml::encode($action));
parent::setUp();
}
protected function error($message = '', $group = 'Other', array $caller = NULL) {
if ($group == 'User notice') {
return $this
->assert('debug', $message, 'Debug', $caller);
}
if ($group == 'Drupal\\Core\\Config\\UnmetDependenciesException') {
$this->expectedException = TRUE;
return FALSE;
}
return $this
->assert('exception', $message, $group, $caller);
}
protected function setUpSite() {
}
public function testInstalled() {
if ($this->expectedException) {
$this
->pass('Expected Drupal\\Core\\Config\\UnmetDependenciesException exception thrown');
}
else {
$this
->fail('Expected Drupal\\Core\\Config\\UnmetDependenciesException exception thrown');
}
$this
->assertErrorLogged('Configuration objects (system.action.user_block_user_action) provided by user have unmet dependencies in');
}
}