Skip to content

Commit

Permalink
fixed filterNameSchema method, updated the test
Browse files Browse the repository at this point in the history
  • Loading branch information
Sztig committed Nov 4, 2024
1 parent b10e48c commit 2eb1790
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
5 changes: 5 additions & 0 deletions src/lib/Repository/NameSchema/NameSchemaService.php
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,11 @@ protected function filterNameSchema(string $nameSchema): array
if ($foundGroups) {
$i = 0;
foreach ($groupArray[1] as $group) {
// Skip the group if it has no fields to parse
if (!preg_match('/<.*>/', $group)) {
continue;
}

// Create meta-token for group
$metaToken = self::META_STRING . $i;

Expand Down
16 changes: 8 additions & 8 deletions tests/lib/Repository/NameSchema/NameSchemaServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,13 @@ public static function getDataForTestResolveNameSchema(): iterable
yield 'Default: Field Map and Languages taken from Content Version' => [
[],
[
'eng-GB' => ['text2' => 'two'],
'cro-HR' => ['text2' => 'dva'],
'eng-GB' => ['text1' => 'one', 'text2' => 'two'],
'cro-HR' => ['text1' => 'jedan', 'text2' => 'dva'],
],
[],
[
'eng-GB' => 'two',
'cro-HR' => 'dva',
'eng-GB' => 'one - two (testString)',
'cro-HR' => 'jedan - dva (testString)',
],
];

Expand All @@ -98,8 +98,8 @@ public static function getDataForTestResolveNameSchema(): iterable
],
['eng-GB', 'cro-HR'],
[
'eng-GB' => 'three',
'cro-HR' => 'Dva',
'eng-GB' => 'three (testString)',
'cro-HR' => ' - Dva (testString)',
],
];
}
Expand All @@ -119,11 +119,11 @@ public function testResolveNameSchema(
array $expectedNames
): void {
$content = $this->buildTestContentObject();
$nameSchema = '<text3|text2>';
$nameSchema = '<text3|(<text1> - <text2>)> (testString)';
$contentType = $this->buildTestContentTypeStub($nameSchema, $nameSchema);
$event = new ResolveContentNameSchemaEvent(
$content,
['field' => ['text3', 'text2']],
['field' => ['text3', 'text2', 'text1']],
$contentType,
$fieldMap,
$languageCodes
Expand Down

0 comments on commit 2eb1790

Please sign in to comment.