From 5e7a84d74feece77bea2ced6a63a448e79c666b7 Mon Sep 17 00:00:00 2001 From: tedbow <tedbow@240860.no-reply.drupal.org> Date: Thu, 1 Sep 2022 12:40:51 +0000 Subject: [PATCH] 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 --- ...tomaticUpdatesExtensionsKernelTestBase.php | 41 ------------------- .../Validator/UpdateReleaseValidatorTest.php | 4 +- 2 files changed, 2 insertions(+), 43 deletions(-) diff --git a/automatic_updates_extensions/tests/src/Kernel/AutomaticUpdatesExtensionsKernelTestBase.php b/automatic_updates_extensions/tests/src/Kernel/AutomaticUpdatesExtensionsKernelTestBase.php index 04623651d2..f7a4b01a24 100644 --- a/automatic_updates_extensions/tests/src/Kernel/AutomaticUpdatesExtensionsKernelTestBase.php +++ b/automatic_updates_extensions/tests/src/Kernel/AutomaticUpdatesExtensionsKernelTestBase.php @@ -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. * diff --git a/automatic_updates_extensions/tests/src/Kernel/Validator/UpdateReleaseValidatorTest.php b/automatic_updates_extensions/tests/src/Kernel/Validator/UpdateReleaseValidatorTest.php index 57d7bbe2f6..3d79f87987 100644 --- a/automatic_updates_extensions/tests/src/Kernel/Validator/UpdateReleaseValidatorTest.php +++ b/automatic_updates_extensions/tests/src/Kernel/Validator/UpdateReleaseValidatorTest.php @@ -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', -- GitLab