示例#1
0
 /**
  * @param string      $key
  * @param Opportunity $entity
  */
 public function fillEntityData($key, $entity)
 {
     $userRepo = $this->templateManager->getEntityRepository('Oro\\Bundle\\UserBundle\\Entity\\User');
     $customerRepo = $this->templateManager->getEntityRepository('OroCRM\\Bundle\\SalesBundle\\Entity\\B2bCustomer');
     $contactRepo = $this->templateManager->getEntityRepository('OroCRM\\Bundle\\ContactBundle\\Entity\\Contact');
     $leadRepo = $this->templateManager->getEntityRepository('OroCRM\\Bundle\\SalesBundle\\Entity\\Lead');
     $channelRepo = $this->templateManager->getEntityRepository('OroCRM\\Bundle\\ChannelBundle\\Entity\\Channel');
     $organizationRepo = $this->templateManager->getEntityRepository('Oro\\Bundle\\OrganizationBundle\\Entity\\Organization');
     switch ($key) {
         case 'Jerry Coleman':
             $entity->setName('Oro Inc. Opportunity Name');
             $entity->setCustomer($customerRepo->getEntity('Jerry Coleman'));
             $entity->setDataChannel($channelRepo->getEntity('B2b channel|b2b'));
             $entity->setCreatedAt(new \DateTime());
             $entity->setUpdatedAt(new \DateTime());
             $entity->setOwner($userRepo->getEntity('John Doo'));
             $entity->setOrganization($organizationRepo->getEntity('default'));
             $entity->setBudgetAmount(1000000);
             $entity->setContact($contactRepo->getEntity('Jerry Coleman'));
             $entity->setLead($leadRepo->getEntity('Jerry Coleman'));
             $entity->setStatus(new OpportunityStatus('In Progress'));
             return;
     }
     parent::fillEntityData($key, $entity);
 }
 /**
  * @depends testRemoveOpportunityFromB2bCustomer
  *
  * Test that no processing occured for b2bcustomers that were deleted
  * assert that onFlush event listeners not throwing exceptions
  */
 public function testRemovedB2bCustomer()
 {
     $em = $this->getEntityManager();
     $organization = $em->getRepository('OroOrganizationBundle:Organization')->getFirst();
     $opportunity = new Opportunity();
     $opportunity->setName('remove_b2bcustomer_test');
     $opportunity->setDataChannel($this->getReference('default_channel'));
     $opportunity->setCloseRevenue(50);
     $opportunity->setBudgetAmount(50.0);
     $opportunity->setProbability(10);
     $opportunity->setStatus($em->getReference('OroCRMSalesBundle:OpportunityStatus', 'won'));
     $opportunity->setOrganization($organization);
     $opportunity->setCustomer($this->getReference('default_b2bcustomer'));
     /** @var B2bCustomer $b2bCustomer */
     $b2bCustomer = $this->getReference('default_b2bcustomer');
     $b2bCustomer->addOpportunity($opportunity);
     $em->persist($opportunity);
     $em->flush();
     $em->remove($b2bCustomer);
     $em->flush();
 }