From 04acd3d6b9a95ff49d430eaf4f65aabc25282d88 Mon Sep 17 00:00:00 2001 From: Yuriy Andamasov Date: Fri, 22 May 2026 10:56:29 +0300 Subject: Engine: Add setVersion() with strict validation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Engine accepts only versions 7 and above (covering ES 7.x, 8.x, and OpenSearch 1.x/2.x/3.x via the typeless API). Anything below 7 raises with a clear message pointing at the bundled engine for ES 5 users. 🤖 Generated by [robots](https://vyos.io) --- ...SElasticModernFulltextStorageEngineTestCase.php | 38 ++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 src/__tests__/VyOSElasticModernFulltextStorageEngineTestCase.php (limited to 'src/__tests__/VyOSElasticModernFulltextStorageEngineTestCase.php') diff --git a/src/__tests__/VyOSElasticModernFulltextStorageEngineTestCase.php b/src/__tests__/VyOSElasticModernFulltextStorageEngineTestCase.php new file mode 100644 index 0000000..7a41ca1 --- /dev/null +++ b/src/__tests__/VyOSElasticModernFulltextStorageEngineTestCase.php @@ -0,0 +1,38 @@ +setVersion($v); + } catch (Exception $e) { + $caught = $e; + } + $this->assertEqual( + null, + $caught, + pht('Expected no exception for version=%d.', $v)); + $this->assertEqual($v, $engine->getVersion()); + } + } + + public function testSetVersionRejectsBelowSeven() { + foreach (array(0, 1, 2, 5, 6) as $v) { + $engine = new VyOSElasticModernFulltextStorageEngine(); + $caught = null; + try { + $engine->setVersion($v); + } catch (Exception $e) { + $caught = $e; + } + $this->assertTrue( + $caught !== null, + pht('Expected an exception for version=%d.', $v)); + } + } + +} -- cgit v1.2.3