/** * @test */ public function thatListsCommentAttachment() { $comment = new Comment(self::DUMMY_COMMENT_CONTENT, $this->_dummyTicket, $this->createDiamanteUser(), false); $a1 = new Attachment(new File('some/path/file.ext')); $a2 = new Attachment(new File('some/path/file.ext')); $comment->addAttachment($a1); $comment->addAttachment($a2); $this->commentRepository->expects($this->once())->method('get')->with($this->equalTo(self::DUMMY_COMMENT_ID))->will($this->returnValue($comment)); $this->authorizationService->expects($this->once())->method('isActionPermitted')->with($this->equalTo('VIEW'), $this->equalTo($comment))->will($this->returnValue(true)); $attachments = $this->service->listCommentAttachment(self::DUMMY_COMMENT_ID); $this->assertNotNull($attachments); $this->assertCount(2, $attachments); $this->assertContains($a1, $attachments); $this->assertContains($a2, $attachments); }
/** * Retrieves comment attachments * * @ApiDoc( * description="Returns comment attachments", * uri="/comments/{id}/attachments.{_format}", * method="GET", * resource=true, * requirements={ * { * "name"="id", * "dataType"="integer", * "requirement"="\d+", * "description"="Comment Id" * } * }, * statusCodes={ * 200="Returned when successful", * 403="Returned when the user is not authorized to list comment attachments" * } * ) * * @param $id * * @return \Doctrine\Common\Collections\ArrayCollection */ public function listCommentAttachment($id) { return parent::listCommentAttachment($id); }