本文整理汇总了PHP中Oro\Bundle\EmailBundle\Entity\Email::addEmailUser方法的典型用法代码示例。如果您正苦于以下问题:PHP Email::addEmailUser方法的具体用法?PHP Email::addEmailUser怎么用?PHP Email::addEmailUser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Oro\Bundle\EmailBundle\Entity\Email
的用法示例。
在下文中一共展示了Email::addEmailUser方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testVote
/**
* @param boolean $atLeastOneGranted
* @dataProvider voteProvider
*/
public function testVote($atLeastOneGranted)
{
$token = $this->getMock('Symfony\\Component\\Security\\Core\\Authentication\\Token\\TokenInterface');
$email = new Email();
$emailUser1 = new EmailUser();
$emailUser2 = new EmailUser();
$emailUser3 = new EmailUser();
$email->addEmailUser($emailUser1);
$email->addEmailUser($emailUser2);
$email->addEmailUser($emailUser3);
$attributes = ['VIEW'];
if ($atLeastOneGranted) {
$this->securityFacade->expects($this->once())->method('isGranted')->with('VIEW', ${'emailUser' . mt_rand(1, 3)})->willReturn(true);
}
$result = $atLeastOneGranted ? EmailVoter::ACCESS_GRANTED : EmailVoter::ACCESS_DENIED;
$this->assertEquals($result, $this->emailVoter->vote($token, $email, $attributes));
}
示例2: testEnsureEmailBodyCached
public function testEnsureEmailBodyCached()
{
$email = new Email();
$emailBody = new EmailBody();
$emailUser = new EmailUser();
$origin = new TestEmailOrigin();
$folder = new EmailFolder();
$folder->setOrigin($origin);
$emailUser->setFolder($folder);
$email->addEmailUser($emailUser);
$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')->with($this->identicalTo($folder), $this->identicalTo($email), $this->identicalTo($this->em))->will($this->returnValue($emailBody));
$this->em->expects($this->once())->method('persist')->with($this->identicalTo($email));
$this->em->expects($this->once())->method('flush');
$this->logger->expects($this->never())->method('notice');
$this->logger->expects($this->never())->method('warning');
$this->manager->ensureEmailBodyCached($email);
$this->assertSame($emailBody, $email->getEmailBody());
}
示例3: testSync
public function testSync()
{
$email = new Email();
$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);
$repo = $this->getMockBuilder('Oro\\Bundle\\EmailBundle\\Entity\\Repository\\EmailRepository')->disableOriginalConstructor()->getMock();
$this->doctrine->expects($this->once())->method('getRepository')->willReturn($repo);
$runCount = 0;
$repo->expects($this->exactly(2))->method('getEmailsWithoutBody')->willReturnCallback(function () use(&$runCount, $email) {
$runCount++;
return $runCount === 1 ? [$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')->with($this->identicalTo($folder), $this->identicalTo($email), $this->identicalTo($this->em))->will($this->returnValue($emailBody));
$this->em->expects($this->once())->method('persist')->with($this->identicalTo($email));
$this->em->expects($this->once())->method('flush');
$this->em->expects($this->once())->method('clear');
$this->logger->expects($this->exactly(2))->method('notice');
$this->logger->expects($this->never())->method('warning');
$this->synchronizer->sync();
$this->assertSame($emailBody, $email->getEmailBody());
}
示例4: testPersist
/**
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
public function testPersist()
{
$origin = $this->getMockBuilder('Oro\\Bundle\\EmailBundle\\Entity\\EmailOrigin')->getMock();
$origin->expects($this->any())->method('getId')->will($this->returnValue(1));
$folder = new EmailFolder();
$folder->setName('Exist');
$folder->setFullName('Exist');
$folder->setOrigin($origin);
$this->batch->addFolder($folder);
$newFolder = new EmailFolder();
$newFolder->setName('New');
$newFolder->setFullName('New');
$newFolder->setOrigin($origin);
$this->batch->addFolder($newFolder);
$dbFolder = new EmailFolder();
$dbFolder->setName('DbExist');
$dbFolder->setFullName('DbExist');
$dbFolder->setOrigin($origin);
$addr = $this->addrManager->newEmailAddress()->setEmail('Exist');
$this->batch->addAddress($addr);
$newAddr = $this->addrManager->newEmailAddress()->setEmail('New');
$this->batch->addAddress($newAddr);
$dbAddr = $this->addrManager->newEmailAddress()->setEmail('DbExist');
$email1 = new Email();
$email1->setXMessageId('email1');
$email1->setMessageId('email1');
$email1->setFromEmailAddress($addr);
$emailUser1 = new EmailUser();
$emailUser1->addFolder($folder);
$emailUser1->setOrigin($origin);
$email1->addEmailUser($emailUser1);
$this->addEmailRecipient($email1, $addr);
$this->addEmailRecipient($email1, $newAddr);
$this->batch->addEmailUser($emailUser1);
$email2 = new Email();
$email2->setXMessageId('email2');
$email2->setMessageId('email2');
$email2->setFromEmailAddress($newAddr);
$emailUser2 = new EmailUser();
$emailUser2->addFolder($newFolder);
$emailUser2->setOrigin($origin);
$email2->addEmailUser($emailUser2);
$this->addEmailRecipient($email2, $addr);
$this->addEmailRecipient($email2, $newAddr);
$this->batch->addEmailUser($emailUser2);
$email3 = new Email();
$email3->setXMessageId('email3');
$email3->setMessageId('some_email');
$email3->setFromEmailAddress($newAddr);
$emailUser3 = new EmailUser();
$emailUser3->addFolder($folder);
$email3->addEmailUser($emailUser3);
$this->addEmailRecipient($email3, $addr);
$this->addEmailRecipient($email3, $newAddr);
$this->batch->addEmailUser($emailUser3);
$email4 = new Email();
$email4->setXMessageId('email4');
$email4->setMessageId('some_email');
$email4->setFromEmailAddress($newAddr);
$emailUser4 = new EmailUser();
$emailUser4->addFolder($folder);
$email4->addEmailUser($emailUser4);
$this->addEmailRecipient($email4, $addr);
$this->addEmailRecipient($email4, $newAddr);
$this->batch->addEmailUser($emailUser4);
$existingEmail = new Email();
$existingEmail->setXMessageId('existing_email');
$existingEmail->setMessageId('some_email');
$existingEmail->setFromEmailAddress($newAddr);
$emailUser5 = new EmailUser();
$emailUser5->addFolder($dbFolder);
$existingEmail->addEmailUser($emailUser5);
$this->addEmailRecipient($existingEmail, $addr);
$this->addEmailRecipient($existingEmail, $newAddr);
$em = $this->getMockBuilder('Doctrine\\ORM\\EntityManager')->disableOriginalConstructor()->getMock();
$folderRepo = $this->getMockBuilder('Doctrine\\ORM\\EntityRepository')->disableOriginalConstructor()->getMock();
$addrRepo = $this->getMockBuilder('Doctrine\\ORM\\EntityRepository')->disableOriginalConstructor()->getMock();
$emailRepo = $this->getMockBuilder('Doctrine\\ORM\\EntityRepository')->disableOriginalConstructor()->getMock();
$em->expects($this->exactly(3))->method('getRepository')->will($this->returnValueMap(array(array('OroEmailBundle:EmailFolder', $folderRepo), array('Oro\\Bundle\\EmailBundle\\Tests\\Unit\\Entity\\TestFixtures\\TestEmailAddressProxy', $addrRepo), array('OroEmailBundle:Email', $emailRepo))));
$folderRepo->expects($this->exactly(2))->method('findOneBy')->will($this->returnCallback(function ($c) use(&$dbFolder) {
return $c['fullName'] === 'Exist' ? $dbFolder : null;
}));
$addrRepo->expects($this->exactly(2))->method('findOneBy')->will($this->returnCallback(function ($c) use(&$dbAddr) {
return $c['email'] === 'Exist' ? $dbAddr : null;
}));
$emailRepo->expects($this->once())->method('findBy')->with(array('messageId' => array('email1', 'email2', 'some_email')))->will($this->returnValue([$existingEmail]));
$owner = $this->getMock('Oro\\Bundle\\EmailBundle\\Entity\\EmailOwnerInterface');
$this->ownerProvider->expects($this->any())->method('findEmailOwner')->will($this->returnValue($owner));
$this->batch->persist($em);
$this->assertCount(1, $email1->getEmailUsers());
$this->assertCount(1, $email2->getEmailUsers());
$this->assertTrue($origin === $emailUser1->getOrigin());
$this->assertTrue($origin === $emailUser2->getOrigin());
$this->assertSame($newFolder, $emailUser2->getFolders()->first());
$this->assertSame($dbFolder, $emailUser1->getFolders()->first());
$this->assertTrue($dbAddr === $email1->getFromEmailAddress());
$this->assertNull($email1->getFromEmailAddress()->getOwner());
//.........这里部分代码省略.........