public function testRemovedStateIfFailed() { // no failed jobs $this->assertEmpty($this->getJobs('magento_customer_export', BatchStatus::FAILED)); /** @var Customer $customer */ $customer = $this->getReference('customer'); $e = new TransportException(); $e->setFaultCode(102); $this->transport->expects($this->once())->method('getCustomerInfo')->will($this->throwException($e)); $this->transport->expects($this->never())->method('updateCustomer'); $this->transport->expects($this->never())->method('createCustomer'); $jobResult = $this->getContainer()->get('oro_importexport.job_executor')->executeJob('export', 'magento_customer_export', ['channel' => $customer->getChannel()->getId(), 'entity' => $customer, 'changeSet' => [], 'twoWaySyncStrategy' => 'remote', 'writer_skip_clear' => true, 'processorAlias' => 'orocrm_magento']); $this->assertEmpty($jobResult->getFailureExceptions()); $this->assertTrue($jobResult->isSuccessful()); // no failed jobs $this->assertEmpty($this->getJobs('magento_customer_export', BatchStatus::FAILED)); $stateManager = new StateManager(); $this->assertTrue($stateManager->isInState($customer->getSyncState(), Customer::MAGENTO_REMOVED)); foreach ($customer->getAddresses() as $address) { $this->assertTrue($stateManager->isInState($address->getSyncState(), Address::MAGENTO_REMOVED)); } }
public function testStates() { $object = new \stdClass(); $object->stateField = null; $stateManager = new StateManager(); $this->assertFalse($stateManager->isInState($object->stateField, self::STATE_REQUIRE_ADDRESS)); $this->assertFalse($stateManager->isInState($object->stateField, self::STATE_REQUIRE_INFO)); $stateManager->addState($object, 'stateField', self::STATE_REQUIRE_ADDRESS); $this->assertTrue($stateManager->isInState($object->stateField, self::STATE_REQUIRE_ADDRESS)); $this->assertFalse($stateManager->isInState($object->stateField, self::STATE_REQUIRE_INFO)); $stateManager->addState($object, 'stateField', self::STATE_REQUIRE_INFO); $this->assertTrue($stateManager->isInState($object->stateField, self::STATE_REQUIRE_ADDRESS)); $this->assertTrue($stateManager->isInState($object->stateField, self::STATE_REQUIRE_INFO)); $stateManager->removeState($object, 'stateField', self::STATE_REQUIRE_ADDRESS); $this->assertFalse($stateManager->isInState($object->stateField, self::STATE_REQUIRE_ADDRESS)); $this->assertTrue($stateManager->isInState($object->stateField, self::STATE_REQUIRE_INFO)); $stateManager->removeState($object, 'stateField', self::STATE_REQUIRE_INFO); $this->assertFalse($stateManager->isInState($object->stateField, self::STATE_REQUIRE_ADDRESS)); $this->assertFalse($stateManager->isInState($object->stateField, self::STATE_REQUIRE_INFO)); $stateManager->addState($object, 'stateField', self::STATE_REQUIRE_ADDRESS | self::STATE_REQUIRE_INFO); $this->assertTrue($stateManager->isInState($object->stateField, self::STATE_REQUIRE_ADDRESS)); $this->assertTrue($stateManager->isInState($object->stateField, self::STATE_REQUIRE_INFO)); $stateManager->addState($object, 'stateField', self::STATE_REQUIRE_ADDRESS); $this->assertTrue($stateManager->isInState($object->stateField, self::STATE_REQUIRE_ADDRESS)); $this->assertTrue($stateManager->isInState($object->stateField, self::STATE_REQUIRE_INFO)); $stateManager->removeState($object, 'stateField', self::STATE_REQUIRE_ADDRESS); $stateManager->removeState($object, 'stateField', self::STATE_REQUIRE_ADDRESS); $this->assertFalse($stateManager->isInState($object->stateField, self::STATE_REQUIRE_ADDRESS)); $this->assertTrue($stateManager->isInState($object->stateField, self::STATE_REQUIRE_INFO)); }
/** * @param Address $address */ public function markAddressSynced(Address $address) { if (!$this->isAddressRemoved($address)) { $this->stateManager->removeState($address, 'syncState', Address::SYNC_TO_MAGENTO); } }