function SecurityAdvisoriesFetcherTest::testNoHttpFallback
Same name in other branches
- 10 core/modules/system/tests/src/Kernel/SecurityAdvisories/SecurityAdvisoriesFetcherTest.php \Drupal\Tests\system\Kernel\SecurityAdvisories\SecurityAdvisoriesFetcherTest::testNoHttpFallback()
- 11.x core/modules/system/tests/src/Kernel/SecurityAdvisories/SecurityAdvisoriesFetcherTest.php \Drupal\Tests\system\Kernel\SecurityAdvisories\SecurityAdvisoriesFetcherTest::testNoHttpFallback()
@covers ::doRequest @covers ::getSecurityAdvisories
File
-
core/
modules/ system/ tests/ src/ Kernel/ SecurityAdvisories/ SecurityAdvisoriesFetcherTest.php, line 667
Class
- SecurityAdvisoriesFetcherTest
- @coversDefaultClass \Drupal\system\SecurityAdvisories\SecurityAdvisoriesFetcher
Namespace
Drupal\Tests\system\Kernel\SecurityAdvisoriesCode
public function testNoHttpFallback() : void {
$this->setTestFeedResponses([
new Response('500', [], 'HTTPS failed'),
]);
$exception_thrown = FALSE;
try {
$this->getAdvisories();
} catch (TransferException $exception) {
$this->assertSame("Server error: `GET https://updates.drupal.org/psa.json` resulted in a `500 Internal Server Error` response:\nHTTPS failed\n", $exception->getMessage());
$exception_thrown = TRUE;
}
$this->assertTrue($exception_thrown);
// There should only be one request / response pair.
$this->assertCount(1, $this->history);
$request = $this->history[0]['request'];
$this->assertNotEmpty($request);
// It should have only been an HTTPS request.
$this->assertEquals('https', $request->getUri()
->getScheme());
// And it should have failed.
$response = $this->history[0]['response'];
$this->assertEquals(500, $response->getStatusCode());
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.