public function testSyncOrigins()
 {
     $container = $this->getMock('Symfony\\Component\\DependencyInjection\\ContainerInterface');
     $sync1 = $this->getMockForAbstractClass('Oro\\Bundle\\EmailBundle\\Sync\\AbstractEmailSynchronizer', [], '', false, true, true, ['supports', 'syncOrigins']);
     $sync2 = $this->getMockForAbstractClass('Oro\\Bundle\\EmailBundle\\Sync\\AbstractEmailSynchronizer', [], '', false, true, true, ['supports', 'syncOrigins']);
     $origin1 = new InternalEmailOrigin();
     $origin1->setName('origin1');
     ReflectionUtil::setId($origin1, 1);
     $origin2 = new InternalEmailOrigin();
     $origin2->setName('origin2');
     ReflectionUtil::setId($origin2, 2);
     $origin3 = new InternalEmailOrigin();
     $origin3->setName('origin3');
     ReflectionUtil::setId($origin3, 3);
     $sync1->expects($this->at(0))->method('supports')->with($origin1)->will($this->returnValue(false));
     $sync1->expects($this->at(1))->method('supports')->with($origin2)->will($this->returnValue(true));
     $sync1->expects($this->at(2))->method('supports')->with($origin3)->will($this->returnValue(false));
     $sync1->expects($this->at(3))->method('syncOrigins')->with([2]);
     $sync2->expects($this->at(0))->method('supports')->with($origin1)->will($this->returnValue(false));
     $sync2->expects($this->at(1))->method('supports')->with($origin2)->will($this->returnValue(false));
     $sync2->expects($this->at(2))->method('supports')->with($origin3)->will($this->returnValue(true));
     $sync2->expects($this->at(3))->method('syncOrigins')->with([3]);
     $container->expects($this->any())->method('get')->will($this->returnValueMap([['sync1', ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE, $sync1], ['sync2', ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE, $sync2]]));
     $manager = new EmailSynchronizationManager($container);
     $manager->addSynchronizer('sync1');
     $manager->addSynchronizer('sync2');
     $manager->syncOrigins([$origin1, $origin2, $origin3]);
 }
 public function testIdGetter()
 {
     $entity = new EmailAttachmentContent();
     ReflectionUtil::setId($entity, 1);
     $this->assertEquals(1, $entity->getId());
 }
Example #3
0
 public function testGetId()
 {
     $imapEmail = new ImapEmail();
     ReflectionUtil::setId($imapEmail, 123);
     $this->assertEquals(123, $imapEmail->getId());
 }
 public function testIdGetter()
 {
     $entity = new TestEmailOrigin();
     ReflectionUtil::setId($entity, 1);
     $this->assertEquals(1, $entity->getId());
 }
 public function testGetId()
 {
     $imapFolder = new ImapEmailFolder();
     ReflectionUtil::setId($imapFolder, 123);
     $this->assertEquals(123, $imapFolder->getId());
 }
 /**
  * @expectedException \Oro\Bundle\EmailBundle\Exception\EmailBodyNotFoundException
  * @expectedExceptionMessage Cannot find a body for "test email" email.
  */
 public function testSyncOneEmailBodyNotFound()
 {
     $email = new Email();
     ReflectionUtil::setId($email, 123);
     $email->setSubject('test email');
     $emailBody = new EmailBody();
     $emailUser = new EmailUser();
     $origin = new TestEmailOrigin();
     $folder = new EmailFolder();
     $folder->setOrigin($origin);
     $emailUser->setOrigin($origin);
     $emailUser->addFolder($folder);
     $email->addEmailUser($emailUser);
     $exception = new EmailBodyNotFoundException($email);
     $loader = $this->getMock('Oro\\Bundle\\EmailBundle\\Provider\\EmailBodyLoaderInterface');
     $this->selector->expects($this->once())->method('select')->with($this->identicalTo($origin))->will($this->returnValue($loader));
     $loader->expects($this->once())->method('loadEmailBody')->will($this->throwException($exception));
     $this->em->expects($this->never())->method('persist');
     $this->em->expects($this->never())->method('flush');
     $this->logger->expects($this->once())->method('notice')->with('Load email body failed. Email id: 123. Error: Cannot find a body for "test email" email.', ['exception' => $exception]);
     $this->logger->expects($this->never())->method('warning');
     $this->synchronizer->syncOneEmailBody($email);
     $this->assertSame($emailBody, $email->getEmailBody());
 }
Example #7
0
 public function testGetId()
 {
     $origin = new UserEmailOrigin();
     ReflectionUtil::setId($origin, 123);
     $this->assertEquals(123, $origin->getId());
 }
 /**
  * @param string   $folderName
  * @param string   $folderFullName
  * @param int      $uidValidity
  * @param int|null $id
  *
  * @return ImapEmailFolder
  */
 protected function createImapFolder($folderName, $folderFullName, $uidValidity, $id = null)
 {
     $folder = new EmailFolder();
     $folder->setName($folderName)->setFullName($folderFullName);
     $imapFolder = new ImapEmailFolder();
     $imapFolder->setFolder($folder)->setUidValidity($uidValidity);
     if ($id !== null) {
         ReflectionUtil::setId($imapFolder, $id);
     }
     return $imapFolder;
 }