예제 #1
0
 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));
 }
예제 #2
0
 /**
  * {@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);
     }
 }
예제 #3
0
 /**
  * @param $firstName
  * @param $lastname
  */
 protected function createCustomer($firstName, $lastname)
 {
     $customer = new Customer();
     $customer->setChannel($this->getReference('integration'));
     $customer->setDataChannel($this->getReference('default_channel'));
     $customer->setFirstName($firstName);
     $customer->setLastName($lastname);
     $customer->setEmail(strtolower($firstName . '_' . $lastname . '@example.com'));
     $customer->setIsActive(true);
     $customer->setWebsite($this->getReference('website'));
     $customer->setStore($this->getReference('store'));
     $customer->setAccount($this->getReference('account'));
     $customer->setGender(Gender::MALE);
     $customer->setGroup($this->getReference('customer_group'));
     $customer->setCreatedAt(new \DateTime('now'));
     $customer->setUpdatedAt(new \DateTime('now'));
     $customer->setOwner($this->user);
     $customer->setOrganization($this->organization);
     $this->em->persist($customer);
 }
예제 #4
0
 /**
  * @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;
 }
예제 #5
0
 /**
  * @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;
 }
예제 #6
0
 public function testUpdateAddress()
 {
     $transportSetting = $this->getMock('Oro\\Bundle\\IntegrationBundle\\Entity\\Transport');
     $channel = new Channel();
     $channel->setTransport($transportSetting);
     $channel->getSynchronizationSettingsReference()->offsetSet('syncPriority', TwoWaySyncConnectorInterface::LOCAL_WINS);
     $customer = new Customer();
     $customer->setOriginId(self::TEST_CUSTOMER_ID);
     $customer->setChannel($channel);
     $customer->setFirstName(self::TEST_CUSTOMER_FIRSTNAME);
     $customer->setLastName(self::TEST_CUSTOMER_LASTNAME);
     $contactAddress = new ContactAddress();
     $address = new Address();
     $address->setFirstName(self::TEST_FIRSTNAME);
     $address->setCountry(new Country(self::TEST_ADDRESS_COUNTRY));
     $address->setRegionText(self::TEST_ADDRESS_REGION);
     $address->setStreet(self::TEST_ADDRESS_STREET);
     $address->setContactAddress($contactAddress);
     $address->setOriginId(1);
     $this->transport->expects($this->once())->method('init');
     $this->regionConverter->expects($this->once())->method('toMagentoData')->with($this->identicalTo($address))->will($this->returnValue(['region' => self::TEST_ADDRESS_REGION_RESOLVED, 'region_id' => null]));
     $this->transport->expects($this->at(2))->method('getCustomerAddresses')->with($this->identicalTo($customer))->will($this->returnValue([(object) ['customer_address_id' => 1, 'telephone' => '911', 'middlename' => 'testMiddleName', 'suffix' => 'testSuffix', 'company' => 'testCompany', 'city' => 'testCity', 'is_default_shipping' => false, 'is_default_billing' => false]]));
     $this->transport->expects($this->at(3))->method('call')->with($this->equalTo(SoapTransport::ACTION_CUSTOMER_ADDRESS_UPDATE), $this->equalTo(['addressId' => 1, 'addressData' => ['prefix' => null, 'firstname' => 'newName', 'middlename' => null, 'lastname' => 'newLastName', 'suffix' => null, 'company' => null, 'street' => [0 => self::TEST_ADDRESS_STREET, 1 => null], 'city' => null, 'postcode' => null, 'country_id' => self::TEST_ADDRESS_COUNTRY, 'region' => self::TEST_ADDRESS_REGION_RESOLVED, 'region_id' => null, 'created_at' => null, 'updated_at' => null, 'is_default_billing' => false, 'is_default_shipping' => false, 'telephone' => 'no phone']]))->will($this->returnValue(true));
     $this->em->expects($this->atLeastOnce())->method('persist');
     $this->em->expects($this->once())->method('flush');
     $data = [];
     array_push($data, (object) ['entity' => $customer, 'object' => ['addresses' => [['entity' => $address, 'status' => AbstractReverseProcessor::UPDATE_ENTITY, 'object' => ['firstname' => 'newName', 'lastname' => 'newLastName']]]]]);
     $this->writer->write($data);
 }