Exemplo n.º 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));
 }
Exemplo n.º 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();
 }