function ConfigImportCommandTest::testImportTransformation

Tests that import storage transformation event subscribers run.

See also

\Drupal\Tests\config\Functional\TransformedConfigExportImportUITest

File

core/tests/Drupal/FunctionalTests/Core/Config/ConfigImportCommandTest.php, line 388

Class

ConfigImportCommandTest
Tests the 'config:import' command.

Namespace

Drupal\FunctionalTests\Core\Config

Code

public function testImportTransformation() : void {
  \Drupal::service('module_installer')->install([
    'config_transformer_test',
  ]);
  $new_site_name = 'Config import test ' . $this->randomMachineName();
  $this->prepareSiteNameUpdate($new_site_name);
  $active_name = $this->config('system.site')
    ->get('name');
  $tester = $this->commandTester();
  $code = $tester->execute([
    '--yes' => TRUE,
  ]);
  self::assertSame(Command::SUCCESS, $code);
  // \Drupal\config_transformer_test\EventSubscriber::onImportTransform()
  // ignores the staged site name and appends " Arrr" to whatever name is
  // currently active, so the transformed value is imported instead.
  self::assertSame($active_name . ' Arrr', $this->config('system.site')
    ->get('name'));
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.