ElasticSearchConnectionTest.php 752 Bytes
Newer Older
1 2 3 4
<?php

namespace yiiunit\extensions\elasticsearch;

5
use yii\elasticsearch\Connection;
6 7 8 9 10 11

/**
 * @group elasticsearch
 */
class ElasticSearchConnectionTest extends ElasticSearchTestCase
{
12 13
	public function testOpen()
	{
14
		$connection = new Connection();
15 16 17 18 19 20 21 22 23 24 25 26
		$connection->autodetectCluster;
		$connection->nodes = [
			['http_address' => 'inet[/127.0.0.1:9200]'],
		];
		$this->assertNull($connection->activeNode);
		$connection->open();
		$this->assertNotNull($connection->activeNode);
		$this->assertArrayHasKey('name', reset($connection->nodes));
		$this->assertArrayHasKey('hostname', reset($connection->nodes));
		$this->assertArrayHasKey('version', reset($connection->nodes));
		$this->assertArrayHasKey('http_address', reset($connection->nodes));
	}
27 28

}