Exemplo n.º 1
0
 public function testSetEmailSeenChangesDefs()
 {
     $emailUser = $this->getMock('Oro\\Bundle\\EmailBundle\\Entity\\EmailUser');
     $emailUser->expects($this->once())->method('isSeen')->will($this->returnValue(false));
     $emailUser->expects($this->once())->method('setSeen')->with(true);
     $this->em->expects($this->never())->method('flush');
     $this->manager->setEmailUserSeen($emailUser);
 }
Exemplo n.º 2
0
 /**
  * @param array $options
  */
 protected function handleThreadEmails($options)
 {
     $iteration = 0;
     $markType = $options['mark_type'];
     if (!$this->needToProcessThreadIds) {
         return;
     }
     $queryBuilder = $this->entityManager->getRepository('OroEmailBundle:EmailUser')->getEmailUserByThreadId($this->needToProcessThreadIds, $this->user);
     $result = $queryBuilder->getQuery()->iterate();
     foreach ($result as $entity) {
         $entity = $entity[0];
         if ($this->securityFacade->isGranted('EDIT', $entity)) {
             $this->emailManager->setEmailUserSeen($entity, $markType === self::MARK_READ);
         }
         $this->entityManager->persist($entity);
         if ($iteration % self::FLUSH_BATCH_SIZE === 0) {
             $this->entityManager->flush();
             $this->entityManager->clear();
         }
         $iteration++;
     }
     $this->entityManager->flush();
 }