You are here

protected function SalesforcePushQueueProcessorRestTest::setUp in Salesforce Suite 8.4

Same name and namespace in other branches
  1. 8.3 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 43

Class

SalesforcePushQueueProcessorRestTest
Test SalesforcePushQueueProcessor plugin Rest.

Namespace

Drupal\Tests\salesforce_push\Unit

Code

protected function setUp() {
  $this->entityType = 'default';
  $this->queue = $this
    ->getMockBuilder(PushQueueInterface::CLASS)
    ->getMock();
  $this->client = $this
    ->getMockBuilder(RestClientInterface::CLASS)
    ->getMock();
  $this->eventDispatcher = $this
    ->getMockBuilder(EventDispatcherInterface::CLASS)
    ->getMock();
  $this->eventDispatcher
    ->expects($this
    ->any())
    ->method('dispatch')
    ->willReturn(NULL);
  $this->entity_manager = $this
    ->getMockBuilder(EntityTypeManagerInterface::class)
    ->getMock();
  $this->string_translation = $this
    ->getMockBuilder(TranslationInterface::class)
    ->getMock();
  $this->mapping = $this
    ->getMockBuilder(SalesforceMappingInterface::CLASS)
    ->getMock();
  $this->mapping
    ->expects($this
    ->any())
    ->method('id')
    ->willReturn('foo_mapping');
  $this->mapping
    ->expects($this
    ->any())
    ->method('__get')
    ->with($this
    ->equalTo('drupal_entity_type'))
    ->willReturn($this->entityType);
  $this->mappingStorage = $this
    ->getMockBuilder(ConfigEntityStorageInterface::CLASS)
    ->getMock();
  $this->mappingStorage
    ->expects($this
    ->any())
    ->method('load')
    ->willReturn($this->mapping);
  $this->mappedObjectStorage = $this
    ->getMockBuilder(SqlEntityStorageInterface::CLASS)
    ->getMock();
  $prophecy = $this
    ->prophesize(EntityTypeManagerInterface::class);
  $prophecy
    ->getStorage('salesforce_mapping')
    ->willReturn($this->mappingStorage);
  $prophecy
    ->getStorage('salesforce_mapped_object')
    ->willReturn($this->mappedObjectStorage);
  $this->entityTypeManager = $prophecy
    ->reveal();
  $this->authToken = $this
    ->getMockBuilder(TokenInterface::CLASS)
    ->getMock();
  $this->authMan = $this
    ->getMockBuilder(SalesforceAuthProviderPluginManager::CLASS)
    ->disableOriginalConstructor()
    ->getMock();
  $this->authMan
    ->expects($this
    ->any())
    ->method('getToken')
    ->willReturn($this->authToken);
  $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_type.manager', $this->entity_manager);
  \Drupal::setContainer($container);
  $this->handler = new Rest([], '', [], $this->queue, $this->entityTypeManager, $this->eventDispatcher, $this->authMan);
}