function UpdateFetcherTest::setUp
Same name in other branches
- 8.9.x core/modules/update/tests/src/Unit/UpdateFetcherTest.php \Drupal\Tests\update\Unit\UpdateFetcherTest::setUp()
- 10 core/modules/update/tests/src/Unit/UpdateFetcherTest.php \Drupal\Tests\update\Unit\UpdateFetcherTest::setUp()
- 11.x core/modules/update/tests/src/Unit/UpdateFetcherTest.php \Drupal\Tests\update\Unit\UpdateFetcherTest::setUp()
Overrides UnitTestCase::setUp
File
-
core/
modules/ update/ tests/ src/ Unit/ UpdateFetcherTest.php, line 70
Class
- UpdateFetcherTest
- Tests update functionality unrelated to the database.
Namespace
Drupal\Tests\update\UnitCode
protected function setUp() : void {
parent::setUp();
$this->mockConfigFactory = $this->getConfigFactoryStub([
'update.settings' => [
'fetch_url' => 'http://www.example.com',
],
]);
$this->mockHttpClient = $this->createMock('\\GuzzleHttp\\ClientInterface');
$settings = new Settings([]);
$this->updateFetcher = new UpdateFetcher($this->mockConfigFactory, $this->mockHttpClient, $settings);
$this->testProject = [
'name' => 'update_test',
'project_type' => '',
'info' => [
'version' => '',
'project status url' => 'https://www.example.com',
],
'includes' => [
'module1' => 'Module 1',
'module2' => 'Module 2',
],
];
// Set up logger factory so that watchdog_exception() does not break and
// register this class as the logger so we can test messages.
$container = $this->createMock('Symfony\\Component\\DependencyInjection\\ContainerInterface');
$logger_factory = new LoggerChannelFactory();
$logger_factory->addLogger($this);
$container->expects($this->any())
->method('get')
->with('logger.factory')
->willReturn($logger_factory);
\Drupal::setContainer($container);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.