function UpdateFetcherTest::testUpdateFetcherNoFallback
Same name in other branches
- 10 core/modules/update/tests/src/Unit/UpdateFetcherTest.php \Drupal\Tests\update\Unit\UpdateFetcherTest::testUpdateFetcherNoFallback()
- 11.x core/modules/update/tests/src/Unit/UpdateFetcherTest.php \Drupal\Tests\update\Unit\UpdateFetcherTest::testUpdateFetcherNoFallback()
@covers ::doRequest @covers ::fetchProjectData
File
-
core/
modules/ update/ tests/ src/ Unit/ UpdateFetcherTest.php, line 187
Class
- UpdateFetcherTest
- Tests update functionality unrelated to the database.
Namespace
Drupal\Tests\update\UnitCode
public function testUpdateFetcherNoFallback() {
// First, try without the HTTP fallback setting, and HTTPS mocked to fail.
$settings = new Settings([]);
$this->mockClient(new Response('500', [], 'HTTPS failed'));
$update_fetcher = new UpdateFetcher($this->mockConfigFactory, $this->mockHttpClient, $settings);
$data = $update_fetcher->fetchProjectData($this->testProject, '');
// 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());
$this->assertEmpty($data);
$this->assertSame([
"Server error: `GET https://www.example.com/update_test/current` resulted in a `500 Internal Server Error` response:\nHTTPS failed\n",
], $this->logMessages);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.