Skip to content
Snippets Groups Projects
Commit f6b98cf9 authored by Adam G-H's avatar Adam G-H
Browse files

Refactor how tempstore is inspected

parent 6924f0b7
No related branches found
No related tags found
No related merge requests found
......@@ -11,6 +11,7 @@ use Drupal\package_manager\Event\PreCreateEvent;
use Drupal\package_manager\Event\PreRequireEvent;
use Drupal\package_manager\ValidationResult;
use Drupal\package_manager_test_validation\EventSubscriber\TestSubscriber;
use Drupal\project_browser\ComposerInstaller\Installer;
use Drupal\project_browser_test\Datetime\TestTime;
use Drupal\Tests\BrowserTestBase;
use Drupal\Tests\project_browser\Traits\PackageManagerFixtureUtilityTrait;
......@@ -175,10 +176,13 @@ class InstallerControllerTest extends BrowserTestBase {
private function doStart() {
$this->assertProjectBrowserTempStatus(NULL, NULL);
$this->drupalGet('admin/modules/project_browser/install-begin/drupal/awesome_module');
$this->stageId = $this->sharedTempStore->get('package_manager_stage')->get('lock')[0];
$this->assertSession()->statusCodeEquals(200);
$expected_output = sprintf('{"phase":"create","status":0,"stage_id":"%s"}', $this->stageId);
$this->assertSame($expected_output, $this->getSession()->getPage()->getContent());
$actual_output = $this->getSession()->getPage()->getContent();
$actual_output = Json::decode($actual_output);
$this->assertSame('create', $actual_output['phase']);
$this->assertSame(0, $actual_output['status']);
$this->assertNotEmpty($actual_output['stage_id']);
$this->stageId = $actual_output['stage_id'];
$this->assertInstallInProgress('awesome_module', 'creating install stage');
}
......@@ -534,9 +538,17 @@ class InstallerControllerTest extends BrowserTestBase {
* The expected value of the 'core requiring' state.
*/
protected function assertProjectBrowserTempStatus($expected_requiring, $expected_installing) {
$project_browser_requiring = $this->sharedTempStore->get('project_browser')->get('requiring');
$project_browser_installing = $this->sharedTempStore->get('project_browser')->get('installing');
$this->assertSame($expected_requiring, $project_browser_requiring);
$metadata_key = new \ReflectionClassConstant(Installer::class, 'TEMPSTORE_METADATA_KEY');
// @see \Drupal\package_manager\StageBase::__construct()
// @see \Drupal\package_manager\StageBase::getMetadata()
$stage_metadata = $this->container->get('tempstore.shared')
->get('package_manager_stage')
->get($metadata_key->getValue());
// @see \Drupal\project_browser\Controller\InstallerController::__construct()
$project_browser_installing = $this->container->get('keyvalue.expirable')
->get('project_browser')
->get('installing');
$this->assertSame($expected_requiring, $stage_metadata['requiring'] ?? NULL);
$this->assertSame($expected_installing, $project_browser_installing);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment