protected function UpdaterTest::setUp in Update helper 2.x
Same name and namespace in other branches
- 8 tests/src/Kernel/UpdaterTest.php \Drupal\Tests\update_helper\Kernel\UpdaterTest::setUp()
Overrides KernelTestBase::setUp
File
- tests/
src/ Kernel/ UpdaterTest.php, line 134
Class
Namespace
Drupal\Tests\update_helper\KernelCode
protected function setUp() {
parent::setUp();
$this->moduleHandler = \Drupal::moduleHandler();
$module_dir = $this->moduleHandler
->getModule('update_helper_test')
->getPath();
mkdir($module_dir . '/config/install', 0755, TRUE);
// Prepare config file for testing of configuration import.
$tour_config = [
'id' => 'tour-update-helper-test',
'module' => 'update_helper',
'label' => 'Tour test Update Helper config import',
'langcode' => 'en',
'routes' => [
[
'route_name' => 'update_helper.1',
],
],
'tips' => [
'tour-update-helper-test-1' => [
'id' => 'update-helper-test-1',
'plugin' => 'text',
'label' => 'Update Helper',
'body' => 'Update helper test tour.',
'weight' => 1,
],
],
];
file_put_contents($module_dir . '/config/install/tour.tour.tour-update-helper-test.yml', Yaml::encode($tour_config));
/** @var \Drupal\update_helper\ConfigHandler $config_handler */
$config_handler = \Drupal::service('update_helper.config_handler');
// Create update configuration for testExecuteUpdate.
$patch_file_path = $config_handler
->getPatchFile('update_helper_test', 'test_updater', TRUE);
file_put_contents($patch_file_path, Yaml::encode($this
->getUpdateDefinition()));
// Create update configuration for testOnlyDeleteUpdate.
$patch_file_path = $config_handler
->getPatchFile('update_helper_test', 'test_updater_only_delete', TRUE);
file_put_contents($patch_file_path, Yaml::encode([
'field.storage.node.body' => [
'expected_config' => [],
'update_actions' => [
'delete' => [
'lost_config' => 'text',
],
],
],
]));
}