protected function AssetRefreshManagerTest::setUp in Media: Acquia DAM 8
Overrides UnitTestCase::setUp
File
- tests/
src/ Unit/ AssetRefreshManagerTest.php, line 565
Class
- AssetRefreshManagerTest
- AssetRefreshManager Service test.
Namespace
Drupal\Tests\media_acquiadam\UnitCode
protected function setUp() {
parent::setUp();
$this->acquiadamClient = $this
->getMockBuilder(Acquiadam::class)
->setMethods([
'getNotifications',
])
->disableOriginalConstructor()
->getMock();
$this->state = $this
->getMockBuilder(State::class)
->disableOriginalConstructor()
->getMock();
$this->queue = $this
->getMockBuilder(DatabaseQueue::class)
->disableOriginalConstructor()
->getMock();
/** @var \Drupal\Core\Queue\QueueFactory|\PHPUnit\Framework\MockObject\MockObject $queue_factory */
$queue_factory = $this
->getMockBuilder(QueueFactory::class)
->disableOriginalConstructor()
->getMock();
$queue_factory
->method('get')
->willReturn($this->queue);
$this->entityQuery = $this
->getMockBuilder(Query::class)
->setMethods([
'orConditionGroup',
'condition',
'execute',
'get',
])
->disableOriginalConstructor()
->getMock();
$entity_storage = $this
->getMockBuilder(EntityStorageInterface::class)
->disableOriginalConstructor()
->getMock();
$entity_storage
->method('getQuery')
->willReturn($this->entityQuery);
$entity_type_manager = $this
->getMockBuilder(EntityTypeManagerInterface::class)
->disableOriginalConstructor()
->getMock();
$entity_type_manager
->method('getStorage')
->willReturnMap([
[
'media',
$entity_storage,
],
]);
/** @var \Drupal\Component\Datetime\Time|\PHPUnit\Framework\MockObject\MockObject $time */
$time = $this
->getMockBuilder(Time::class)
->disableOriginalConstructor()
->getMock();
$time
->method('getRequestTime')
->willReturn(self::REQUEST_TIME);
$this->container = new ContainerBuilder();
$this->container
->set('state', $this->state);
$this->container
->set('logger.factory', $this
->getLoggerFactoryStub());
$this->container
->set('queue', $queue_factory);
$this->container
->set('entity_type.manager', $entity_type_manager);
$this->container
->set('datetime.time', $time);
$this->container
->set('media_acquiadam.acquiadam', $this->acquiadamClient);
\Drupal::setContainer($this->container);
$this->assetRefreshManager = AssetRefreshManager::create($this->container);
$this->assetRefreshManager
->setLastReadInterval(10000000);
$this->assetRefreshManager
->setRequestLimit(3);
}