Skip to content
Snippets Groups Projects

Issue #3258056: Simplify Stage::dispatch exception handling

@@ -3,6 +3,7 @@
namespace Drupal\Tests\automatic_updates\Functional;
use Drupal\automatic_updates\Event\ReadinessCheckEvent;
use Drupal\automatic_updates\Exception\UpdateException;
use Drupal\package_manager\Event\PreCreateEvent;
use Drupal\package_manager\ValidationResult;
use Drupal\automatic_updates_test\ReadinessChecker\TestChecker1;
@@ -175,9 +176,9 @@ class UpdaterFormTest extends AutomaticUpdatesFunctionalTestBase {
$assert_session->pageTextNotContains((string) $message);
TestChecker1::setTestResult(NULL, ReadinessCheckEvent::class);
// Set an exception that the validator will throw, so we can test what
// Repackage the validation error as an exception, so we can test what
// happens if a validator throws once the update has started.
$error = new \RuntimeException('The update exploded.');
$error = new UpdateException($expected_results, 'The update exploded.');
TestChecker1::setException($error, PreCreateEvent::class);
$session->reload();
$assert_session->pageTextNotContains(static::$errorsExplanation);
@@ -190,7 +191,10 @@ class UpdaterFormTest extends AutomaticUpdatesFunctionalTestBase {
$this->assertUpdateStagedTimes(0);
$assert_session->pageTextContainsOnce('An error has occurred.');
$page->clickLink('the error page');
// We should see the exception message.
$assert_session->pageTextContainsOnce((string) $expected_results[0]->getMessages()[0]);
// Since there's only one error message, we shouldn't see the summary...
$assert_session->pageTextNotContains($expected_results[0]->getSummary());
// ...but we should see the exception message.
$assert_session->pageTextContainsOnce('The update exploded.');
// If the error is thrown in PreCreateEvent the update stage will not have
// been created.
Loading