public function OgMenuConfigImportTest::testConfigImport in Organic Groups Menu (OG Menu) 8
Checks the creation of the group reference field from imported config.
File
- tests/
src/ Kernel/ OgMenuConfigImportTest.php, line 46
Class
- OgMenuConfigImportTest
- @group og_menu
Namespace
Drupal\Tests\og_menu\KernelCode
public function testConfigImport() {
/** @var \Drupal\Core\File\FileSystemInterface $file_system */
$file_system = $this->container
->get('file_system');
// Make sure the system.site configuration is available, so that the site
// UUID exists.
$this
->installConfig([
'system',
]);
$active = $this->container
->get('config.storage');
$sync = $this->container
->get('config.storage.sync');
$this
->copyConfig($active, $sync);
$src_dir = __DIR__ . '/../../modules/og_menu_test/config/install';
$target_dir = Settings::get('config_sync_directory');
$names = [
'field.field.ogmenu_instance.test.og_audience',
'field.storage.ogmenu_instance.og_audience',
'node.type.group',
'og_menu.ogmenu.test',
];
foreach ($names as $name) {
self::assertTrue($file_system
->copy("{$src_dir}/{$name}.yml", "{$target_dir}/{$name}.yml"));
}
// Import the content of the sync directory.
$this
->configImporter()
->import();
$this
->assertArrayHasKey(OgGroupAudienceHelper::DEFAULT_FIELD, \Drupal::service('entity_field.manager')
->getFieldStorageDefinitions('ogmenu_instance'));
}