Пример #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
 /**
  * "Success" form handler
  *
  * @param Customer $entity
  */
 protected function onSuccess(Customer $entity)
 {
     if (null === $entity->getOrganization()) {
         $entity->setOrganization($this->organization);
     }
     $addresses = $entity->getAddresses();
     foreach ($addresses as $address) {
         if (null === $address->getOrganization()) {
             $address->setOrganization($this->organization);
         }
     }
     $this->manager->persist($entity);
     $this->manager->flush();
 }
Пример #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;
 }