function ProviderRepositoryTest::setUp

Same name in other branches
  1. 9 core/modules/media/tests/src/Unit/ProviderRepositoryTest.php \Drupal\Tests\media\Unit\ProviderRepositoryTest::setUp()
  2. 10 core/modules/media/tests/src/Unit/ProviderRepositoryTest.php \Drupal\Tests\media\Unit\ProviderRepositoryTest::setUp()

Overrides UnitTestCase::setUp

File

core/modules/media/tests/src/Unit/ProviderRepositoryTest.php, line 62

Class

ProviderRepositoryTest
@coversDefaultClass \Drupal\media\OEmbed\ProviderRepository

Namespace

Drupal\Tests\media\Unit

Code

protected function setUp() : void {
    parent::setUp();
    $config_factory = $this->getConfigFactoryStub([
        'media.settings' => [
            'oembed_providers_url' => 'https://oembed.com/providers.json',
        ],
    ]);
    $key_value_factory = new KeyValueMemoryFactory();
    $this->keyValue = $key_value_factory->get('media');
    $this->currentTime = time();
    $time = $this->prophesize('\\Drupal\\Component\\Datetime\\TimeInterface');
    $time->getCurrentTime()
        ->willReturn($this->currentTime);
    $this->logger = $this->prophesize('\\Psr\\Log\\LoggerInterface');
    $logger_factory = $this->prophesize(LoggerChannelFactoryInterface::class);
    $logger_factory->get('media')
        ->willReturn($this->logger);
    $this->responses = new MockHandler();
    $client = new Client([
        'handler' => HandlerStack::create($this->responses),
    ]);
    $this->repository = new ProviderRepository($client, $config_factory, $time->reveal(), $key_value_factory, $logger_factory->reveal());
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.