/** * @expectedException \Symfony\Component\Security\Core\Exception\AuthenticationException * @expectedExceptionMessage Attempt of unauthorized access */ public function testGetCurrentUserWithNoDiamanteUser() { $apiUser = $this->createApiUser(); $this->authorizationService->expects($this->once())->method('getLoggedUser')->will($this->returnValue($apiUser)); $this->diamanteUserRepository->expects($this->once())->method('findUserByEmail')->with($apiUser->getEmail())->will($this->returnValue(null)); $this->service->getCurrentUser(); }
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); }
public function testUpdatePropertiesByKey() { $this->ticketRepository->expects($this->once())->method('get')->will($this->returnValue($this->ticket)); $properties = array('subject' => 'DUMMY_SUBJECT_UPDT_BY_KEY', 'description' => 'DUMMY_DESC_UPDT_BY_KEY', 'status' => 'open', 'priority' => 'high', 'source' => 'phone'); $this->ticket->expects($this->once())->method('updateProperties')->with($this->equalTo($properties)); $this->ticket->expects($this->once())->method('getId')->will($this->returnValue(1)); $this->ticketRepository->expects($this->once())->method('getByTicketKey')->with(new TicketKey('DT', 1))->will($this->returnValue($this->ticket)); $this->ticketRepository->expects($this->once())->method('store')->with($this->equalTo($this->ticket)); $this->authorizationService->expects($this->any())->method('isActionPermitted')->with($this->anything(), $this->equalTo($this->ticket))->will($this->returnValue(true)); $command = new UpdatePropertiesCommand(); $command->key = static::DUMMY_TICKET_KEY; $command->properties = $properties; $this->ticketService->updatePropertiesByKey($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->registry->expects($this->any())->method('getManager')->will($this->returnValue($this->em)); $this->em->expects($this->any())->method('persist'); $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); }