public function AssetRefreshManagerTest::testNonInterruptedFetch in Media: Acquia DAM 8
Tests a "non-interrupted API fetch" scenario.
@dataProvider providerTestNonInterruptedFetch
Parameters
array $request_query_options: The list of request query options.
array $response: The stub of Notifications API response.
array $expected_asset_ids: The list of expected asset ids.
int $expected_total: The expected number of media entities to add to the queue.
File
- tests/
src/ Unit/ AssetRefreshManagerTest.php, line 187
Class
- AssetRefreshManagerTest
- AssetRefreshManager Service test.
Namespace
Drupal\Tests\media_acquiadam\UnitCode
public function testNonInterruptedFetch(array $request_query_options, array $response, array $expected_asset_ids, int $expected_total) {
$this->state
->method('get')
->willReturnMap([
[
'media_acquiadam.notifications_next_page',
NULL,
NULL,
],
[
'media_acquiadam.notifications_starttime',
NULL,
NULL,
],
[
'media_acquiadam.notifications_endtime',
self::REQUEST_TIME,
self::REQUEST_TIME,
],
]);
$this
->setupApiResponseStub($request_query_options, $response);
$this
->setupMediaEntityExpectations($expected_asset_ids, $expected_total);
$this->state
->method('set')
->withConsecutive([
'media_acquiadam.notifications_starttime',
self::LAST_READ_TIMESTAMP,
], [
'media_acquiadam.notifications_starttime',
self::REQUEST_TIME,
], [
'media_acquiadam.notifications_endtime',
NULL,
], [
'media_acquiadam.notifications_next_page',
NULL,
]);
$actual = $this->assetRefreshManager
->updateQueue($this
->getAssetIdFieldsStub());
$this
->assertEquals($expected_total, $actual);
}