Commit 507733af authored by AaronBauman's avatar AaronBauman Committed by andypost

Issue #2851559 by aaronbauman: exportModuleContent() dies on any non-existent UUID

parent 03953a6f
......@@ -165,6 +165,9 @@ class Exporter implements ExporterInterface {
foreach ($info['default_content'] as $entity_type => $uuids) {
foreach ($uuids as $uuid) {
$entity = $this->entityRepository->loadEntityByUuid($entity_type, $uuid);
if (!$entity) {
throw new \InvalidArgumentException(sprintf('Entity "%s" with UUID "%s" does not exist', $entity_type, $uuid));
}
$exported_content[$entity_type][$uuid] = $this->exportContent($entity_type, $entity->id());
}
}
......
......@@ -41,6 +41,8 @@ interface ExporterInterface {
*
* @return string[][]
* The serialized entities keyed by entity type and UUID.
*
* @throws \InvalidArgumentException if any UUID is not found.
*/
public function exportModuleContent($module_name);
......
......@@ -186,4 +186,22 @@ class ExporterIntegrationTest extends KernelTestBase {
$this->assertEqual($content['node'][$test_uuid], $expected_node);
}
/**
* Tests exportModuleContent()
*/
public function testModuleExportException() {
\Drupal::service('module_installer')->install([
'node',
'default_content',
'default_content_export_test',
]);
\Drupal::service('router.builder')->rebuild();
$this->defaultContentManager = \Drupal::service('default_content.exporter');
$this->setExpectedException(\InvalidArgumentException::class);
// Should throw an exception for missing uuid in default_content_export_test
$this->defaultContentManager->exportModuleContent('default_content_export_test');
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment