protected function SecurityAdvisoriesFetcherTest::setTestFeedResponses in Drupal 9
Sets test feed responses.
Parameters
\GuzzleHttp\Psr7\Response[] $responses: The responses for the http_client service to return.
4 calls to SecurityAdvisoriesFetcherTest::setTestFeedResponses()
- SecurityAdvisoriesFetcherTest::setFeedItems in core/
modules/ system/ tests/ src/ Kernel/ SecurityAdvisories/ SecurityAdvisoriesFetcherTest.php - Sets the feed items to be returned for the test.
- SecurityAdvisoriesFetcherTest::testHttpFallback in core/
modules/ system/ tests/ src/ Kernel/ SecurityAdvisories/ SecurityAdvisoriesFetcherTest.php - @covers ::doRequest @covers ::getSecurityAdvisories
- SecurityAdvisoriesFetcherTest::testInvalidJsonResponse in core/
modules/ system/ tests/ src/ Kernel/ SecurityAdvisories/ SecurityAdvisoriesFetcherTest.php - Tests that invalid JSON feed responses are not stored.
- SecurityAdvisoriesFetcherTest::testNoHttpFallback in core/
modules/ system/ tests/ src/ Kernel/ SecurityAdvisories/ SecurityAdvisoriesFetcherTest.php - @covers ::doRequest @covers ::getSecurityAdvisories
File
- core/
modules/ system/ tests/ src/ Kernel/ SecurityAdvisories/ SecurityAdvisoriesFetcherTest.php, line 713
Class
- SecurityAdvisoriesFetcherTest
- @coversDefaultClass \Drupal\system\SecurityAdvisories\SecurityAdvisoriesFetcher
Namespace
Drupal\Tests\system\Kernel\SecurityAdvisoriesCode
protected function setTestFeedResponses(array $responses) : void {
// Create a mock and queue responses.
$mock = new MockHandler($responses);
$handler_stack = HandlerStack::create($mock);
$history = Middleware::history($this->history);
$handler_stack
->push($history);
// Rebuild the container because the 'system.sa_fetcher' service and other
// services may already have an instantiated instance of the 'http_client'
// service without these changes.
$this->container
->get('kernel')
->rebuildContainer();
$this->container = $this->container
->get('kernel')
->getContainer();
$this->container
->get('logger.factory')
->addLogger($this);
$this->container
->set('http_client', new Client([
'handler' => $handler_stack,
]));
}