Esempio n. 1
0
 public function testWarmUpAndIsOptional()
 {
     $oroProvider = $this->getMock('Oro\\Bundle\\EmailBundle\\Entity\\Provider\\EmailOwnerProviderInterface');
     $oroProvider->expects($this->any())->method('getEmailOwnerClass')->will($this->returnValue('Oro\\TestUser'));
     $oroCrmProvider = $this->getMock('Oro\\Bundle\\EmailBundle\\Entity\\Provider\\EmailOwnerProviderInterface');
     $oroCrmProvider->expects($this->any())->method('getEmailOwnerClass')->will($this->returnValue('OroCRM\\TestContact'));
     $acmeProvider = $this->getMock('Oro\\Bundle\\EmailBundle\\Entity\\Provider\\EmailOwnerProviderInterface');
     $acmeProvider->expects($this->any())->method('getEmailOwnerClass')->will($this->returnValue('Acme\\TestUser'));
     $storage = new EmailOwnerProviderStorage();
     $storage->addProvider($oroProvider);
     $storage->addProvider($oroCrmProvider);
     $storage->addProvider($acmeProvider);
     $kernel = $this->getMock('Symfony\\Component\\HttpKernel\\KernelInterface');
     $warmer = $this->getMockBuilder('Oro\\Bundle\\EmailBundle\\Cache\\EntityCacheWarmer')->setConstructorArgs(array($storage, 'SomeDir', 'Test\\SomeNamespace', 'Test%sProxy', $kernel))->setMethods(array('createFilesystem', 'createTwigEnvironment', 'writeCacheFile'))->getMock();
     $fs = $this->getMockBuilder('Symfony\\Component\\Filesystem\\Filesystem')->disableOriginalConstructor()->getMock();
     $twig = $this->getMockBuilder('\\Twig_Environment')->disableOriginalConstructor()->getMock();
     $warmer->expects($this->once())->method('createFilesystem')->will($this->returnValue($fs));
     $warmer->expects($this->once())->method('createTwigEnvironment')->will($this->returnValue($twig));
     $fs->expects($this->once())->method('exists')->with($this->equalTo('SomeDir'));
     $fs->expects($this->once())->method('mkdir')->with($this->equalTo('SomeDir'), $this->equalTo(0777));
     $this->setTwigAndSaveExpectations($twig, $warmer, '.php', 0);
     $this->setTwigAndSaveExpectations($twig, $warmer, '.orm.yml', 1);
     $warmer->warmup('');
     $this->assertFalse($warmer->isOptional());
 }
 public function testStorage()
 {
     $provider1 = $this->getMock('Oro\\Bundle\\EmailBundle\\Entity\\Provider\\EmailOwnerProviderInterface');
     $provider2 = $this->getMock('Oro\\Bundle\\EmailBundle\\Entity\\Provider\\EmailOwnerProviderInterface');
     $storage = new EmailOwnerProviderStorage();
     $storage->addProvider($provider1);
     $storage->addProvider($provider2);
     $result = $storage->getProviders();
     $this->assertCount(2, $result);
     $this->assertTrue($provider1 === $result[0]);
     $this->assertTrue($provider2 === $result[1]);
 }
Esempio n. 3
0
 protected function setUp()
 {
     $this->emailOwnerManager = $this->getMockBuilder('Oro\\Bundle\\EmailBundle\\Entity\\Manager\\EmailOwnerManager')->disableOriginalConstructor()->getMock();
     $this->emailActivityManager = $this->getMockBuilder('Oro\\Bundle\\EmailBundle\\Entity\\Manager\\EmailActivityManager')->disableOriginalConstructor()->getMock();
     $this->emailThreadManager = $this->getMockBuilder('Oro\\Bundle\\EmailBundle\\Entity\\Manager\\EmailThreadManager')->disableOriginalConstructor()->getMock();
     $this->registry = $this->getMockBuilder('Doctrine\\Bundle\\DoctrineBundle\\Registry')->setMethods(['getRepository', 'getEmailsByOwnerEntity'])->disableOriginalConstructor()->getMock();
     $this->userEmailOwnerProvider = $this->getMockBuilder('Oro\\Bundle\\UserBundle\\Entity\\Provider\\EmailOwnerProvider')->disableOriginalConstructor()->getMock();
     $this->chainProvider = $this->getMockBuilder('Oro\\Bundle\\ActivityListBundle\\Provider\\ActivityListChainProvider')->disableOriginalConstructor()->getMock();
     $this->emailOwnerStorage = new EmailOwnerProviderStorage();
     $this->emailOwnerStorage->addProvider($this->userEmailOwnerProvider);
     $this->emailOwnersProvider = $this->getMockBuilder('Oro\\Bundle\\EmailBundle\\Provider\\EmailOwnersProvider')->setConstructorArgs([$this->chainProvider, $this->emailOwnerStorage, $this->registry])->setMethods(['supportOwnerProvider'])->getMock();
     $this->listener = new EntityListener($this->emailOwnerManager, $this->emailActivityManager, $this->emailThreadManager, $this->emailOwnersProvider);
 }
 public function testPrepareQueryOneProviderGiven()
 {
     $provider = $this->getMock('Oro\\Bundle\\EmailBundle\\Entity\\Provider\\EmailOwnerProviderInterface');
     $provider->expects($this->any())->method('getEmailOwnerClass')->will($this->returnValue(self::TEST_ENTITY));
     $this->registry->addProvider($provider);
     $this->formatter->expects($this->once())->method('getFormattedNameDQL')->with($this->equalTo('owner1'), $this->equalTo(self::TEST_ENTITY))->will($this->returnValue(self::TEST_NAME_DQL_FORMATTED));
     $em = $this->getTestEntityManager();
     $qb = $em->createQueryBuilder();
     $qb->select('e')->from('OroEmailBundle:Email', 'e')->leftJoin('e.fromEmailAddress', self::JOIN_ALIAS);
     $this->factory->prepareQuery($qb);
     // @codingStandardsIgnoreStart
     $this->assertEquals("SELECT e, " . "CONCAT('', CASE WHEN a.hasOwner = true THEN (" . "CASE WHEN a.owner1 IS NOT NULL THEN CONCAT(a.firstName, CONCAT(a.lastName, '')) ELSE '' END" . ") ELSE a.email END) as fromEmailExpression " . "FROM OroEmailBundle:Email e LEFT JOIN e.fromEmailAddress a LEFT JOIN a.owner1 owner1", $qb->getDQL());
     // @codingStandardsIgnoreEnd
 }
Esempio n. 5
0
 private function getEmailOwnerProviderStorage()
 {
     $provider1 = $this->getMock('Oro\\Bundle\\EmailBundle\\Entity\\Provider\\EmailOwnerProviderInterface');
     $provider1->expects($this->any())->method('getEmailOwnerClass')->will($this->returnValue('Oro\\Bundle\\EmailBundle\\Tests\\Unit\\Entity\\TestFixtures\\TestEmailOwner'));
     $provider2 = $this->getMock('Oro\\Bundle\\EmailBundle\\Entity\\Provider\\EmailOwnerProviderInterface');
     $provider2->expects($this->any())->method('getEmailOwnerClass')->will($this->returnValue('Oro\\Bundle\\EmailBundle\\Tests\\Unit\\Entity\\TestFixtures\\TestEmailOwnerWithoutEmail'));
     $storage = new EmailOwnerProviderStorage();
     $storage->addProvider($provider1);
     $storage->addProvider($provider2);
     return $storage;
 }