protected function RedirectImportExportTest::forcePreSaveExceptionByUuid in Acquia Content Hub 8.2
Adds a listener to force an exception by UUID.
Parameters
string $error_stub_uuid: The UUID.
1 call to RedirectImportExportTest::forcePreSaveExceptionByUuid()
- RedirectImportExportTest::testExceptionOnRedirectImport in tests/
src/ Kernel/ RedirectImportExportTest.php - Tests if stubs are cleaned when there's an exception importing redirects.
File
- tests/
src/ Kernel/ RedirectImportExportTest.php, line 234
Class
- RedirectImportExportTest
- Tests redirect export and import.
Namespace
Drupal\Tests\acquia_contenthub\KernelCode
protected function forcePreSaveExceptionByUuid(string $error_stub_uuid) {
/** @var \Symfony\Component\EventDispatcher\EventDispatcherInterface $dispatcher */
$dispatcher = $this->container
->get('event_dispatcher');
$dispatcher
->addListener(AcquiaContentHubEvents::PRE_ENTITY_SAVE, function ($event) use ($error_stub_uuid) {
if ($event
->getCdf()
->getUuid() === $error_stub_uuid) {
throw new \Exception('Test exception entity uuid: ' . $error_stub_uuid);
}
});
}