request = $this->createMock(IRequest::class); $this->config = $this->createMock(IConfig::class); $this->appConfig = $this->createMock(IAppConfig::class); $this->appManager = $this->createMock(AppManager::class); $this->dependencyAnalyzer = $this->createMock(DependencyAnalyzer::class); $this->categoryFetcher = $this->createMock(CategoryFetcher::class); $this->appFetcher = $this->createMock(AppFetcher::class); $this->l10nFactory = $this->createMock(IFactory::class); $this->bundleFetcher = $this->createMock(BundleFetcher::class); $this->installer = $this->createMock(Installer::class); $this->subscriptionRegistry = $this->createMock(IRegistry::class); $this->logger = $this->createMock(LoggerInterface::class); $this->apiController = new ApiController( $this->request, $this->config, $this->appConfig, $this->appManager, $this->dependencyAnalyzer, $this->categoryFetcher, $this->appFetcher, $this->l10nFactory, $this->bundleFetcher, $this->installer, $this->subscriptionRegistry, $this->logger, ); } public function testListCategories(): void { $json = file_get_contents(__DIR__ . '/../fixtures/categories.json'); $this->categoryFetcher ->expects($this->once()) ->method('get') ->willReturn(json_decode($json, true)['data']); $response = $this->apiController->listCategories(); $this->assertInstanceOf(DataResponse::class, $response); $this->assertSame(200, $response->getStatus()); $jsonResponse = json_encode($response->getData()); $this->assertJsonStringEqualsJsonFile(__DIR__ . '/../fixtures/categories-api-response.json', $jsonResponse); } }