diff --git a/core/tests/Drupal/KernelTests/KernelTestBaseTest.php b/core/tests/Drupal/KernelTests/KernelTestBaseTest.php index ab4dff1f7fd77997bdc3749ce7c361b0d872b5b8..9339fbfe857b170b7b1ac1f5abc307ce5ea2e766 100644 --- a/core/tests/Drupal/KernelTests/KernelTestBaseTest.php +++ b/core/tests/Drupal/KernelTests/KernelTestBaseTest.php @@ -175,10 +175,13 @@ public function testOutboundHttpRequest() { // which checks the DRUPAL_TEST_IN_CHILD_SITE constant, that is not defined // in Kernel tests. try { - $this->container->get('http_client')->get('http://example.com'); + /** @var \GuzzleHttp\Psr7\Response $response */ + $response = $this->container->get('http_client')->head('http://example.com'); + self::assertEquals(200, $response->getStatusCode()); } - catch (GuzzleException $e) { - // Ignore any HTTP errors. + catch (\Throwable $e) { + // Ignore any HTTP errors, any other exception is considered an error. + self::assertInstanceOf(GuzzleException::class, $e, sprintf('Asserting that a possible exception is thrown. Got "%s" with message: "%s".', get_class($e), $e->getMessage())); } }