protected function setUp() { parent::setUp(); $this->user = new User(); $this->user->setEmail('*****@*****.**')->setPlainPassword('TestPassword'); $this->mailProcessor = new Processor($this->managerRegistry, $this->configManager, $this->renderer, $this->emailHolderHelper, $this->mailer); }
protected function setUp() { parent::setUp(); $this->request = new Request(); $this->user = new User(); $this->user->setEmail('*****@*****.**'); $this->mailProcessor = new Processor($this->managerRegistry, $this->configManager, $this->renderer, $this->emailHolderHelper, $this->mailer); }
/** * {@inheritdoc} */ public function load(ObjectManager $manager) { /** @var UserManager $userManager */ $userManager = $this->container->get('oro_user.manager'); $role = $manager->getRepository('OroUserBundle:Role')->findOneByRole('ROLE_ADMINISTRATOR'); $group = $manager->getRepository('OroUserBundle:Group')->findOneByName('Administrators'); $unit = $manager->getRepository('OroOrganizationBundle:BusinessUnit')->findOneByName('Main'); $organization = $manager->getRepository('OroOrganizationBundle:Organization')->getFirst(); $user = new User(); $user->setUsername('owner_User'); $user->addGroup($group); $user->addRole($role); $user->addBusinessUnit($unit); $user->setFirstname('Test Owner FirstName'); $user->setLastname('Test Owner LastName'); $user->setEmail('*****@*****.**'); $user->setOwner($unit); $user->addGroup($group); $user->setPlainPassword('test password'); $user->setSalt(md5(mt_rand(1, 222))); $user->setOrganization($organization); $userManager->updateUser($user); $this->setReference('owner_user', $user); $manager->flush(); }
public function testEmail() { $user = new User(); $mail = '*****@*****.**'; $this->assertNull($user->getEmail()); $user->setEmail($mail); $this->assertEquals($mail, $user->getEmail()); }
public function testNewItem() { $user = new User(); $user->setEmail('*****@*****.**'); $this->factory->expects($this->once())->method('createItem')->will($this->returnValue($this->item)); $repository = $this->getDefaultRepositoryMock(null); $em = $this->getEntityManager($repository); $listener = $this->getListener($this->factory, $this->securityContext, $em); $response = $this->getResponse(); $listener->onResponse($this->getEventMock($this->getRequest(), $response)); }
/** * @param string $firstName * @param string $lastName * * @return User */ protected function createUser($firstName, $lastName) { $user = new User(); $user->setOrganization($this->organization); $user->setFirstName($firstName); $user->setLastName($lastName); $user->setUsername(strtolower($firstName . '.' . $lastName)); $user->setPassword(strtolower($firstName . '.' . $lastName)); $user->setEmail(strtolower($firstName . '_' . $lastName . '@example.com')); $user->addEmail($this->email); $this->em->persist($user); return $user; }
public function testNavigationHistoryItemEntity() { $user = new User(); $user->setEmail('*****@*****.**'); $values = array('title' => 'Some Title', 'url' => 'Some Url', 'user' => $user); $item = new NavigationHistoryItem($values); $this->assertEquals($values['title'], $item->getTitle()); $this->assertEquals($values['url'], $item->getUrl()); $this->assertEquals($values['user'], $item->getUser()); $dateTime = new \DateTime(); $item->setVisitedAt($dateTime); $this->assertEquals($dateTime, $item->getVisitedAt()); $visitCount = rand(0, 100); $item->setVisitCount($visitCount); $this->assertEquals($visitCount, $item->getVisitCount()); $this->assertEquals(null, $item->getId()); }
public function testNavigationItemEntity() { $user = new User(); $user->setEmail('*****@*****.**'); $values = array('title' => 'Some Title', 'url' => 'Some Url', 'position' => 'Some position', 'user' => $user); $item = new NavigationItem($values); $item->setType('test'); $this->assertEquals($values['title'], $item->getTitle()); $this->assertEquals($values['url'], $item->getUrl()); $this->assertEquals($values['position'], $item->getPosition()); $this->assertEquals($values['user'], $item->getUser()); $this->assertEquals('test', $item->getType()); $dateTime = new \DateTime(); $item->setUpdatedAt($dateTime); $this->assertEquals($dateTime, $item->getUpdatedAt()); $dateTime = new \DateTime(); $item->setCreatedAt($dateTime); $this->assertEquals($dateTime, $item->getCreatedAt()); }
public function testNavigationHistoryItemEntity() { $organization = new Organization(); $user = new User(); $user->setEmail('*****@*****.**'); $values = array('title' => 'Some Title', 'url' => 'Some Url', 'user' => $user, 'organization' => $organization, 'route' => 'test_route', 'routeParameters' => array('key' => 'value'), 'entityId' => 1); $item = new NavigationHistoryItem($values); $this->assertEquals($values['title'], $item->getTitle()); $this->assertEquals($values['url'], $item->getUrl()); $this->assertEquals($values['user'], $item->getUser()); $this->assertEquals($values['organization'], $item->getOrganization()); $this->assertEquals($values['route'], $item->getRoute()); $this->assertEquals($values['routeParameters'], $item->getRouteParameters()); $this->assertEquals($values['entityId'], $item->getEntityId()); $dateTime = new \DateTime(); $item->setVisitedAt($dateTime); $this->assertEquals($dateTime, $item->getVisitedAt()); $visitCount = rand(0, 100); $item->setVisitCount($visitCount); $this->assertEquals($visitCount, $item->getVisitCount()); $this->assertEquals(null, $item->getId()); }
/** * @param bool $hasReminder * @param bool $hasConfig * @param bool $hasRecipient * @param bool $hasSender * @param array $templates * @return EmailNotification */ protected function createNotification($hasReminder = true, $hasConfig = false, $hasRecipient = false, $hasSender = false, $templates = null) { $repository = $this->getMock('Doctrine\\Common\\Persistence\\ObjectRepository'); $repository->expects($this->any())->method('find')->will($this->returnValue(new CalendarEvent())); $templates = is_array($templates) ? $templates : [$this->createTemplate()]; $repository->expects($this->any())->method('findBy')->will($this->returnValue($templates)); $this->em->expects($this->any())->method('getRepository')->will($this->returnValue($repository)); $this->provider = $this->getMockBuilder('\\Oro\\Bundle\\EntityConfigBundle\\Provider\\ConfigProvider')->disableOriginalConstructor()->getMock(); $config = $this->getMockBuilder('Oro\\Bundle\\EntityConfigBundle\\Config\\ConfigInterface')->disableOriginalConstructor()->getMock(); $config->expects($this->any())->method('has')->will($this->returnValue($hasConfig)); $config->expects($this->any())->method('get')->will($this->returnValue(self::TEMPLATE)); $this->provider->expects($this->any())->method('getConfig')->will($this->returnValue($config)); $notification = new EmailNotification($this->em, $this->provider, $this->entityNameResolver); if ($hasReminder) { $reminder = new Reminder(); if (!$hasConfig) { $reminder->setRelatedEntityClassName(self::ENTITY)->setRelatedEntityId(1); } if ($hasRecipient) { $user = new User(); $user->setEmail(self::EMAIL); $reminder->setRecipient($user); } if ($hasSender) { $reminder->setSender($this->sender); } $notification->setReminder($reminder); } return $notification; }
protected function getTestUser() { $user = new User(); $user->setId(1); $user->setEmail('*****@*****.**'); $user->setSalt('1fqvkjskgry8s8cs400840c0ok8ggck'); return $user; }
public function testNotifyWithEmptyAuthor() { $ticketUniqueId = UniqueId::generate(); $reporter = new UserAdapter(1, UserAdapter::TYPE_DIAMANTE); $assignee = new User(); $assignee->setId(2); $assignee->setEmail('*****@*****.**'); $author = null; $branch = new Branch('KEY', 'Name', 'Description'); $ticket = new Ticket($ticketUniqueId, new TicketSequenceNumber(1), 'Subject', 'Description', $branch, $reporter, $assignee, new Source(Source::WEB), new Priority(Priority::PRIORITY_MEDIUM), new Status(Status::NEW_ONE)); $notification = new TicketNotification((string) $ticketUniqueId, $author, 'Header', 'Subject', new \ArrayIterator(array('key' => 'value')), array('file.ext')); $message = new \Swift_Message(); $this->watchersService->expects($this->once())->method('getWatchers')->will($this->returnValue([new WatcherList($ticket, 'diamante_1')])); $this->diamanteUserRepository->expects($this->exactly(2))->method('get')->with(1)->will($this->returnValue($this->diamanteUser)); $this->configManager->expects($this->once())->method('get')->will($this->returnValue('*****@*****.**')); $this->nameFormatter->expects($this->once())->method('format')->with($this->diamanteUser)->will($this->returnValue('First Last')); $this->mailer->expects($this->once())->method('createMessage')->will($this->returnValue($message)); $this->ticketRepository->expects($this->once())->method('getByUniqueId')->with($ticketUniqueId)->will($this->returnValue($ticket)); $this->templateResolver->expects($this->any())->method('resolve')->will($this->returnValueMap(array(array($notification, TemplateResolver::TYPE_TXT, 'txt.template.html'), array($notification, TemplateResolver::TYPE_HTML, 'html.template.html')))); $optionsConstraint = $this->logicalAnd($this->arrayHasKey('changes'), $this->arrayHasKey('attachments'), $this->arrayHasKey('user'), $this->arrayHasKey('header'), $this->contains($notification->getChangeList()), $this->contains($notification->getAttachments()), $this->contains('First Last'), $this->contains($notification->getHeaderText())); $this->twig->expects($this->at(0))->method('render')->with('txt.template.html', $optionsConstraint)->will($this->returnValue('Rendered TXT template')); $this->twig->expects($this->at(1))->method('render')->with('html.template.html', $optionsConstraint)->will($this->returnValue('Rendered HTML template')); $this->mailer->expects($this->once())->method('send')->with($this->logicalAnd($this->isInstanceOf('\\Swift_Message'), $this->callback(function (\Swift_Message $other) use($notification) { $to = $other->getTo(); return false !== strpos($other->getSubject(), $notification->getSubject()) && false !== strpos($other->getSubject(), 'KEY-1') && false !== strpos($other->getBody(), 'Rendered TXT template') && array_key_exists('*****@*****.**', $to) && $other->getHeaders()->has('References') && false !== strpos($other->getHeaders()->get('References'), '*****@*****.**') && false !== strpos($other->getHeaders()->get('References'), '*****@*****.**'); }))); $this->messageReferenceRepository->expects($this->once())->method('findAllByTicket')->with($ticket)->will($this->returnValue(array(new MessageReference('*****@*****.**', $ticket), new MessageReference('*****@*****.**', $ticket)))); $this->messageReferenceRepository->expects($this->once())->method('store')->with($this->logicalAnd($this->isInstanceOf('\\Diamante\\DeskBundle\\Model\\Ticket\\EmailProcessing\\MessageReference'))); $notifier = new EmailNotifier($this->container, $this->twig, $this->mailer, $this->templateResolver, $this->ticketRepository, $this->messageReferenceRepository, $this->userService, $this->nameFormatter, $this->diamanteUserRepository, $this->configManager, $this->oroUserManager, $this->watchersService, $this->senderHost); $notifier->notify($notification); }
/** * @return array */ public function sendEmailResultProvider() { $user = new User(); $user->setEmail('*****@*****.**'); return [['user' => $user, 'emailType' => 'txt', 'expectedEmailType' => 'text/plain'], ['user' => $user, 'emailType' => 'html', 'expectedEmailType' => 'text/html']]; }
protected function setUpEvent(CalendarEvent $event, $id, $email) { $user = new User(); $user->setEmail($email); $calendar = new Calendar(); $calendar->setOwner($user); $event->setCalendar($calendar); ReflectionUtil::setPrivateProperty($event, 'id', $id); $event->setReminded(false); }
/** * @param int $size * @param string $specificData * @return array */ protected function getOroUsersCollection($size = 2, $specificData = '') { $result = array(); for ($i = 0; $i < $size; $i++) { $user = new OroUser(); $user->setUsername("username_{$i}"); $user->setFirstName("First {$specificData}"); $user->setLastName("Last {$specificData}"); $user->setEmail("some@host{$i}.com"); $result[] = $user; } return $result; }