diff options
| author | Yuriy Andamasov <yuriy@andamasov.com> | 2026-05-23 17:49:28 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-05-23 17:49:28 +0300 |
| commit | 422681512d98175eb558271589cf433c1c9a1020 (patch) | |
| tree | 00ad5372e564a0c332f7dc26abe9836681f9361e /src/__tests__/VyOSElasticModernHostTestCase.php | |
| parent | 49588447d6865c968143db7db1ab2b82b191e29e (diff) | |
| parent | 5a47a44b717a912bd22d7e03921521cfec49074e (diff) | |
| download | phorge-elasticsearch-modern-production.tar.gz phorge-elasticsearch-modern-production.zip | |
Merge pull request #16 from vyos/developmentHEADv0.1.0production
Release v0.1.0 — promote development to production
Diffstat (limited to 'src/__tests__/VyOSElasticModernHostTestCase.php')
| -rw-r--r-- | src/__tests__/VyOSElasticModernHostTestCase.php | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/src/__tests__/VyOSElasticModernHostTestCase.php b/src/__tests__/VyOSElasticModernHostTestCase.php new file mode 100644 index 0000000..8fcd9b6 --- /dev/null +++ b/src/__tests__/VyOSElasticModernHostTestCase.php @@ -0,0 +1,66 @@ +<?php + +final class VyOSElasticModernHostTestEngine + extends VyOSElasticModernFulltextStorageEngine { +} + +final class VyOSElasticModernHostTestCase + extends PhutilTestCase { + + public function testEngineIsConcreteForDispatch() { + // Must NOT be abstract: PhutilClassMapQuery → PhutilSymbolLoader::loadObjects() + // calls setConcreteOnly(true) which unsets abstract classes. A concrete (plain) + // class is required for cluster.search[].type:elasticsearch-modern dispatch. + $class = new ReflectionClass('VyOSElasticModernFulltextStorageEngine'); + $this->assertFalse($class->isAbstract()); + } + + public function testDisplayName() { + $engine = new VyOSElasticModernHostTestEngine(); + $host = new VyOSElasticModernHost($engine); + $this->assertEqual( + 'Elasticsearch (modern)', + (string)$host->getDisplayName()); + } + + public function testConfigDefaults() { + $engine = new VyOSElasticModernHostTestEngine(); + $host = new VyOSElasticModernHost($engine); + $host->setConfig(array()); + $this->assertEqual('http', $host->getProtocol()); + $this->assertEqual('phabricator/', $host->getPath()); + $this->assertEqual(7, $host->getVersion()); + } + + public function testConfigOverrides() { + $engine = new VyOSElasticModernHostTestEngine(); + $host = new VyOSElasticModernHost($engine); + $host->setConfig(array( + 'host' => 'es.example.com', + 'port' => 9200, + 'protocol' => 'https', + 'path' => '/myphorge', + 'version' => 8, + )); + $this->assertEqual('es.example.com', $host->getHost()); + $this->assertEqual(9200, $host->getPort()); + $this->assertEqual('https', $host->getProtocol()); + $this->assertEqual('/myphorge', $host->getPath()); + $this->assertEqual(8, $host->getVersion()); + } + + public function testGetURI() { + $engine = new VyOSElasticModernHostTestEngine(); + $host = new VyOSElasticModernHost($engine); + $host->setConfig(array( + 'host' => 'es.example.com', + 'port' => 9200, + 'protocol' => 'http', + 'path' => '/phabricator', + )); + $uri = (string)$host->getURI('/_doc/abc'); + $this->assertTrue(strpos($uri, 'es.example.com') !== false); + $this->assertTrue(strpos($uri, '/_doc/abc') !== false); + } + +} |
