コード例 #1
0
 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]);
 }
コード例 #2
0
 /**
  * {@inheritDoc}
  */
 public function load(ObjectManager $manager)
 {
     $outboxFolder = new EmailFolder();
     $outboxFolder->setType(EmailFolder::SENT)->setName(EmailFolder::SENT)->setFullName(EmailFolder::SENT);
     $origin = new InternalEmailOrigin();
     $origin->setName(InternalEmailOrigin::BAP)->addFolder($outboxFolder);
     $manager->persist($origin);
     $manager->flush();
 }
コード例 #3
0
ファイル: LoadUserData.php プロジェクト: Maksold/platform
 /**
  * {@inheritdoc}
  */
 public function load(ObjectManager $manager)
 {
     $userManager = $this->container->get('oro_user.manager');
     $organization = $manager->getRepository('OroOrganizationBundle:Organization')->getFirst();
     $role = $manager->getRepository('OroUserBundle:Role')->findOneBy(['role' => 'ROLE_ADMINISTRATOR']);
     $user = $userManager->createUser();
     $user->setUsername('simple_user')->setPlainPassword('simple_password')->setEmail('*****@*****.**')->setOrganization($organization)->addOrganization($organization)->setEnabled(true)->addRole($role);
     $folder = new EmailFolder();
     $folder->setName('sent');
     $folder->setFullName('sent');
     $folder->setType('sent');
     $origin = new InternalEmailOrigin();
     $origin->setName('simple_user_origin_name');
     $origin->setActive(true);
     $origin->addFolder($folder);
     $origin->setOwner($user);
     $origin->setOrganization($organization);
     $user->addEmailOrigin($origin);
     $userManager->updateUser($user);
     $user2 = $userManager->createUser();
     $user2->setUsername('simple_user2')->setPlainPassword('simple_password2')->setFirstName('Elley')->setLastName('Towards')->setEmail('*****@*****.**')->setOrganization($organization)->addOrganization($organization)->setEnabled(true);
     $folder2 = new EmailFolder();
     $folder2->setName('sent');
     $folder2->setFullName('sent');
     $folder2->setType('sent');
     $origin2 = new InternalEmailOrigin();
     $origin2->setName('simple_user_origin_name_2');
     $origin2->setActive(true);
     $origin2->addFolder($folder2);
     $origin2->setOwner($user2);
     $origin2->setOrganization($organization);
     $user2->addEmailOrigin($origin);
     $userManager->updateUser($user2);
     $this->setReference($user->getUsername(), $user);
     $this->setReference($user2->getUsername(), $user2);
 }
コード例 #4
0
 protected function getTestOrigin()
 {
     $outboxFolder = new EmailFolder();
     $outboxFolder->setType(FolderType::SENT)->setName(FolderType::SENT)->setFullName(FolderType::SENT);
     $origin = new InternalEmailOrigin();
     $origin->setName('BAP_User_1')->addFolder($outboxFolder)->setOwner($this->getTestUser())->setOrganization($this->getTestOrganization());
     return $origin;
 }
コード例 #5
0
ファイル: Processor.php プロジェクト: northdakota/platform
 /**
  * @param User                  $emailOwner
  * @param OrganizationInterface $organization
  *
  * @return InternalEmailOrigin
  */
 protected function createUserInternalOrigin(User $emailOwner, OrganizationInterface $organization = null)
 {
     $organization = $organization ? $organization : $emailOwner->getOrganization();
     $originName = InternalEmailOrigin::BAP . '_User_' . $emailOwner->getId();
     $outboxFolder = new EmailFolder();
     $outboxFolder->setType(FolderType::SENT)->setName(FolderType::SENT)->setFullName(FolderType::SENT);
     $origin = new InternalEmailOrigin();
     $origin->setName($originName)->addFolder($outboxFolder)->setOwner($emailOwner)->setOrganization($organization);
     $emailOwner->addEmailOrigin($origin);
     $this->getEntityManager()->persist($origin);
     $this->getEntityManager()->persist($emailOwner);
     return $origin;
 }
コード例 #6
0
ファイル: EmailApiHandler.php プロジェクト: nmallare/platform
 /**
  * @param User                  $originOwner
  * @param OrganizationInterface $organization
  * @param string                $originName
  *
  * @return InternalEmailOrigin
  */
 protected function createEmailOrigin(User $originOwner, OrganizationInterface $organization, $originName)
 {
     $origin = new InternalEmailOrigin();
     $origin->setName($originName);
     $origin->setOwner($originOwner);
     $origin->setOrganization($organization);
     $originOwner->addEmailOrigin($origin);
     $this->entityManager->persist($origin);
     return $origin;
 }
コード例 #7
0
 public function testNameGetterAndSetter()
 {
     $entity = new InternalEmailOrigin();
     $entity->setName('test');
     $this->assertEquals('test', $entity->getName());
 }