summaryrefslogtreecommitdiff
path: root/src/__tests__/VyOSElasticModernFulltextStorageEngineTestCase.php
diff options
context:
space:
mode:
authorYuriy Andamasov <yuriy@vyos.io>2026-05-23 13:31:46 +0300
committerYuriy Andamasov <yuriy@vyos.io>2026-05-23 13:31:46 +0300
commitde83584f8b782bde516d6b39f9f1bc4214585058 (patch)
treeef210a295958021e0c3f2c078aec6d415d92c35c /src/__tests__/VyOSElasticModernFulltextStorageEngineTestCase.php
parentb05490e9be22d8e9ac576ac62b646ddd9b5f3ffe (diff)
downloadphorge-elasticsearch-modern-de83584f8b782bde516d6b39f9f1bc4214585058.tar.gz
phorge-elasticsearch-modern-de83584f8b782bde516d6b39f9f1bc4214585058.zip
E5 fixup: detect intra-key duplicates in buildIndexMappings(); add collision tests
🤖 Generated by [robots](https://vyos.io)
Diffstat (limited to 'src/__tests__/VyOSElasticModernFulltextStorageEngineTestCase.php')
-rw-r--r--src/__tests__/VyOSElasticModernFulltextStorageEngineTestCase.php56
1 files changed, 56 insertions, 0 deletions
diff --git a/src/__tests__/VyOSElasticModernFulltextStorageEngineTestCase.php b/src/__tests__/VyOSElasticModernFulltextStorageEngineTestCase.php
index 979c419..e3daab4 100644
--- a/src/__tests__/VyOSElasticModernFulltextStorageEngineTestCase.php
+++ b/src/__tests__/VyOSElasticModernFulltextStorageEngineTestCase.php
@@ -180,4 +180,60 @@ final class VyOSElasticModernFulltextStorageEngineTestCase
$mappings['properties']['lastModified']['type']);
}
+ public function testBuildIndexMappingsRejectsReservedFieldName() {
+ $engine = $this->newEngine()->setVersion(7);
+ $caught = null;
+ try {
+ $engine->buildIndexMappings(
+ array(), array('documentType'), array(), 'text');
+ } catch (Exception $e) {
+ $caught = $e;
+ }
+ $this->assertTrue(
+ $caught !== null,
+ pht('Expected exception when field name collides with reserved key.'));
+ }
+
+ public function testBuildIndexMappingsRejectsReservedRelationshipName() {
+ $engine = $this->newEngine()->setVersion(7);
+ $caught = null;
+ try {
+ $engine->buildIndexMappings(
+ array(), array(), array('lastModified'), 'text');
+ } catch (Exception $e) {
+ $caught = $e;
+ }
+ $this->assertTrue(
+ $caught !== null,
+ pht('Expected exception when relationship name collides with reserved key.'));
+ }
+
+ public function testBuildIndexMappingsRejectsFooTsClash() {
+ // A field named "foo_ts" would clash with the timestamp slot auto-generated
+ // for a relationship named "foo".
+ $engine = $this->newEngine()->setVersion(7);
+ $caught = null;
+ try {
+ $engine->buildIndexMappings(
+ array(), array('foo_ts'), array('foo'), 'text');
+ } catch (Exception $e) {
+ $caught = $e;
+ }
+ $this->assertTrue(
+ $caught !== null,
+ pht('Expected exception for field/relationship timestamp-slot collision.'));
+ }
+
+ public function testBuildIndexMappingsEmptyInputsYieldStandardFields() {
+ $engine = $this->newEngine()->setVersion(7);
+ $mappings = $engine->buildIndexMappings(array(), array(), array(), 'text');
+ $this->assertTrue(isset($mappings['properties']['documentType']));
+ $this->assertTrue(isset($mappings['properties']['dateCreated']));
+ $this->assertTrue(isset($mappings['properties']['lastModified']));
+ $this->assertEqual(
+ 'keyword', $mappings['properties']['documentType']['type']);
+ $this->assertEqual('date', $mappings['properties']['dateCreated']['type']);
+ $this->assertEqual('date', $mappings['properties']['lastModified']['type']);
+ }
+
}