request = $this->getMockBuilder(IRequest::class)->getMock(); $this->ticketService = $this->getMockBuilder(TicketService::class) ->disableOriginalConstructor() ->getMock(); $this->ticketMapper = $this->getMockBuilder(TicketMapper::class) ->disableOriginalConstructor() ->getMock(); $this->matrixService = $this->getMockBuilder(MatrixService::class) ->disableOriginalConstructor() ->getMock(); $this->chatService = $this->getMockBuilder(ChatService::class) ->disableOriginalConstructor() ->getMock(); $this->controller = new TicketApiController( $this->request, new NullLogger(), $this->ticketService, $this->ticketMapper, $this->matrixService, $this->chatService, $this->userId, ); } public function testCreate() { $title = 'title here'; $content = 'just check if this value is returned correctly'; $ticketId = 1; $this->ticketService->expects($this->once()) ->method('create') ->with($this->equalTo($title), $this->equalTo($content), $this->equalTo($this->userId)) ->willReturn(array( 'ticketId' => $ticketId, 'status' => "open", 'lastModified' => $this->any(), 'title' => $title, 'description' => $content, 'matrixHelperName' => null, 'expirationDate' => $this->any(), )); $response = $this->controller->create($title, $content); $responseData = $response->getData(); $this->assertEquals($ticketId, $responseData['ticketId']); } /* public function testUpdateNotFound() { // test the correct status code if no note is found $this->service->expects($this->once()) ->method('update') ->will($this->throwException(new NoteNotFound())); $result = $this->controller->update(3); $this->assertEquals(Http::STATUS_NOT_FOUND, $result->getStatus()); }*/ }