Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions src/Migration/Mapping/Lookup/LanguageLookup.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,6 @@ public function get(string $localeCode, Context $context): ?string

$language = $this->getLanguage($localeUuid, $context);
if (!$language instanceof LanguageEntity) {
$this->cache[$localeCode] = null;

return null;
}

Expand Down
49 changes: 49 additions & 0 deletions tests/Migration/Mapping/Lookup/LanguageLookupTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,55 @@ public function testGetShouldGetDataFromCache(string $localeCode, ?string $expec
static::assertSame($expectedResult, $documentTypeLookup->get($localeCode, Context::createDefaultContext()));
}

public function testGetDoesNotCacheMissingLanguage(): void
{
$context = Context::createDefaultContext();

$languageRepository = static::getContainer()->get('language.repository');
$localeRepository = static::getContainer()->get('locale.repository');

$localeId = Uuid::randomHex();
$localeCode = 'en-US-' . Uuid::randomHex();
$languageId = Uuid::randomHex();

try {
$localeRepository->create([
[
'id' => $localeId,
'code' => $localeCode,
'name' => 'Test Locale',
'territory' => 'Test Territory',
],
], $context);

$languageLookup = new LanguageLookup(
$languageRepository,
new LocaleLookup($localeRepository)
);

static::assertNull($languageLookup->get($localeCode, $context));

$languageRepository->create([
[
'id' => $languageId,
'name' => 'Test language',
'localeId' => $localeId,
'translationCodeId' => $localeId,
],
], $context);

static::assertSame($languageId, $languageLookup->get($localeCode, $context));
} finally {
$languageRepository->delete([
['id' => $languageId],
], $context);

$localeRepository->delete([
['id' => $localeId],
], $context);
}
}

#[DataProvider('getLanguageIdData')]
public function testGetDefaultLanguageEntity(string $languageId, ?string $expectedResult): void
{
Expand Down
Loading