Skip to content

Commit 5a9bee7

Browse files
committed
IBX-10289: updated tests
1 parent 099b241 commit 5a9bee7

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,9 @@ private function getImageConfig(): array
107107

108108
// The content type may not have the default fields; in that case, don't add the aggregations
109109
$imageType = $this->contentTypeService->loadContentType(self::IMAGE_TYPE_ID);
110-
foreach ($this->config['image']['aggregations'] as $aggregation) {
110+
foreach ($this->config['image']['aggregations'] as $key => $aggregation) {
111111
if ($imageType->hasFieldDefinition($aggregation['fieldDefinitionIdentifier'])) {
112-
$imageConfig['aggregations'][] = $aggregation;
112+
$imageConfig['aggregations'][$key] = $aggregation;
113113
}
114114
}
115115

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

Lines changed: 14 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,19 @@ private function mockContentTypeServiceLoadContentTypeByIdentifier(array $valueM
263264
->willReturnMap($valueMap);
264265
}
265266

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

0 commit comments

Comments
 (0)