You are here

public function SalesforcePushQueueProcessorRestTest::testProcessItemEntityNotFound in Salesforce Suite 8.3

Same name and namespace in other branches
  1. 8.4 modules/salesforce_push/tests/src/Unit/SalesforcePushQueueProcessorRestTest.php \Drupal\Tests\salesforce_push\Unit\SalesforcePushQueueProcessorRestTest::testProcessItemEntityNotFound()
  2. 5.0.x modules/salesforce_push/tests/src/Unit/SalesforcePushQueueProcessorRestTest.php \Drupal\Tests\salesforce_push\Unit\SalesforcePushQueueProcessorRestTest::testProcessItemEntityNotFound()

@covers ::processItem

@expectedException \Drupal\salesforce\EntityNotFoundException

File

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

Class

SalesforcePushQueueProcessorRestTest
Test SalesforcePushQueueProcessor plugin Rest.

Namespace

Drupal\Tests\salesforce_push\Unit

Code

public function testProcessItemEntityNotFound() {

  // Test throwing exception on drupal entity not found.
  $this->queueItem = (object) [
    'op' => '',
    'mapped_object_id' => 'foo',
    'name' => 'bar',
    'entity_id' => 'foo',
  ];
  $this->mappedObject = $this
    ->getMock(MappedObjectInterface::class);
  $this->mappedObject
    ->expects($this
    ->any())
    ->method('isNew')
    ->willReturn(TRUE);
  $this->entityStorage = $this
    ->getMock(SqlEntityStorageInterface::CLASS);
  $prophecy = $this
    ->prophesize(EntityTypeManagerInterface::class);
  $prophecy
    ->getStorage($this->entityType)
    ->willReturn($this->entityStorage);
  $prophecy
    ->getStorage('salesforce_mapping')
    ->willReturn($this->mappingStorage);
  $prophecy
    ->getStorage('salesforce_mapped_object')
    ->willReturn($this->mappedObjectStorage);
  $this->entityTypeManager = $prophecy
    ->reveal();
  $this->entityStorage
    ->expects($this
    ->once())
    ->method('load')
    ->willReturn(NULL);
  $this->handler = $this
    ->getMock(Rest::class, [
    'getMappedObject',
  ], [
    [],
    '',
    [],
    $this->queue,
    $this->client,
    $this->entityTypeManager,
    $this->eventDispatcher,
  ]);
  $this->handler
    ->expects($this
    ->once())
    ->method('getMappedObject')
    ->willReturn($this->mappedObject);
  $this->handler
    ->processItem($this->queueItem);
}