Skip to content
Snippets Groups Projects
Commit 0a0fbc80 authored by git's avatar git
Browse files

Cleans up PullBaseTest::testProcessItemCreate()

testProcessItemCreate() now test using the non-Exception based login in PullBase::processItem().
Assertion test added to ensure mapped object passed is empty to trigger create logic
continue statement commented out (to be removed most likely) to address following error:
PHP Fatal error:  'continue' not in the 'loop' or 'switch' context in
sfsuite/modules/contrib/salesforce/modules/salesforce_pull/src/Plugin/QueueWorker/PullBase.php
on line 166
parent aae6d320
No related branches found
No related tags found
No related merge requests found
......@@ -163,7 +163,7 @@ abstract class PullBase extends QueueWorkerBase implements ContainerFactoryPlugi
'%msg' => $e->getMessage(),
]
);
continue;
//continue;
}
// Flag this entity as having been processed. This does not persist,
......
......@@ -153,43 +153,16 @@ class PullBaseTest extends UnitTestCase {
/**
* Test handler operation, create with good data
* NOTE: can only test that exception is thrown, cannot test that the
* createEntity() method executes as expected - that must be in a separate test
*/
public function testProcessItemCreate() {
//mock StringTranslation service
$prophecy = $this->prophesize(TranslationInterface::CLASS);
$this->translation = $prophecy->reveal();
// mock mapped object EntityStorage object
$prophecy = $this->prophesize(EntityStorageBase::CLASS);
$prophecy->loadByProperties(Argument::any())->willReturn([]);
$this->mappedObjectStorage = $prophecy->reveal();
// mock sf mapping
// @TODO move this into setUp()?
$my_mapping = new SalesforceMapping([
'id' => 'test',
'drupal_bundle' => 'test',
'drupal_entity_type' => 'test',
'salesforce_object_type' => 'test',
'sync_triggers' => [
MappingConstants::SALESFORCE_MAPPING_SYNC_SF_CREATE => MappingConstants::SALESFORCE_MAPPING_SYNC_SF_CREATE
],
], 'salesforce_mapping');
$this->assertEquals('test', $my_mapping->getDrupalBundle());
$this->assertEquals('test', $my_mapping->getDrupalEntityType());
$this->assertTrue($my_mapping->doesPull());
// mock sf mapping entitystorage
$prophecy = $this->prophesize(EntityStorageBase::CLASS);
$prophecy->load(Argument::any())->willReturn($my_mapping);
$this->mappingObjectStorage = $prophecy->reveal();
// mock EntityTypeManagerInterface
$prophecy = $this->prophesize(EntityTypeManagerInterface::CLASS);
$prophecy->getStorage('salesforce_mapping')->willReturn($this->mappingObjectStorage);
$prophecy->getStorage('salesforce_mapping')->willReturn($this->configStorage);
$prophecy->getStorage('salesforce_mapped_object')->willReturn($this->mappedObjectStorage);
$prophecy->getStorage('test')->willReturn($this->newEntityStorage); $prophecy->getDefinition('test')->willReturn($this->entityDefinition);
$this->etm = $prophecy->reveal();
......@@ -202,6 +175,7 @@ class PullBaseTest extends UnitTestCase {
$item = new PullQueueItem($sobject, $this->mapping);
$this->pullWorker->processItem($item);
$this->assertEmpty($this->etm->getStorage('salesforce_mapped_object')->loadByProperties(['name' => 'test_test']));
$this->assertEquals('create', $this->pullWorker->getDone());
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment