public function testGettersSetters() { $this->entity->setFirstName(self::TEST_STRING . 'first'); $this->entity->setLastName(self::TEST_STRING . 'last'); $this->assertNull($this->entity->getOrganization()); $this->entity->addAddress($this->getMock('OroCRM\\Bundle\\MagentoBundle\\Entity\\Address')); $this->entity->setOrganization($this->getMock('Oro\\Bundle\\OrganizationBundle\\Entity\\Organization')); $this->assertInstanceOf('Doctrine\\Common\\Collections\\Collection', $this->entity->getAddresses()); $this->assertInstanceOf('Oro\\Bundle\\OrganizationBundle\\Entity\\Organization', $this->entity->getOrganization()); $this->assertFalse($this->entity->getAddressByOriginId(1)); }
/** * @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()); }
/** * {@inheritdoc} */ public function load(ObjectManager $manager) { $addressTypeRepo = $manager->getRepository('OroAddressBundle:AddressType'); foreach (self::$data as $item) { $customer = new Customer(); $customer->setEmail($item['email']); $customer->setFirstName($item['firstName']); $customer->setLastName($item['lastName']); foreach ($item['addresses'] as $addressData) { $address = new Address(); $address->setPostalCode($addressData['postalCode']); $address->addType($addressTypeRepo->findOneBy(['name' => $addressData['type']])); $customer->addAddress($address); $manager->persist($address); } $manager->persist($customer); $manager->flush(); $this->setReference($item['reference'], $customer); } }
/** * @param $oid * @param Account $account * @param MagentoAddress $address * * @return Customer */ protected function createCustomer($oid, Account $account, MagentoAddress $address) { $customer = new Customer(); $customer->setChannel($this->integration); $customer->setDataChannel($this->channel); $customer->setFirstName('John'); $customer->setLastName('Doe'); $customer->setEmail('*****@*****.**'); $customer->setOriginId($oid); $customer->setIsActive(true); $customer->setWebsite($this->website); $customer->setStore($this->store); $customer->setAccount($account); $customer->setGender(Gender::MALE); $customer->setGroup($this->customerGroup); $customer->setCreatedAt(new \DateTime('now')); $customer->setUpdatedAt(new \DateTime('now')); $customer->addAddress($address); $customer->setOwner($this->getUser()); $customer->setOrganization($this->organization); $this->em->persist($customer); return $customer; }
/** * @param $oid * @param Account $account * @param MagentoAddress $address * * @return Customer */ protected function createCustomer($oid, Account $account, MagentoAddress $address) { $customer = new Customer(); $customer->setChannel($this->integration); $customer->setDataChannel($this->channel); $customer->setFirstName('John'); $customer->setLastName('Doe'); $customer->setEmail('*****@*****.**'); $customer->setOriginId($oid); $customer->setIsActive(true); $customer->setWebsite($this->website); $customer->setStore($this->store); $customer->setAccount($account); $customer->setGender(Gender::MALE); $customer->setGroup($this->customerGroup); // TODO: DateTimeZones should be removed in BAP-8710. Tests should be passed for: // - OroCRM\Bundle\MagentoBundle\Tests\Functional\Controller\Api\Rest\CustomerControllerTest // - OroCRM\Bundle\MagentoBundle\Tests\Functional\Controller\Api\Rest\MagentoCustomerControllerTest $customer->setCreatedAt(new \DateTime('now', new \DateTimezone('UTC'))); $customer->setUpdatedAt(new \DateTime('now', new \DateTimezone('UTC'))); $customer->addAddress($address); $customer->setOwner($this->getUser()); $customer->setOrganization($this->organization); $this->em->persist($customer); return $customer; }
/** * @dataProvider removeAddressDataProvider * * @param bool $remoteResult * @param bool $expectedRemove */ public function testRemoveAddress($remoteResult, $expectedRemove) { $transportSetting = $this->getMock('Oro\\Bundle\\IntegrationBundle\\Entity\\Transport'); $channel = new Channel(); $channel->setTransport($transportSetting); $customer = new Customer(); $customer->setChannel($channel); $address = new Address(); $address->setOriginId(self::TEST_ADDRESS_ID); $customer->addAddress($address); $this->transport->expects($this->once())->method('init'); $remoteResult = is_bool($remoteResult) ? $this->returnValue($remoteResult) : $this->throwException($remoteResult); $this->transport->expects($this->at(2))->method('getCustomerAddresses')->will($this->returnValue([])); $this->transport->expects($this->at(3))->method('call')->with($this->equalTo(SoapTransport::ACTION_CUSTOMER_ADDRESS_DELETE), $this->equalTo(['addressId' => self::TEST_ADDRESS_ID]))->will($remoteResult); $this->em->expects($this->exactly((int) $expectedRemove))->method('remove'); $this->em->expects($this->once())->method('flush'); $data = []; array_push($data, (object) ['entity' => $customer, 'object' => ['addresses' => [['entity' => $address, 'status' => AbstractReverseProcessor::DELETE_ENTITY]]]]); $this->writer->write($data); }