protected function setUp() { MockAnnotations::init($this); $factory = new TicketFactory('\\Diamante\\DeskBundle\\Model\\Ticket\\Ticket'); $this->builder = new CommonTicketBuilder($factory, $this->branchRepository, $this->userService); $this->branchRepository->expects($this->once())->method('get')->with(self::BRANCH_ID)->will($this->returnValue($this->createBranch())); $this->userService->expects($this->once())->method('getByUser')->with(new User(self::ASSIGNEE_ID, User::TYPE_ORO))->will($this->returnValue($this->createAssignee())); }
public function testGenerateGridFilterUrl() { $returnedFilter = new Filter('testFilter', 'testServiceId'); $this->filterRepository->expects($this->once())->method('get')->with($this->equalTo(self::DUMMY_FILTER_ID))->will($this->returnValue($returnedFilter)); $this->container->expects($this->once())->method('get')->with($this->equalTo($returnedFilter->getServiceId()))->will($this->returnValue($this->filterUrlGenerator)); $this->filterUrlGenerator->expects($this->once())->method('generateFilterUrlPart'); $this->ticketGridFiltersService->generateGridFilterUrl(self::DUMMY_FILTER_ID); }
/** * @test */ public function testBranchDefaultAssigneeRetrieved() { $this->branchRepository->expects($this->once())->method('get')->with($this->equalTo(1))->will($this->returnValue($this->branch)); $this->branch->expects($this->once())->method('getDefaultAssigneeId')->will($this->returnValue(1)); $assignee = $this->branchEmailConfigurationServiceImpl->getBranchDefaultAssignee(1); $this->assertEquals(1, $assignee); }
/** * @test */ public function deleteAttachment() { $pathname = 'some/path/file.ext'; $filename = 'file.ext'; $attachment = new Attachment(new File($pathname)); $this->fileStorageService->expects($this->once())->method('remove')->with($this->equalTo($filename)); $this->repository->expects($this->once())->method('remove')->with($this->equalTo($attachment)); $this->manager->deleteAttachment($attachment); }
public function testRenderTicket() { $tags = array(array('id' => 1, 'name' => 'Ticket Tag')); $renderTagResult = '<span class="tag-inline">Ticket Tag</span>'; $this->registry->expects($this->once())->method('getRepository')->will($this->returnValue($this->sharedRepository)); $this->tagManager->expects($this->once())->method('loadTagging')->will($this->returnValue($this->tagManager)); $this->twig->expects($this->once())->method('render')->will($this->returnValue($renderTagResult)); $this->sharedRepository->expects($this->once())->method('get')->will($this->returnValue($this->ticket)); $this->ticket->expects($this->once())->method('getTags')->will($this->returnValue($this->commonCollection)); $this->commonCollection->expects($this->once())->method('getValues')->will($this->returnValue($tags)); $ticketResult = $this->renderTagExtensionExtension->renderTag($this->twig, 1, 'ticket'); $this->assertEquals($renderTagResult, $ticketResult); }
/** * @test */ public function thatCommentCreatesWithAttachments() { $author = $this->createAuthor(); $ticket = $this->createDummyTicket(); $this->messageReferenceRepository->expects($this->once())->method('getReferenceByMessageId')->with($this->equalTo(self::DUMMY_MESSAGE_ID))->will($this->returnValue($this->messageReference)); $this->messageReference->expects($this->once())->method('getTicket')->will($this->returnValue($ticket)); $this->commentFactory->expects($this->once())->method('create')->with($this->equalTo(self::DUMMY_COMMENT_CONTENT), $this->equalTo($ticket), $this->equalTo($author))->will($this->returnValue($this->comment)); $this->attachmentManager->expects($this->once())->method('createNewAttachment')->with($this->equalTo(self::DUMMY_FILENAME), $this->equalTo(self::DUMMY_FILE_CONTENT), $this->equalTo($this->comment)); $this->ticketRepository->expects($this->once())->method('store')->with($this->equalTo($ticket)); $this->messageReferenceService->createCommentForTicket(self::DUMMY_COMMENT_CONTENT, (string) $author, self::DUMMY_MESSAGE_ID, $this->attachments()); $this->assertCount(1, $ticket->getComments()); $this->assertEquals($this->comment, $ticket->getComments()->get(0)); }
public function testUpdateProperties() { $this->branchRepository->expects($this->once())->method('get')->will($this->returnValue($this->branch)); $name = 'DUMMY_NAME_UPDT'; $description = 'DUMMY_DESC_UPDT'; $this->branch->expects($this->at(0))->method('updateProperty')->with($this->equalTo('name'), $this->equalTo($name)); $this->branch->expects($this->at(1))->method('updateProperty')->with($this->equalTo('description'), $this->equalTo($description)); $this->branchRepository->expects($this->once())->method('store')->with($this->equalTo($this->branch)); $this->authorizationService->expects($this->once())->method('isActionPermitted')->with($this->equalTo('EDIT'), $this->equalTo('Entity:DiamanteDeskBundle:Branch'))->will($this->returnValue(true)); $command = new UpdatePropertiesCommand(); $command->id = 1; $command->properties = ['name' => $name, 'description' => $description]; $this->branchServiceImpl->updateProperties($command); }
/** * @test */ public function thatAttachmentRemovesFromComment() { $attachment = new Attachment(new File('some/path/file.ext')); $this->commentRepository->expects($this->once())->method('get')->with($this->equalTo(self::DUMMY_COMMENT_ID))->will($this->returnValue($this->comment)); $this->comment->expects($this->once())->method('getAttachment')->with($this->equalTo(1))->will($this->returnValue($attachment)); $this->comment->expects($this->once())->method('removeAttachment')->with($this->equalTo($attachment)); $this->attachmentManager->expects($this->once())->method('deleteAttachment')->with($this->equalTo($attachment)); $this->commentRepository->expects($this->once())->method('store')->with($this->equalTo($this->comment)); $this->authorizationService->expects($this->once())->method('isActionPermitted')->with($this->equalTo('EDIT'), $this->equalTo($this->comment))->will($this->returnValue(true)); $removeCommentAttachmentCommand = new RemoveCommentAttachmentCommand(); $removeCommentAttachmentCommand->attachmentId = 1; $removeCommentAttachmentCommand->commentId = self::DUMMY_COMMENT_ID; $this->service->removeAttachmentFromComment($removeCommentAttachmentCommand); }