Beispiel #1
0
 public function testValidationPassesIfEnabledIsNull()
 {
     $entity = new Contact();
     $entity->setEnabled(null);
     $entity->translate('en')->setName('Test');
     $entity->translate('en')->setEmail('*****@*****.**');
     $entity->mergeNewTranslations();
     $errors = $this->validator->validate($entity);
     $this->assertEquals(0, count($errors));
     $this->assertFalse($entity->getEnabled());
 }
 /**
  * {@inheritDoc}
  */
 public function load(ObjectManager $manager)
 {
     if (!$this->isEnabled()) {
         return;
     }
     $contact = new Contact();
     $contact->setEnabled(1);
     $contact->translate('en')->setName('Sales department');
     $contact->translate('en')->setEmail('*****@*****.**');
     $contact->translate('en')->setPhone('555 123-345-678');
     $contact->translate('en')->setBusinessHours($this->getBusinessHours());
     $contact->mergeNewTranslations();
     $manager->persist($contact);
     $manager->flush();
     $this->setReference('contact', $contact);
 }
 public function create() : ContactInterface
 {
     $contact = new Contact();
     $contact->setEnabled(true);
     $contact->setCreatedAt(new \DateTime());
     /** @var ContactTranslation $translation */
     $translation = $contact->translate();
     $translation->setName('');
     $translation->setEmail('');
     $translation->setBusinessHours('');
     $translation->setCity('');
     $translation->setCountry('');
     $translation->setLine1('');
     $translation->setLine2('');
     $translation->setPostalCode('');
     $translation->setState('');
     $translation->setPhone('');
     return $contact;
 }
 /**
  * {@inheritDoc}
  */
 public function load(ObjectManager $manager)
 {
     if (!$this->isEnabled()) {
         return;
     }
     $contact = new Contact();
     $contact->setEnabled(1);
     /** @var ContactTranslation $translation */
     $translation = $contact->translate();
     $translation->setName('Sales department');
     $translation->setEmail('*****@*****.**');
     $translation->setBusinessHours($this->getBusinessHours());
     $translation->setCity('');
     $translation->setCountry('');
     $translation->setLine1('');
     $translation->setLine2('');
     $translation->setPostalCode('');
     $translation->setState('');
     $translation->setPhone('555 123-345-678');
     $contact->mergeNewTranslations();
     $manager->persist($contact);
     $manager->flush();
     $this->setReference('contact', $contact);
 }