protected function AcquiadamConfigFormTest::setUp in Media: Acquia DAM 8
Overrides UnitTestCase::setUp
File
- tests/
src/ Unit/ AcquiadamConfigFormTest.php, line 199
Class
- AcquiadamConfigFormTest
- Config form test.
Namespace
Drupal\Tests\media_acquiadam\UnitCode
protected function setUp() {
parent::setUp();
// We need to override the DAM client so that we can fake authentication.
$dam_client = $this
->getMockBuilder(Client::class)
->disableOriginalConstructor()
->getMock();
// We do not actually care about validating anything at this point, but
// the validateForm method does a basic "does authentication work" check.
$dam_client
->expects($this
->any())
->method('getAccountSubscriptionDetails')
->willReturn([]);
// We need to make sure we get our mocked class instead of the original.
$acquiadam_client_factory = $this
->getMockBuilder(ClientFactory::class)
->disableOriginalConstructor()
->getMock();
$acquiadam_client_factory
->expects($this
->any())
->method('getWithCredentials')
->willReturn($dam_client);
$time = $this
->getMockBuilder(Time::class)
->disableOriginalConstructor()
->getMock();
$time
->method('getRequestTime')
->willReturn(1560000000);
$this->queueWorker = $this
->getMockBuilder(AssetRefresh::class)
->disableOriginalConstructor()
->getMock();
$queue_worker_manager = $this
->getMockBuilder(QueueWorkerManager::class)
->disableOriginalConstructor()
->getMock();
$queue_worker_manager
->expects($this
->any())
->method('createInstance')
->willReturn($this->queueWorker);
$this->state = $this
->getMockBuilder(State::class)
->disableOriginalConstructor()
->getMock();
$this->container = new ContainerBuilder();
$this->container
->set('string_translation', $this
->getStringTranslationStub());
$this->container
->set('media_acquiadam.client_factory', $acquiadam_client_factory);
$this->container
->set('config.factory', $this
->getConfigFactoryStub());
$this->container
->set('datetime.time', $time);
$this->container
->set('plugin.manager.queue_worker', $queue_worker_manager);
$this->container
->set('state', $this->state);
\Drupal::setContainer($this->container);
$this->acquiaDamConfig = $this
->getMockedAcquidamConfig();
}