Skip to content

Commit 1af4f22

Browse files
committed
Added unit tests for CloudId examples
1 parent 7a9d26b commit 1af4f22

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

tests/Elasticsearch/Tests/ClientBuilderTest.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,4 +170,27 @@ public function testNotIncludePortInHostHeader()
170170
$this->assertEquals($host, $request['request']['headers']['Host'][0]);
171171
}
172172
}
173+
174+
public function getCloudIdExamples()
175+
{
176+
return [
177+
['cluster:d2VzdGV1cm9wZS5henVyZS5lbGFzdGljLWNsb3VkLmNvbTo5MjQzJGM2NjM3ZjMxMmM1MjQzY2RhN2RlZDZlOTllM2QyYzE5JA==', 'c6637f312c5243cda7ded6e99e3d2c19.westeurope.azure.elastic-cloud.com:9243'],
178+
['cluster:d2VzdGV1cm9wZS5henVyZS5lbGFzdGljLWNsb3VkLmNvbSRlN2RlOWYxMzQ1ZTQ0OTAyODNkOTAzYmU1YjZmOTE5ZSQ=', 'e7de9f1345e4490283d903be5b6f919e.westeurope.azure.elastic-cloud.com'],
179+
['cluster:d2VzdGV1cm9wZS5henVyZS5lbGFzdGljLWNsb3VkLmNvbSQ4YWY3ZWUzNTQyMGY0NThlOTAzMDI2YjQwNjQwODFmMiQyMDA2MTU1NmM1NDA0OTg2YmZmOTU3ZDg0YTZlYjUxZg==', '8af7ee35420f458e903026b4064081f2.westeurope.azure.elastic-cloud.com']
180+
];
181+
}
182+
183+
/**
184+
* @dataProvider getCloudIdExamples
185+
*/
186+
public function testSetCloudIdWithExplicitPortOnlyES_UUID(string $cloudId, string $url)
187+
{
188+
$client = ClientBuilder::create()
189+
->setElasticCloudId($cloudId)
190+
->build();
191+
192+
$connection = $client->transport->getConnection();
193+
194+
$this->assertEquals($url, $connection->getHost());
195+
}
173196
}

0 commit comments

Comments
 (0)