You are here

protected function SalesforcePushQueueProcessorRestTest::setUp 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::setUp()
  2. 5.0.x modules/salesforce_push/tests/src/Unit/SalesforcePushQueueProcessorRestTest.php \Drupal\Tests\salesforce_push\Unit\SalesforcePushQueueProcessorRestTest::setUp()

Overrides UnitTestCase::setUp

File

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

Class

SalesforcePushQueueProcessorRestTest
Test SalesforcePushQueueProcessor plugin Rest.

Namespace

Drupal\Tests\salesforce_push\Unit

Code

protected function setUp() {
  $this->entityType = 'default';
  $this->queue = $this
    ->getMock(PushQueueInterface::CLASS);
  $this->client = $this
    ->getMock(RestClientInterface::CLASS);
  $this->eventDispatcher = $this
    ->getMock(EventDispatcherInterface::CLASS);
  $this->eventDispatcher
    ->expects($this
    ->any())
    ->method('dispatch')
    ->willReturn(NULL);
  $this->entity_manager = $this
    ->getMock(EntityManagerInterface::class);
  $this->string_translation = $this
    ->getMock(TranslationInterface::class);
  $this->mapping = $this
    ->getMock(SalesforceMappingInterface::CLASS);
  $this->mapping
    ->expects($this
    ->any())
    ->method('__get')
    ->with($this
    ->equalTo('drupal_entity_type'))
    ->willReturn($this->entityType);
  $this->mappingStorage = $this
    ->getMock(ConfigEntityStorageInterface::CLASS);
  $this->mappingStorage
    ->expects($this
    ->any())
    ->method('load')
    ->willReturn($this->mapping);
  $this->mappedObjectStorage = $this
    ->getMock(SqlEntityStorageInterface::CLASS);
  $prophecy = $this
    ->prophesize(EntityTypeManagerInterface::class);
  $prophecy
    ->getStorage('salesforce_mapping')
    ->willReturn($this->mappingStorage);
  $prophecy
    ->getStorage('salesforce_mapped_object')
    ->willReturn($this->mappedObjectStorage);
  $this->entityTypeManager = $prophecy
    ->reveal();
  $container = new ContainerBuilder();
  $container
    ->set('queue.salesforce_push', $this->queue);
  $container
    ->set('salesforce.client', $this->client);
  $container
    ->set('entity_type.manager', $this->entityTypeManager);
  $container
    ->set('event_dispatcher', $this->eventDispatcher);
  $container
    ->set('string_translation', $this->string_translation);
  $container
    ->set('entity.manager', $this->entity_manager);
  \Drupal::setContainer($container);
  $this->handler = new Rest([], '', [], $this->queue, $this->client, $this->entityTypeManager, $this->eventDispatcher);
}