protected function PushQueueTest::setUp in Salesforce Suite 5.0.x
Same name and namespace in other branches
- 8.4 modules/salesforce_push/tests/src/Unit/PushQueueTest.php \Drupal\Tests\salesforce_push\Unit\PushQueueTest::setUp()
- 8.3 modules/salesforce_push/tests/src/Unit/PushQueueTest.php \Drupal\Tests\salesforce_push\Unit\PushQueueTest::setUp()
Overrides UnitTestCase::setUp
File
- modules/
salesforce_push/ tests/ src/ Unit/ PushQueueTest.php, line 39
Class
- PushQueueTest
- Test Object instantitation.
Namespace
Drupal\Tests\salesforce_push\UnitCode
protected function setUp() : void {
$this->schema = $this
->getMockBuilder(Schema::class)
->disableOriginalConstructor()
->getMock();
$this->schema
->expects($this
->any())
->method('tableExists')
->willReturn(TRUE);
$this->database = $this
->getMockBuilder(Connection::class)
->disableOriginalConstructor()
->getMock();
$this->database
->expects($this
->any())
->method('schema')
->willReturn($this->schema);
$this->state = $this
->getMockBuilder(StateInterface::class)
->getMock();
$this->push_queue_processor_plugin_manager = $this
->getMockBuilder(PushQueueProcessorPluginManager::class)
->disableOriginalConstructor()
->getMock();
$this->entityTypeManager = $this
->getMockBuilder(EntityTypeManagerInterface::class)
->getMock();
$this->eventDispatcher = $this
->getMockBuilder(EventDispatcherInterface::CLASS)
->getMock();
$this->eventDispatcher
->expects($this
->any())
->method('dispatch')
->willReturn(NULL);
$this->string_translation = $this
->getMockBuilder(TranslationInterface::class)
->getMock();
$this->time = $this
->getMockBuilder(TimeInterface::class)
->getMock();
$this->mappingStorage = $this
->getMockBuilder(SalesforceMappingStorage::CLASS)
->disableOriginalConstructor()
->getMock();
$this->mappedObjectStorage = $this
->getMockBuilder(SqlEntityStorageInterface::CLASS)
->getMock();
$this->entityStorage = $this
->getMockBuilder(SqlEntityStorageInterface::CLASS)
->getMock();
$this->entityTypeManager
->expects($this
->at(0))
->method('getStorage')
->with($this
->equalTo('salesforce_mapping'))
->willReturn($this->mappingStorage);
$this->entityTypeManager
->expects($this
->at(1))
->method('getStorage')
->with($this
->equalTo('salesforce_mapped_object'))
->willReturn($this->mappedObjectStorage);
// Mock config.
$prophecy = $this
->prophesize(Config::CLASS);
$prophecy
->get('global_push_limit', Argument::any())
->willReturn(PushQueue::DEFAULT_GLOBAL_LIMIT);
$config = $prophecy
->reveal();
$prophecy = $this
->prophesize(ConfigFactoryInterface::CLASS);
$prophecy
->get('salesforce.settings')
->willReturn($config);
$this->configFactory = $prophecy
->reveal();
$container = new ContainerBuilder();
$container
->set('database', $this->database);
$container
->set('state', $this->state);
$container
->set('entity_type.manager', $this->entityTypeManager);
$container
->set('event_dispatcher', $this->eventDispatcher);
$container
->set('string_translation', $this->string_translation);
$container
->set('plugin.manager.salesforce_push_queue_processor', $this->push_queue_processor_plugin_manager);
$container
->set('datetime.time', $this->time);
$container
->set('config.factory', $this->configFactory);
\Drupal::setContainer($container);
}