You are here

public function SalesforcePushQueueProcessorRestTest::testProcess in Salesforce Suite 8.3

@covers ::process @expectedException \Drupal\Core\Queue\SuspendQueueException

File

modules/salesforce_push/tests/src/Unit/SalesforcePushQueueProcessorRestTest.php, line 85

Class

SalesforcePushQueueProcessorRestTest
Test SalesforcePushQueueProcessor plugin Rest.

Namespace

Drupal\Tests\salesforce_push\Unit

Code

public function testProcess() {
  $this->handler = $this
    ->getMock(Rest::class, [
    'processItem',
  ], [
    [],
    '',
    [],
    $this->queue,
    $this->client,
    $this->entityTypeManager,
    $this->eventDispatcher,
  ]);
  $this->client
    ->expects($this
    ->at(0))
    ->method('isAuthorized')
    ->willReturn(TRUE);

  // Test suspend queue if not authorized.
  $this->client
    ->expects($this
    ->at(1))
    ->method('isAuthorized')
    ->willReturn(FALSE);
  $this->handler
    ->expects($this
    ->once())
    ->method('processItem')
    ->willReturn(NULL);

  // Test delete item after successful processItem()
  $this->queue
    ->expects($this
    ->once())
    ->method('deleteItem')
    ->willReturn(NULL);
  $this->handler
    ->process([
    (object) [
      1,
    ],
  ]);
  $this->handler
    ->process([
    (object) [
      2,
    ],
  ]);
}