/** * @test */ public function thatTicketCreatesWithAttachments() { $branchId = 1; $assigneeId = 3; $reporter = $this->createReporter(); $this->ticketBuilder->expects($this->once())->method('setSubject')->with(self::SUBJECT)->will($this->returnValue($this->ticketBuilder)); $this->ticketBuilder->expects($this->once())->method('setDescription')->with(self::DESCRIPTION)->will($this->returnValue($this->ticketBuilder)); $this->ticketBuilder->expects($this->once())->method('setBranchId')->with($branchId)->will($this->returnValue($this->ticketBuilder)); $this->ticketBuilder->expects($this->once())->method('setReporter')->with((string) $reporter)->will($this->returnValue($this->ticketBuilder)); $this->ticketBuilder->expects($this->once())->method('setAssigneeId')->with($assigneeId)->will($this->returnValue($this->ticketBuilder)); $this->ticketBuilder->expects($this->once())->method('setSource')->with(Source::EMAIL)->will($this->returnValue($this->ticketBuilder)); $this->ticketBuilder->expects($this->once())->method('build')->will($this->returnValue($this->ticket)); $this->attachmentManager->expects($this->once())->method('createNewAttachment')->with($this->equalTo(self::DUMMY_FILENAME), $this->equalTo(self::DUMMY_FILE_CONTENT), $this->equalTo($this->ticket)); $this->ticketRepository->expects($this->once())->method('store')->with($this->equalTo($this->ticket)); $messageReference = new MessageReference(self::DUMMY_MESSAGE_ID, $this->ticket); $this->messageReferenceRepository->expects($this->once())->method('store')->with($this->equalTo($messageReference)); $this->ticket->expects($this->atLeastOnce())->method('getRecordedEvents')->will($this->returnValue(array())); $this->messageReferenceService->createTicket(self::DUMMY_MESSAGE_ID, $branchId, self::SUBJECT, self::DESCRIPTION, $reporter, $assigneeId, $this->attachments()); }
/** * @test */ public function thatTicketCreatesWithDefaultStatusAndAttachments() { $branchId = 1; $reporterId = 2; $assigneeId = 3; $status = Status::NEW_ONE; $priority = Priority::PRIORITY_LOW; $source = Source::PHONE; $number = new TicketSequenceNumber(null); $reporter = $this->createReporter($reporterId); $ticket = new Ticket(UniqueId::generate(), $number, self::SUBJECT, self::DESCRIPTION, $this->createBranch(), $reporter, $this->createAssignee(), new Source($source), new Priority($priority), new Status($status)); $this->ticketBuilder->expects($this->once())->method('setSubject')->with(self::SUBJECT)->will($this->returnValue($this->ticketBuilder)); $this->ticketBuilder->expects($this->once())->method('setDescription')->with(self::DESCRIPTION)->will($this->returnValue($this->ticketBuilder)); $this->ticketBuilder->expects($this->once())->method('setBranchId')->with($branchId)->will($this->returnValue($this->ticketBuilder)); $this->ticketBuilder->expects($this->once())->method('setReporter')->with((string) $reporter)->will($this->returnValue($this->ticketBuilder)); $this->ticketBuilder->expects($this->once())->method('setAssigneeId')->with($assigneeId)->will($this->returnValue($this->ticketBuilder)); $this->ticketBuilder->expects($this->once())->method('setSource')->with($source)->will($this->returnValue($this->ticketBuilder)); $this->ticketBuilder->expects($this->once())->method('setPriority')->with($priority)->will($this->returnValue($this->ticketBuilder)); $this->ticketBuilder->expects($this->once())->method('setStatus')->with(null)->will($this->returnValue($this->ticketBuilder)); $this->ticketBuilder->expects($this->once())->method('build')->will($this->returnValue($ticket)); $attachmentInputs = $this->attachmentInputs(); $this->attachmentManager->expects($this->exactly(count($attachmentInputs)))->method('createNewAttachment')->with($this->isType(\PHPUnit_Framework_Constraint_IsType::TYPE_STRING), $this->isType(\PHPUnit_Framework_Constraint_IsType::TYPE_STRING), $this->equalTo($ticket)); $this->ticketRepository->expects($this->once())->method('store')->with($this->equalTo($ticket)); $this->authorizationService->expects($this->once())->method('isActionPermitted')->with($this->equalTo('CREATE'), $this->equalTo('Entity:DiamanteDeskBundle:Ticket'))->will($this->returnValue(true)); $command = new CreateTicketCommand(); $command->branch = $branchId; $command->subject = self::SUBJECT; $command->description = self::DESCRIPTION; $command->reporter = (string) $reporter; $command->assignee = $assigneeId; $command->priority = $priority; $command->source = $source; $command->status = null; $command->attachmentsInput = $attachmentInputs; $this->ticketService->createTicket($command); }