/** * @param string $key * @param B2bCustomer $entity */ public function fillEntityData($key, $entity) { $addressRepo = $this->templateManager->getEntityRepository('Oro\\Bundle\\AddressBundle\\Entity\\Address'); $userRepo = $this->templateManager->getEntityRepository('Oro\\Bundle\\UserBundle\\Entity\\User'); $contactRepo = $this->templateManager->getEntityRepository('OroCRM\\Bundle\\ContactBundle\\Entity\\Contact'); $leadRepo = $this->templateManager->getEntityRepository('OroCRM\\Bundle\\SalesBundle\\Entity\\Lead'); $accountRepo = $this->templateManager->getEntityRepository('OroCRM\\Bundle\\AccountBundle\\Entity\\Account'); $channelRepo = $this->templateManager->getEntityRepository('OroCRM\\Bundle\\ChannelBundle\\Entity\\Channel'); $opportunityRepo = $this->templateManager->getEntityRepository('OroCRM\\Bundle\\SalesBundle\\Entity\\Opportunity'); switch ($key) { case 'Jerry Coleman': $entity->setName('Jerry Coleman'); $entity->addLead($leadRepo->getEntity('Jerry Coleman')); $entity->setContact($contactRepo->getEntity('Jerry Coleman')); $entity->setAccount($accountRepo->getEntity('Coleman')); $entity->setOwner($userRepo->getEntity('John Doo')); $entity->setBillingAddress($addressRepo->getEntity('Jerry Coleman')); $entity->setShippingAddress($addressRepo->getEntity('Jerry Coleman')); $entity->setDataChannel($channelRepo->getEntity('B2B channel|b2b')); $entity->setCreatedAt(new \DateTime()); $entity->setUpdatedAt(new \DateTime()); $entity->addOpportunity($opportunityRepo->getEntity('Jerry Coleman')); return; } parent::fillEntityData($key, $entity); }
protected function createB2bCustomer() { $customer = new B2bCustomer(); $customer->setAccount($this->getReference('default_account')); $customer->setName(self::CUSTOMER_NAME); $customer->setDataChannel($this->getReference('default_channel')); $customer->setOrganization($this->organization); $this->em->persist($customer); $this->em->flush(); $this->setReference('default_b2bcustomer', $customer); return $this; }
/** * @depends testChangeStatusAffectsLifetime * * @param Opportunity $opportunity * * @return Opportunity */ public function testCustomerChangeShouldUpdateBothCustomersIfValuable(Opportunity $opportunity) { $em = $this->getEntityManager(); $b2bCustomer = $opportunity->getCustomer(); $this->assertEquals(100, $b2bCustomer->getLifetime()); $newCustomer = new B2bCustomer(); $newCustomer->setName(uniqid('name')); $newCustomer->setDataChannel($opportunity->getDataChannel()); $em->persist($newCustomer); $em->flush(); $this->assertEquals(0, $newCustomer->getLifetime()); $opportunity->setCustomer($newCustomer); $em->persist($opportunity); $em->flush(); $em->refresh($b2bCustomer); $em->refresh($newCustomer); $this->assertEquals(0, $b2bCustomer->getLifetime()); $this->assertEquals(100, $newCustomer->getLifetime()); return $opportunity; }
/** * @param Organization $organization * @param array $data * @param Channel $channel * * @return B2bCustomer */ protected function createCustomer(Organization $organization, $data, Channel $channel = null) { $address = new Address(); $customer = new B2bCustomer(); $customer->setName($data['Company']); $customer->setOwner($this->getRandomUserReference()); $customer->setAccount($this->getAccount()); $customer->setOrganization($organization); $address->setCity($data['City']); $address->setStreet($data['StreetAddress']); $address->setPostalCode($data['ZipCode']); $address->setFirstName($data['GivenName']); $address->setLastName($data['Surname']); $address->setCountry($this->getCountryReference($data['Country'])); $address->setRegion($this->getRegionReference($data['Country'], $data['State'])); $customer->setShippingAddress($address); $customer->setBillingAddress(clone $address); if ($channel) { $customer->setDataChannel($channel); } return $customer; }