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); }
/** * Update certain properties of the Ticket * @param Command\UpdatePropertiesCommand $command * @return Ticket * * @throws TicketNotFoundException * @throws ForbiddenException */ public function updateProperties(Command\UpdatePropertiesCommand $command) { $ticket = $this->loadTicketById($command->id); $this->isGranted('EDIT', $ticket); $ticket->updateProperties($command->properties); $this->ticketRepository->store($ticket); $this->loadTagging($ticket); $this->dispatchWorkflowEvent($this->doctrineRegistry, $this->dispatcher, $ticket); return $ticket; }
/** * Update certain properties of the Ticket * @param Command\UpdatePropertiesCommand $command * @return Ticket */ public function updateProperties(Command\UpdatePropertiesCommand $command) { /** * @var $ticket \Diamante\DeskBundle\Model\Ticket\Ticket */ $ticket = $this->loadTicketById($command->id); $this->isGranted('EDIT', $ticket); $ticket->updateProperties($command->properties); $this->ticketRepository->store($ticket); $this->dispatchEvents($ticket); return $ticket; }
/** * @test */ public function testSearchTickets() { $tickets = array(new Ticket(new UniqueId('unique_id'), new TicketSequenceNumber(13), self::SUBJECT, self::DESCRIPTION, $this->createBranch(), new User(1, User::TYPE_DIAMANTE), $this->createAssignee(), new Source(Source::PHONE), new Priority(Priority::PRIORITY_LOW), new Status(Status::CLOSED)), new Ticket(new UniqueId('unique_id'), new TicketSequenceNumber(12), self::SUBJECT, self::DESCRIPTION, $this->createBranch(), new User(1, User::TYPE_ORO), $this->createAssignee(), new Source(Source::PHONE), new Priority(Priority::PRIORITY_LOW), new Status(Status::CLOSED))); $command = new SearchTicketsCommand(); $command->q = 'scr'; $command->reporter = 'oro_1'; $pagingInfo = new PagingInfo(1, new FilterPagingProperties()); $this->ticketRepository->expects($this->once())->method('search')->with($this->equalTo('scr'), $this->equalTo(array(array('reporter', 'eq', 'oro_1'))), $this->equalTo(new FilterPagingProperties()))->will($this->returnValue(array($tickets[1]))); $this->apiPagingService->expects($this->once())->method('getPagingInfo')->will($this->returnValue($pagingInfo)); $retrievedTickets = $this->ticketService->searchTickets($command); $this->assertNotNull($retrievedTickets); $this->assertTrue(is_array($retrievedTickets)); $this->assertNotEmpty($retrievedTickets); $this->assertEquals($tickets[1], $retrievedTickets[0]); }
/** * @expectedException \RuntimeException * @expectedExceptionMessage Ticket loading failed, ticket not found. */ public function testDeleteTicketByKeyWhenTicketDoesNotExist() { $this->ticketRepository->expects($this->once())->method('getByTicketKey')->with(new TicketKey('DT', 1))->will($this->returnValue(null)); $this->ticketService->deleteTicketByKey(self::DUMMY_TICKET_KEY); }
/** * @param Notification $notification * @return Ticket */ private function loadTicket(Notification $notification) { $uniqueId = new UniqueId($notification->getTicketUniqueId()); $ticket = $this->ticketRepository->getByUniqueId($uniqueId); return $ticket; }
public function renderTag(\Twig_Environment $twig, $ticketId) { $ticket = $this->ticketRepository->get($ticketId); $this->tagManager->loadTagging($ticket); return $twig->render('DiamanteDeskBundle:Ticket/Datagrid/Property:tag.html.twig', ['tags' => $ticket->getTags()->getValues()]); }
/** * @param User $user */ public function cleanupUser(User $user) { $this->watcherListRepository->removeByUser($user); $this->ticketRepository->removeTicketReporter($user); $this->commentRepository->removeCommentAuthor($user); }