Skip to content

Commit 0282d85

Browse files
committed
IBX-10289: updated tests
1 parent 099b241 commit 0282d85

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

src/lib/UI/Config/Provider/Module/DamWidget.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,14 +102,15 @@ private function getImageConfig(): array
102102
{
103103
$imageConfig = [
104104
'showImageFilters' => $this->showImageFilters(),
105+
'aggregations' => [],
105106
'enableMultipleDownload' => extension_loaded('zip'),
106107
];
107108

108109
// The content type may not have the default fields; in that case, don't add the aggregations
109110
$imageType = $this->contentTypeService->loadContentType(self::IMAGE_TYPE_ID);
110-
foreach ($this->config['image']['aggregations'] as $aggregation) {
111+
foreach ($this->config['image']['aggregations'] as $key => $aggregation) {
111112
if ($imageType->hasFieldDefinition($aggregation['fieldDefinitionIdentifier'])) {
112-
$imageConfig['aggregations'][] = $aggregation;
113+
$imageConfig['aggregations'][$key] = $aggregation;
113114
}
114115
}
115116

tests/lib/UI/Config/Provider/Module/DamWidgetTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ public function testGetConfig(
137137
$this->mockRepositoryConfigurationProviderGetRepositoryConfig($repositoryConfig);
138138
$this->mockContentTypeServiceLoadContentTypeByIdentifier($loadContentTypeValueMap);
139139
$this->mockSchemaIdentifierExtractorExtract($extractSchemaIdentifiersValueMap);
140+
$this->mockContentTypeServiceLoadContentType();
140141

141142
self::assertEquals(
142143
$expectedConfiguration,
@@ -263,6 +264,16 @@ private function mockContentTypeServiceLoadContentTypeByIdentifier(array $valueM
263264
->willReturnMap($valueMap);
264265
}
265266

267+
private function mockContentTypeServiceLoadContentType(): void
268+
{
269+
$contetnType = $this->createMock(ContentType::class);
270+
$contetnType->method('hasFieldDefinition')->willReturn(true);
271+
272+
$this->contentTypeService
273+
->method('loadContentType')
274+
->willReturn($contetnType);
275+
}
276+
266277
/**
267278
* @param array<array{string|array<string>}> $valueMap
268279
*/

0 commit comments

Comments
 (0)