Skip to content
Snippets Groups Projects

Issue #3321684: Should most validators that subscribe to PreCreate check readiness to update also subscribe to PreApply?

Merged Issue #3321684: Should most validators that subscribe to PreCreate check readiness to update also subscribe to PreApply?
1 file
+ 25
0
Compare changes
  • Side-by-side
  • Inline
@@ -5,6 +5,7 @@ declare(strict_types = 1);
namespace Drupal\Tests\package_manager\Kernel;
use Drupal\package_manager\Event\PreCreateEvent;
use Drupal\package_manager\Exception\StageValidationException;
use Drupal\package_manager\ValidationResult;
/**
@@ -64,4 +65,28 @@ class PendingUpdatesValidatorTest extends PackageManagerKernelTestBase {
$this->assertResults([$result], PreCreateEvent::class);
}
/**
* Tests that pending updates stop an operation from being applied.
*/
public function testPendingUpdateAfterStaged(): void {
$this->registerPostUpdateFunctions();
$stage = $this->createStage();
$stage->create();
$stage->require(['drupal/core:9.8.1']);
// Make an additional post-update function available; the update registry
// will think it's pending.
require_once __DIR__ . '/../../fixtures/post_update.php';
$result = ValidationResult::createError([
'Some modules have database schema updates to install. You should run the <a href="/update.php">database update script</a> immediately.',
]);
try {
$stage->apply();
$this->fail('Able to apply update even though there is pending update.');
}
catch (StageValidationException $exception) {
$this->assertValidationResultsEqual([$result], $exception->getResults());
}
}
}
Loading