| @@ 278-292 (lines=15) @@ | ||
| 275 | * |
|
| 276 | * @return Mock|SectionsService |
|
| 277 | */ |
|
| 278 | private function setMockSectionsService($indexBy) |
|
| 279 | { |
|
| 280 | $mockSectionService = $this->getMockBuilder(SectionsService::class) |
|
| 281 | ->disableOriginalConstructor() |
|
| 282 | ->getMock(); |
|
| 283 | ||
| 284 | $mockSectionService->expects($this->any()) |
|
| 285 | ->method('getAllSections') |
|
| 286 | ->with($indexBy) |
|
| 287 | ->willReturn($this->getMockSections($indexBy, 2)); |
|
| 288 | ||
| 289 | $this->setComponent(Craft::app(), 'sections', $mockSectionService); |
|
| 290 | ||
| 291 | return $mockSectionService; |
|
| 292 | } |
|
| 293 | ||
| 294 | /** |
|
| 295 | * @param string $indexBy |
|
| @@ 328-342 (lines=15) @@ | ||
| 325 | * |
|
| 326 | * @return Mock|AssetSourcesService |
|
| 327 | */ |
|
| 328 | private function setMockAssetSourcesService($indexBy) |
|
| 329 | { |
|
| 330 | $mockAssetSourcesService = $this->getMockBuilder(AssetSourcesService::class) |
|
| 331 | ->disableOriginalConstructor() |
|
| 332 | ->getMock(); |
|
| 333 | ||
| 334 | $mockAssetSourcesService->expects($this->exactly(1)) |
|
| 335 | ->method('getAllSources') |
|
| 336 | ->with($indexBy) |
|
| 337 | ->willReturn($this->getMockAssetSources($indexBy, 1)); |
|
| 338 | ||
| 339 | $this->setComponent(Craft::app(), 'assetSources', $mockAssetSourcesService); |
|
| 340 | ||
| 341 | return $mockAssetSourcesService; |
|
| 342 | } |
|
| 343 | ||
| 344 | /** |
|
| 345 | * @param string $indexBy |
|
| @@ 378-392 (lines=15) @@ | ||
| 375 | * |
|
| 376 | * @return Mock|AssetSourcesService |
|
| 377 | */ |
|
| 378 | private function setMockGlobalsService($indexBy) |
|
| 379 | { |
|
| 380 | $mockAssetSourcesService = $this->getMockBuilder(GlobalsService::class) |
|
| 381 | ->disableOriginalConstructor() |
|
| 382 | ->getMock(); |
|
| 383 | ||
| 384 | $mockAssetSourcesService->expects($this->exactly(1)) |
|
| 385 | ->method('getAllSets') |
|
| 386 | ->with($indexBy) |
|
| 387 | ->willReturn($this->getMockGlobalSets($indexBy, 1)); |
|
| 388 | ||
| 389 | $this->setComponent(Craft::app(), 'globals', $mockAssetSourcesService); |
|
| 390 | ||
| 391 | return $mockAssetSourcesService; |
|
| 392 | } |
|
| 393 | ||
| 394 | /** |
|
| 395 | * @param string $indexBy |
|
| @@ 224-238 (lines=15) @@ | ||
| 221 | /** |
|
| 222 | * @return Mock|CraftFieldsService |
|
| 223 | */ |
|
| 224 | private function setMockFieldsService() |
|
| 225 | { |
|
| 226 | $mockFieldsService = $this->getMockBuilder(FieldsService::class) |
|
| 227 | ->disableOriginalConstructor() |
|
| 228 | ->getMock(); |
|
| 229 | ||
| 230 | $mockFieldsService->expects($this->any()) |
|
| 231 | ->method('getLayoutById') |
|
| 232 | ->with($this->isType('integer')) |
|
| 233 | ->willReturn($this->getMockFieldLayout()); |
|
| 234 | ||
| 235 | $this->setComponent(Craft::app(), 'fields', $mockFieldsService); |
|
| 236 | ||
| 237 | return $mockFieldsService; |
|
| 238 | } |
|
| 239 | ||
| 240 | /** |
|
| 241 | * @return Mock|fields |
|
| @@ 267-281 (lines=15) @@ | ||
| 264 | /** |
|
| 265 | * @return Mock|CategoriesService |
|
| 266 | */ |
|
| 267 | private function setMockCategoriesService() |
|
| 268 | { |
|
| 269 | $mockCategoriesService = $this->getMockBuilder(CategoriesService::class) |
|
| 270 | ->disableOriginalConstructor() |
|
| 271 | ->getMock(); |
|
| 272 | ||
| 273 | $mockCategoriesService->expects($this->any()) |
|
| 274 | ->method('getAllGroups') |
|
| 275 | ->with('handle') |
|
| 276 | ->willReturn([]); |
|
| 277 | ||
| 278 | $this->setComponent(Craft::app(), 'categories', $mockCategoriesService); |
|
| 279 | ||
| 280 | return $mockCategoriesService; |
|
| 281 | } |
|
| 282 | ||
| 283 | ||
| 284 | /** |
|