You are here

protected function AcquiadamConfigFormTest::assertBatchRun in Media: Acquia DAM 8

Makes assertion during an emulated batch run.

Parameters

array $context: The Batch context.

int $run: The run index.

int $total_media_ids: The total number of items added to the batch.

1 call to AcquiadamConfigFormTest::assertBatchRun()
AcquiadamConfigFormTest::testProcessBatchItems in tests/src/Unit/AcquiadamConfigFormTest.php
Tests a batch processing.

File

tests/src/Unit/AcquiadamConfigFormTest.php, line 170

Class

AcquiadamConfigFormTest
Config form test.

Namespace

Drupal\Tests\media_acquiadam\Unit

Code

protected function assertBatchRun(array $context, int $run, int $total_media_ids) : void {
  $processed = AcquiadamConfig::BATCH_SIZE * $run;
  $processed = $processed > $total_media_ids ? $total_media_ids : $processed;
  $this
    ->assertNotEmpty($context);
  $this
    ->assertEquals($processed, $context['sandbox']['progress']);
  $this
    ->assertEquals($total_media_ids, $context['sandbox']['max']);
  $this
    ->assertEquals($total_media_ids, $context['results']['total']);
  if ($processed < $total_media_ids) {
    $this
      ->assertEquals(range(1 + $processed, $total_media_ids), $context['sandbox']['items']);
  }
  else {
    $this
      ->assertEmpty($context['sandbox']['items']);
  }
  $this
    ->assertEquals(1560000000, $context['results']['start_time']);
  $this
    ->assertEquals($processed, $context['results']['processed']);
  $this
    ->assertEquals($processed / $total_media_ids, $context['finished']);
}