function PackageManagerKernelTestBase::setReleaseMetadata
Sets the release metadata file to use when fetching available updates.
Parameters
string[] $files: The paths of the XML metadata files to use, keyed by project name.
8 calls to PackageManagerKernelTestBase::setReleaseMetadata()
- ChangeLoggerTest::testChangeLogging in core/
modules/ package_manager/ tests/ src/ Kernel/ ChangeLoggerTest.php - Tests that the requested and applied changes are logged.
- ComposerPluginsValidatorTest::testValidationDuringPreApply in core/
modules/ package_manager/ tests/ src/ Kernel/ ComposerPluginsValidatorTest.php - Tests composer plugins are validated during pre-apply.
- ProjectInfoTest::testGetInstallableReleases in core/
modules/ package_manager/ tests/ src/ Kernel/ ProjectInfoTest.php - @covers ::getInstallableReleases
- ProjectInfoTest::testGetSupportedBranches in core/
modules/ package_manager/ tests/ src/ Kernel/ ProjectInfoTest.php - @covers ::getSupportedBranches
- ProjectInfoTest::testInstalledVersionSafe in core/
modules/ package_manager/ tests/ src/ Kernel/ ProjectInfoTest.php - Tests checking if the currently installed version of a project is safe.
File
-
core/
modules/ package_manager/ tests/ src/ Kernel/ PackageManagerKernelTestBase.php, line 351
Class
- PackageManagerKernelTestBase
- Base class for kernel tests of Package Manager's functionality.
Namespace
Drupal\Tests\package_manager\KernelCode
protected function setReleaseMetadata(array $files) : void {
$responses = [];
foreach ($files as $project => $file) {
$metadata = Utils::tryFopen($file, 'r');
$responses["/release-history/{$project}/current"] = new Response(200, [], Utils::streamFor($metadata));
}
$callable = function (RequestInterface $request) use ($responses) : Response {
return $responses[$request->getUri()
->getPath()] ?? new Response(404);
};
// The mock handler's queue consist of same callable as many times as the
// number of requests we expect to be made for update XML because it will
// retrieve one item off the queue for each request.
// @see \GuzzleHttp\Handler\MockHandler::__invoke()
$handler = new MockHandler(array_fill(0, 100, $callable));
$this->client = new Client([
'handler' => HandlerStack::create($handler),
]);
$this->container
->set('http_client', $this->client);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.