/** * @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)); }
/** * @test */ public function thatCommentCreatesWithAttachments() { $author = $this->createAuthor(); $ticket = $this->createDummyTicket(); $ticketWithComment = clone $ticket; $ticketWithComment->postNewComment($this->comment); $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->commentService->expects($this->once())->method('postNewCommentForTicket')->will($this->returnValue($ticketWithComment)); $this->messageReferenceService->createCommentForTicket(self::DUMMY_COMMENT_CONTENT, (string) $author, self::DUMMY_MESSAGE_ID, $this->attachments()); $this->assertCount(1, $ticketWithComment->getComments()); $this->assertEquals($this->comment, $ticketWithComment->getComments()->get(0)); }