Skip to content
Snippets Groups Projects
Commit 5e7a84d7 authored by Ted Bowman's avatar Ted Bowman
Browse files

Issue #3307168 by tedbow, kunal.sachdev:...

Issue #3307168 by tedbow, kunal.sachdev: \Drupal\Tests\automatic_updates_extensions\Kernel\AutomaticUpdatesExtensionsKernelTestBase::setReleaseMetadataForProjects is a duplicate of \Drupal\Tests\automatic_updates\Kernel\AutomaticUpdatesKernelTestBase::setReleaseMetadata
parent 3308cc49
No related branches found
No related tags found
No related merge requests found
......@@ -9,12 +9,6 @@ use Drupal\package_manager\Exception\StageValidationException;
use Drupal\Tests\automatic_updates\Kernel\AutomaticUpdatesKernelTestBase;
use Drupal\Tests\package_manager\Kernel\TestPathFactory;
use Drupal\Tests\package_manager\Kernel\TestStageTrait;
use GuzzleHttp\Client;
use GuzzleHttp\Handler\MockHandler;
use GuzzleHttp\HandlerStack;
use GuzzleHttp\Psr7\Response;
use GuzzleHttp\Psr7\Utils;
use Psr\Http\Message\RequestInterface;
/**
* Base class for kernel tests of the Automatic Updates Extensions module.
......@@ -59,13 +53,6 @@ abstract class AutomaticUpdatesExtensionsKernelTestBase extends AutomaticUpdates
}
}
/**
* The client.
*
* @var \GuzzleHttp\Client
*/
protected $client;
/**
* Asserts validation results are returned from a stage life cycle event.
*
......@@ -100,34 +87,6 @@ abstract class AutomaticUpdatesExtensionsKernelTestBase extends AutomaticUpdates
}
}
/**
* Sets the release metadata file to use when fetching available updates.
*
* @param string[] $files
* The paths of the XML metadata files to use, keyed by project name.
*/
protected function setReleaseMetadataForProjects(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, count($responses), $callable));
$this->client = new Client([
'handler' => HandlerStack::create($handler),
]);
$this->container->set('http_client', $this->client);
}
/**
* Creates an extension updater object for testing purposes.
*
......
......@@ -60,7 +60,7 @@ class UpdateReleaseValidatorTest extends AutomaticUpdatesExtensionsKernelTestBas
->set("system_info.$project", $module_info)
->save();
$this->setReleaseMetadataForProjects([
$this->setReleaseMetadata([
$project => __DIR__ . "/../../../fixtures/release-history/$project.1.1.xml",
'drupal' => __DIR__ . '/../../../../../tests/fixtures/release-history/drupal.9.8.2.xml',
]);
......@@ -128,7 +128,7 @@ class UpdateReleaseValidatorTest extends AutomaticUpdatesExtensionsKernelTestBas
$active_installed = __DIR__ . '/../../../fixtures/update_release_validator/active.installed.json';
$this->assertFileIsReadable($active_installed);
$this->assertFileIsReadable($staged_installed);
$this->setReleaseMetadataForProjects([
$this->setReleaseMetadata([
'aaa_automatic_updates_test' => __DIR__ . "/../../../../../tests/fixtures/release-history/aaa_automatic_updates_test.9.8.2.xml",
$project => __DIR__ . "/../../../fixtures/release-history/$project.1.1.xml",
'drupal' => __DIR__ . '/../../../../../tests/fixtures/release-history/drupal.9.8.2.xml',
......
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