Example #1
0
 /**
  * {@inheritdoc}
  */
 public function load(ObjectManager $manager)
 {
     $website = new TrackingWebsite();
     $website->setName('website1')->setIdentifier(1)->setUrl('http://localhost');
     $manager->persist($website);
     $campaignCodes = ['cmp1', 'cmp2', 'cmp3'];
     foreach ($campaignCodes as $code) {
         foreach ($this->data as $data) {
             $entity = new TrackingEvent();
             $entity->setWebsite($website)->setCode($code);
             $data['loggedAt'] = new \DateTime($data['loggedAt'], new \DateTimeZone('UTC'));
             $excludeProperties = ['reference'];
             $propertyAccessor = PropertyAccess::createPropertyAccessor();
             foreach ($data as $property => $value) {
                 if (in_array($property, $excludeProperties)) {
                     continue;
                 }
                 $propertyAccessor->setValue($entity, $property, $value);
             }
             $this->setReference($code . $data['reference'], $entity);
             $manager->persist($entity);
         }
     }
     $manager->flush();
 }
 /**
  * @param ObjectManager $manager
  */
 public function load(ObjectManager $manager)
 {
     $owner = $manager->getRepository('OroUserBundle:User')->findOneBy(['username' => 'admin']);
     if (!$owner) {
         return;
     }
     $website = new TrackingWebsite();
     $website->setName('delete')->setIdentifier('delete')->setUrl('http://domain.com')->setOwner($owner);
     $manager->persist($website);
     $manager->flush();
     $this->setReference('website', $website);
 }
Example #3
0
 public function testPreUpdate()
 {
     $this->assertNull($this->website->getUpdatedAt());
     $this->website->preUpdate();
     $this->assertInstanceOf('\\DateTime', $this->website->getUpdatedAt());
 }