/** * @dataProvider addressTypesUpdateDataProvider * * @param string $priority * @param ArrayCollection $remoteTypes * @param ArrayCollection $localTypes * @param ArrayCollection $contactTypes * @param array $expectedTypeNames */ public function testAddressTypesUpdate($priority, ArrayCollection $remoteTypes, ArrayCollection $localTypes, ArrayCollection $contactTypes, array $expectedTypeNames) { $channel = new Channel(); $channel->getSynchronizationSettingsReference()->offsetSet('syncPriority', $priority); $testCountry = new Country('US'); $contact = new Contact(); $contactAddress = new ContactAddress(); $contactAddress->setId(self::TEST_CONTACT_ADDRESS_ID); $contactAddress->setTypes($contactTypes); $contactAddress->setCountry($testCountry); $contact->addAddress($contactAddress); $phone = new ContactPhone(); $phone->setPhone('123-123-123'); $phone->setOwner($contact); $contact->addPhone($phone); $localCustomer = new Customer(); $localAddress = new Address(); $localAddress->setContactAddress($contactAddress); $localAddress->setTypes($localTypes); $localAddress->setCountry($testCountry); $localAddress->setPhone('123-123-123'); $localAddress->setContactPhone($phone); $localCustomer->addAddress($localAddress); $remoteCustomer = new Customer(); $remoteAddress = new Address(); $remoteAddress->setContactAddress($contactAddress); $remoteAddress->setTypes($remoteTypes); $remoteAddress->setCountry($testCountry); $remoteAddress->setContactPhone($phone); $remoteCustomer->addAddress($remoteAddress); $helper = $this->getHelper($channel); $helper->merge($remoteCustomer, $localCustomer, $contact); $this->assertCount(1, $contact->getAddresses()); $this->assertEquals($expectedTypeNames, $contactAddress->getTypeNames()); }
public function testGetPhoneNumbers() { $entity = new Address(); $contact = $this->getMockBuilder('OroCRM\\Bundle\\ContactBundle\\Entity\\Contact')->disableOriginalConstructor()->getMock(); $this->assertSame([], $this->provider->getPhoneNumbers($entity)); $contactPhone = new ContactPhone('123-123'); $contactPhone->setOwner($contact); $entity->setContactPhone($contactPhone); $this->assertSame([['123-123', $contact]], $this->provider->getPhoneNumbers($entity)); $entity->setPhone('456-456'); $this->assertSame([['456-456', $entity], ['123-123', $contact]], $this->provider->getPhoneNumbers($entity)); }
/** * {@inheritdoc} */ public function load(ObjectManager $manager) { $contact = $this->getReference('Contact_' . LoadContactEntitiesData::FIRST_ENTITY_NAME); foreach ($this->contactEmailData as $contactEmailData) { $contactPhone = new ContactPhone(); $contactPhone->setPrimary($contactEmailData['primary']); $contactPhone->setOwner($contact); $contactPhone->setPhone($contactEmailData['phone']); $this->setReference('ContactPhone_Several_' . $contactEmailData['phone'], $contactPhone); $manager->persist($contactPhone); } $contact2 = $this->getReference('Contact_' . LoadContactEntitiesData::SECOND_ENTITY_NAME); $contactPhone = new ContactPhone(); $contactPhone->setPrimary($this->contactEmailData[0]['primary']); $contactPhone->setOwner($contact2); $contactPhone->setPhone($this->contactEmailData[0]['phone']); $this->setReference('ContactPhone_Single_' . $this->contactEmailData[0]['phone'], $contactPhone); $manager->persist($contactPhone); $manager->flush(); }
/** * @param ContactPhone $entity * @param Contact $contact */ protected function onSuccess(ContactPhone $entity, Contact $contact) { $entity->setOwner($contact); $this->manager->persist($entity); $this->manager->flush(); }
public function dataTest() { $testContact = new ExtendContact(); $testContactAddress = new ContactAddress(); $testContactEmail = new ContactEmail(); $testContactPhone = new ContactPhone(); $testContactAddress->setOwner($testContact); $testContactEmail->setOwner($testContact); $testContactPhone->setOwner($testContact); $testMagentoCustomer = new ExtendCustomer(); $channel = new Channel(); $channel->getSynchronizationSettingsReference()->offsetSet('isTwoWaySyncEnabled', true); $channel->setName('test'); $channel->setEnabled(true); $testMagentoCustomer->setChannel($channel); return ['Updated contact' => [$testContact, $testMagentoCustomer, $channel, [], [$testContact], [], true, true, true, true, true], 'Inserted contact' => [$testContact, $testMagentoCustomer, $channel, [$testContact], [], [], true, false, false, true, false], 'Deleted contact' => [$testContact, $testMagentoCustomer, $channel, [], [], [$testContact], true, true, true, false, true], 'Updated contact with testContactAddress' => [$testContact, $testMagentoCustomer, $channel, [], [$testContact, $testContactAddress], [], true, true, true, true, true], 'Test process Contact Address' => [$testContact, $testMagentoCustomer, $channel, [], [$testContactAddress], [], true, true, true, false, true], 'Test deleted Contact Address' => [$testContact, $testMagentoCustomer, $channel, [], [], [$testContactAddress], true, true, true, false, true]]; }