You are here

protected function UpdateTestBase::setReleaseMetadata in Automatic Updates 8.2

Prepares the test site to serve an XML feed of available release metadata.

Parameters

array $xml_map: The update XML map, as used by update_test.settings.

See also

\Drupal\automatic_updates_test\TestController::metadata()

1 call to UpdateTestBase::setReleaseMetadata()
CoreUpdateTest::createTestSite in tests/src/Build/CoreUpdateTest.php
Uses our already-installed dependencies to build a test site to update.

File

tests/src/Build/UpdateTestBase.php, line 91

Class

UpdateTestBase
Base class for tests that perform in-place updates.

Namespace

Drupal\Tests\automatic_updates\Build

Code

protected function setReleaseMetadata(array $xml_map) : void {
  $xml_map = var_export($xml_map, TRUE);
  $code = <<<END
\$config['update_test.settings']['xml_map'] = {<span class="php-variable">$xml_map</span>};
END;

  // When checking for updates, we need to be able to make sub-requests, but
  // the built-in PHP server is single-threaded. Therefore, if needed, open a
  // second server instance on another port, which will serve the metadata
  // about available updates.
  if (empty($this->metadataServer)) {
    $port = $this
      ->findAvailablePort();
    $this->metadataServer = $this
      ->instantiateServer($port, $this->webRoot);
    $code .= <<<END
\$config['update.settings']['fetch']['url'] = 'http://localhost:{<span class="php-variable">$port</span>}/automatic-update-test';
END;
  }
  $this
    ->addSettings($code, $this
    ->getWebRoot());
}