Skip to content
Snippets Groups Projects
Commit 144de76f authored by Kunal Sachdev's avatar Kunal Sachdev Committed by Adam G-H
Browse files

Issue #3299417 by kunal.sachdev: Add a build test to prove Package Manager can...

Issue #3299417 by kunal.sachdev: Add a build test to prove Package Manager can be used to require new packages
parent b566c985
No related branches found
No related tags found
No related merge requests found
...@@ -82,6 +82,12 @@ class SystemChangeRecorder implements EventSubscriberInterface { ...@@ -82,6 +82,12 @@ class SystemChangeRecorder implements EventSubscriberInterface {
* The stage event. * The stage event.
*/ */
public function recordSystemState(StageEvent $event): void { public function recordSystemState(StageEvent $event): void {
// The rest of this method is strongly coupled to updated_module, so if it
// isn't installed, bail out now.
if (!\Drupal::moduleHandler()->moduleExists('updated_module')) {
return;
}
$results = []; $results = [];
// Call a function in a loaded file to ensure it doesn't get reloaded after // Call a function in a loaded file to ensure it doesn't get reloaded after
......
<?php
namespace Drupal\Tests\package_manager\Build;
/**
* Tests installing packages in a staging area.
*
* @group package_manager
*/
class PackageInstallTest extends TemplateProjectTestBase {
/**
* Tests installing packages in a staging area.
*/
public function testPackageInstall(): void {
$this->createTestProject('RecommendedProject');
$this->addRepository('alpha', __DIR__ . '/../../fixtures/alpha/1.0.0');
$this->installQuickStart('minimal');
$this->formLogin($this->adminUsername, $this->adminPassword);
$this->installModules(['package_manager_test_api']);
// Use the API endpoint to create a stage and install alpha 1.0.0. We ask
// the API to return the contents of composer.json file of installed module,
// so we can assert that the module was installed with the expected version.
// @see \Drupal\package_manager_test_api\ApiController::run()
$query = http_build_query([
'runtime' => [
'drupal/alpha:1.0.0',
],
'files_to_return' => [
'web/modules/contrib/alpha/composer.json',
],
]);
$this->visit("/package-manager-test-api?$query");
$mink = $this->getMink();
$mink->assertSession()->statusCodeEquals(200);
$file_contents = $mink->getSession()->getPage()->getContent();
$file_contents = json_decode($file_contents, TRUE);
$this->assertArrayHasKey('web/modules/contrib/alpha/composer.json', $file_contents);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment