You are here

public function DefaultContentTest::testImportViaConfigImporter in Default Content for D8 8

Same name and namespace in other branches
  1. 2.0.x tests/src/Functional/DefaultContentTest.php \Drupal\Tests\default_content\Functional\DefaultContentTest::testImportViaConfigImporter()

Test importing default content via ConfigImporter.

File

tests/src/Functional/DefaultContentTest.php, line 63

Class

DefaultContentTest
Test import of default content.

Namespace

Drupal\Tests\default_content\Functional

Code

public function testImportViaConfigImporter() {
  $sync = $this->container
    ->get('config.storage.sync');
  $this
    ->copyConfig($this->container
    ->get('config.storage'), $sync);

  // Enable the module using the ConfigImporter.
  $extensions = $sync
    ->read('core.extension');
  $extensions['module']['default_content_test'] = 0;
  $extensions['module'] = module_config_sort($extensions['module']);
  $sync
    ->write('core.extension', $extensions);

  // Slightly hacky but we need the config from the test module too.
  $module_storage = new FileStorage(drupal_get_path('module', 'default_content_test') . '/config/install');
  foreach ($module_storage
    ->listAll() as $name) {
    $sync
      ->write($name, $module_storage
      ->read($name));
  }
  $this
    ->configImporter()
    ->import();
  $this
    ->doPostInstallTests();
}