You are here

public function ContentHubImportQueueBaseTest::testProcessItem in Acquia Content Hub 8

Ensure that the queue can process given entities.

@dataProvider provideQueueItems

Parameters

mixed $item: Some items to test.

array $expected: An array of expected items.

File

tests/src/Unit/Plugin/QueueWorker/ContentHubImportQueueBaseTest.php, line 65

Class

ContentHubImportQueueBaseTest
Test for Content Hub Import Queue Base.

Namespace

Drupal\Tests\acquia_contenthub\Unit\Plugin\QueueWorker

Code

public function testProcessItem($item = [], array $expected = []) {
  $import_entity_manager = $this
    ->getMockBuilder(ImportEntityManager::class)
    ->disableOriginalConstructor()
    ->setMethods([
    'importRemoteEntity',
  ])
    ->getMock();
  foreach ($expected as $index => $values) {

    // @codingStandardsIgnoreStart

    /**
     * @var string $uuid
     * @var bool $deps
     * @var bool $author
     * @var int $status
     */

    // @codingStandardsIgnoreEnd
    $values = array_combine([
      'uuid',
      'deps',
      'author',
      'status',
    ], $values);
    extract($values);
    $import_entity_manager
      ->expects($this
      ->at($index))
      ->method('importRemoteEntity')
      ->with($uuid, $deps, $author, $status);
  }
  $worker = $this
    ->getMockBuilder(ContentHubImportQueue::class)
    ->disableOriginalConstructor()
    ->setMethods([
    'getEntityManager',
  ])
    ->getMock();
  $worker
    ->expects($this
    ->any())
    ->method('getEntityManager')
    ->willReturn($import_entity_manager);
  $worker
    ->processItem($item);
}