本文整理汇总了PHP中Oro\Bundle\EmailBundle\Entity\Email::addFolder方法的典型用法代码示例。如果您正苦于以下问题:PHP Email::addFolder方法的具体用法?PHP Email::addFolder怎么用?PHP Email::addFolder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Oro\Bundle\EmailBundle\Entity\Email
的用法示例。
在下文中一共展示了Email::addFolder方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testFolderGetterAndSetter
public function testFolderGetterAndSetter()
{
$folder = $this->getMock('Oro\\Bundle\\EmailBundle\\Entity\\EmailFolder');
$entity = new Email();
$entity->addFolder($folder);
$this->assertTrue($folder === $entity->getFolders()->first());
}
示例2: 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));
$this->batch->addOrigin($origin);
$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->addFolder($folder);
$email1->setFromEmailAddress($addr);
$this->addEmailRecipient($email1, $addr);
$this->addEmailRecipient($email1, $newAddr);
$this->batch->addEmail($email1);
$email2 = new Email();
$email2->setXMessageId('email2');
$email2->setMessageId('email2');
$email2->addFolder($newFolder);
$email2->setFromEmailAddress($newAddr);
$this->addEmailRecipient($email2, $addr);
$this->addEmailRecipient($email2, $newAddr);
$this->batch->addEmail($email2);
$email3 = new Email();
$email3->setXMessageId('email3');
$email3->setMessageId('some_email');
$email3->addFolder($folder);
$email3->setFromEmailAddress($newAddr);
$this->addEmailRecipient($email3, $addr);
$this->addEmailRecipient($email3, $newAddr);
$this->batch->addEmail($email3);
$email4 = new Email();
$email4->setXMessageId('email4');
$email4->setMessageId('some_email');
$email4->addFolder($folder);
$email4->setFromEmailAddress($newAddr);
$this->addEmailRecipient($email4, $addr);
$this->addEmailRecipient($email4, $newAddr);
$this->batch->addEmail($email4);
$existingEmail = new Email();
$existingEmail->setXMessageId('existing_email');
$existingEmail->setMessageId('some_email');
$existingEmail->addFolder($dbFolder);
$existingEmail->setFromEmailAddress($newAddr);
$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]));
$em->expects($this->exactly(5))->method('persist')->with($this->logicalOr($this->identicalTo($newFolder), $this->identicalTo($newAddr), $this->identicalTo($email1), $this->identicalTo($email2), $this->identicalTo($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->getFolders());
$this->assertCount(1, $email2->getFolders());
$this->assertTrue($origin === $email1->getFolders()->first()->getOrigin());
$this->assertTrue($origin === $email2->getFolders()->first()->getOrigin());
$this->assertSame($dbFolder, $email1->getFolders()->first());
$this->assertSame($newFolder, $email2->getFolders()->first());
$this->assertTrue($dbAddr === $email1->getFromEmailAddress());
$this->assertNull($email1->getFromEmailAddress()->getOwner());
$this->assertTrue($newAddr === $email2->getFromEmailAddress());
$this->assertTrue($owner === $email2->getFromEmailAddress()->getOwner());
$email1Recipients = $email1->getRecipients();
$this->assertTrue($dbAddr === $email1Recipients[0]->getEmailAddress());
$this->assertNull($email1Recipients[0]->getEmailAddress()->getOwner());
$this->assertTrue($newAddr === $email1Recipients[1]->getEmailAddress());
$this->assertTrue($owner === $email1Recipients[1]->getEmailAddress()->getOwner());
$email2Recipients = $email2->getRecipients();
$this->assertTrue($dbAddr === $email2Recipients[0]->getEmailAddress());
$this->assertNull($email2Recipients[0]->getEmailAddress()->getOwner());
//.........这里部分代码省略.........