/** * @test * @expectedException \RuntimeException * @expectedExceptionMessage Attachment loading failed. Ticket has no such attachment. */ public function thatAttachmentRemovingThrowsExceptionWhenTicketHasNoAttachment() { $ticket = new Ticket(new UniqueId('unique_id'), new TicketSequenceNumber(12), self::SUBJECT, self::DESCRIPTION, $this->createBranch(), $this->createReporter(), $this->createAssignee(), new Source(Source::PHONE), new Priority(Priority::PRIORITY_LOW), new Status(Status::CLOSED)); $ticket->addAttachment($this->attachment()); $this->ticketRepository->expects($this->once())->method('get')->with($this->equalTo(self::DUMMY_TICKET_ID))->will($this->returnValue($ticket)); $this->authorizationService->expects($this->once())->method('isActionPermitted')->with($this->equalTo('EDIT'), $this->equalTo($ticket))->will($this->returnValue(true)); $removeTicketAttachmentCommand = new RemoveTicketAttachmentCommand(); $removeTicketAttachmentCommand->ticketId = self::DUMMY_TICKET_ID; $removeTicketAttachmentCommand->attachmentId = self::DUMMY_ATTACHMENT_ID; $this->ticketService->removeAttachmentFromTicket($removeTicketAttachmentCommand); }