示例#1
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());
 }
示例#2
0
 /**
  * Remove opportunities from B2bCustomer
  *
  * @param B2bCustomer   $b2bCustomer
  * @param Opportunity[] $opportunities
  */
 protected function removeOpportunities(B2bCustomer $b2bCustomer, array $opportunities)
 {
     foreach ($opportunities as $opportunity) {
         $b2bCustomer->removeOpportunity($opportunity);
     }
 }