private function setMockAssetSourcesService($indexBy) { $mockAssetSourcesService = $this->getMockBuilder(AssetSourcesService::class)->disableOriginalConstructor()->getMock(); $mockAssetSourcesService->expects($this->exactly(1))->method('getAllSources')->with($indexBy)->willReturn($this->getMockAssetSources($indexBy, 1)); $this->setComponent(Craft::app(), 'assetSources', $mockAssetSourcesService); return $mockAssetSourcesService; }