Exemple #1
0
 /**
  * @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);
 }
Exemple #2
0
 public function testOpportunitiesInteraction()
 {
     $result = $this->entity->getOpportunities();
     $this->assertInstanceOf('Doctrine\\Common\\Collections\\ArrayCollection', $result);
     $this->assertCount(0, $result);
     $opportunity = $this->getMock('OroCRM\\Bundle\\SalesBundle\\Entity\\Opportunity');
     $this->entity->addOpportunity($opportunity);
     $this->assertCount(1, $this->entity->getOpportunities());
     $this->assertTrue($this->entity->getOpportunities()->contains($opportunity));
     $this->entity->removeOpportunity($opportunity);
     $result = $this->entity->getLeads();
     $this->assertCount(0, $result);
     $newCollection = new ArrayCollection();
     $this->entity->setOpportunities($newCollection);
     $this->assertNotSame($result, $this->entity->getOpportunities());
     $this->assertSame($newCollection, $this->entity->getOpportunities());
 }
Exemple #3
0
 /**
  * Append opportunities to B2bCustomer
  *
  * @param B2bCustomer   $b2bCustomer
  * @param Opportunity[] $opportunities
  */
 protected function appendOpportunities(B2bCustomer $b2bCustomer, array $opportunities)
 {
     foreach ($opportunities as $opportunity) {
         $b2bCustomer->addOpportunity($opportunity);
     }
 }