-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathFieldNameGeneratorTest.php
More file actions
57 lines (45 loc) · 1.76 KB
/
FieldNameGeneratorTest.php
File metadata and controls
57 lines (45 loc) · 1.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<?php
/**
* @copyright Copyright (C) Ibexa AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/
declare(strict_types=1);
namespace Ibexa\Tests\Core\Search\Common;
use Ibexa\Contracts\Core\Search\FieldType;
use Ibexa\Core\Search\Common\FieldNameGenerator;
use PHPUnit\Framework\TestCase;
final class FieldNameGeneratorTest extends TestCase
{
public function testGetTypedNameUsesConfiguredMapping(): void
{
$generator = new FieldNameGenerator([
'ibexa_string' => 's',
]);
$fieldType = $this->createMock(FieldType::class);
$fieldType
->method('getType')
->willReturn('ibexa_string');
self::assertSame('title_s', $generator->getTypedName('title', $fieldType));
}
public function testGetTypedNameNormalizesEmbeddingFieldTypeWithoutExplicitMapping(): void
{
$generator = new FieldNameGenerator([], ['ibexa_dense_vector_']);
$fieldType = $this->createMock(FieldType::class);
$fieldType
->method('getType')
->willReturn('ibexa_dense_vector_gemini_embedding_001_1536_dv');
self::assertSame(
'taxonomy_embeddings_gemini_embedding_001_1536_dv',
$generator->getTypedName('taxonomy_embeddings', $fieldType)
);
}
public function testGetTypedNameReturnsOriginalTypeWhenNoFallbackPrefixMatches(): void
{
$generator = new FieldNameGenerator([], ['ibexa_dense_vector_']);
$fieldType = $this->createMock(FieldType::class);
$fieldType
->method('getType')
->willReturn('custom_type');
self::assertSame('foo_custom_type', $generator->getTypedName('foo', $fieldType));
}
}