Exemplo n.º 1
0
 /**
  * @Given /^There are published representative news$/
  */
 public function thereArePublishedLeaderNews(TableNode $table)
 {
     /* @var $em EntityManager */
     $em = $this->getEm();
     /* @var $activityService \Civix\CoreBundle\Service\ActivityUpdate */
     $activityService = $this->getMainContext()->getContainer()->get('civix_core.activity_update');
     $hash = $table->getHash();
     $diffSec = 0;
     foreach ($hash as $row) {
         $diffSec++;
         $news = new RepresentativeNews();
         $news->setUser($em->getRepository(Representative::class)->findOneByUsername($row['username']));
         $news->setSubject($row['subject']);
         $news->setPublishedAt(new \DateTime());
         $em->persist($news);
         $em->flush($news);
         $activity = $activityService->publishLeaderNewsToActivity($news);
         $activity->getSentAt()->sub(new \DateInterval('PT' . (count($hash) - $diffSec) . 'S'));
         $activity->setSentAt(clone $activity->getSentAt());
         if (!empty($row['expired_interval_direction'])) {
             $expired = new \DateTime();
             $expired->{$row}['expired_interval_direction'](new \DateInterval($row['expired_interval_value']));
             $activity->setExpireAt($expired);
             $em->flush($activity);
         }
     }
     $result = $em->getRepository(LeaderNewsActivity::class)->findAll();
     Assert::assertTrue(count($result) >= count($hash));
 }
 public function load(ObjectManager $manager)
 {
     $representative = $this->getReference('representative1');
     $news = new RepresentativeNews();
     $news->setUser($representative);
     $news->setSubject('test');
     $this->addReference('representativeNews1', $news);
     $manager->persist($news);
     //published
     $newsPublished = new RepresentativeNews();
     $newsPublished->setUser($representative);
     $newsPublished->setSubject('testPublish');
     $newsPublished->setPublishedAt(new \DateTime());
     $this->addReference('representativeNewsPublished1', $newsPublished);
     $manager->persist($newsPublished);
     $manager->flush();
 }
 public function getGroupSectionIds()
 {
     $this->__load();
     return parent::getGroupSectionIds();
 }