public function DrushTest::testGeneratePatchFileFromActiveConfigUsingDrush in Update helper 2.x
Tests `drush generate configuration-update`.
File
- tests/
src/ Functional/ DrushTest.php, line 63
Class
- DrushTest
- Automated tests for Drush commands.
Namespace
Drupal\Tests\update_helper\FunctionalCode
public function testGeneratePatchFileFromActiveConfigUsingDrush() {
// Copy the node module so we can modify config for testing.
$file_system = new Filesystem();
$file_system
->mirror('core/modules/node/config/install', $this->siteDirectory . '/modules/test_node_config/config/install');
/** @var \Drupal\Core\Config\ConfigFactory $configFactory */
$configFactory = \Drupal::service('config.factory');
$config = $configFactory
->getEditable('field.storage.node.body');
$configData = $config
->get();
$configData['status'] = FALSE;
$configData['type'] = 'text';
unset($configData['cardinality']);
$configData['settings'] = [
'max_length' => 123,
];
$configData['lost_config'] = 'text';
$config
->setData($configData)
->save(TRUE);
$optionsExample['answers'] = json_encode([
'module' => 'test_node_config',
'update-n' => 9001,
'description' => 'Some description',
'include-modules' => [
'test_node_config',
],
'from-active' => TRUE,
]);
$optionsExample['yes'] = NULL;
$install_file = $this->siteDirectory . '/modules/test_node_config/test_node_config.install';
$update_file = $this->siteDirectory . '/modules/test_node_config/config/update/test_node_config_update_9001.yml';
$this
->assertFileNotExists($install_file);
$this
->assertFileNotExists($update_file);
$this
->drush('generate', [
'configuration-update',
], $optionsExample, NULL, NULL, 0, NULL, [
'SHELL_INTERACTIVE' => 1,
]);
$this
->assertFileExists($install_file);
$this
->assertFileExists($update_file);
$this
->assertEquals(ConfigHandlerTest::getUpdateDefinition(), file_get_contents($update_file));
}