categoryGateway = $this->createMock(CategoryGateway::class); $this->ticketGateway = $this->createMock(TicketGateway::class); $this->permissionChecker = $this->createMock(PermissionChecker::class); $this->modsForHeskSettingsGateway = $this->createMock(ModsForHeskSettingsGateway::class); $this->categoryHandler = new CategoryHandler($this->categoryGateway, $this->ticketGateway, $this->permissionChecker, $this->modsForHeskSettingsGateway); $this->heskSettings = array(); //TODO write proper tests! $this->permissionChecker->method('doesUserHavePermission')->willReturn(true); } function testCreateCallsTheGatewayWithTheCategory() { //-- Arrange $category = new Category(); $category->autoAssign = true; $category->backgroundColor = 'a'; $category->foregroundColor = 'a'; $category->catOrder = 1000; $category->description = 'd'; $category->displayBorder = false; $category->name = 'n'; $category->priority = Priority::LOW; $category->usage = 0; $category->type = 0; $category->id = 1; $this->categoryGateway->method('getAllCategories')->willReturn([$category]); //-- Assert $this->categoryGateway->expects($this->once())->method('createCategory') ->willReturn(1) ->with($category, $this->heskSettings); //-- Act $this->categoryHandler->createCategory($category, new UserContext(), $this->heskSettings); } }