ElasticSearchConnectionTest.php 838 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 14 15 16 17 18 19 20 21 22
    public function testOpen()
    {
        $connection = new Connection();
        $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));
23
//        $this->assertArrayHasKey('hostname', reset($connection->nodes));
24 25 26
        $this->assertArrayHasKey('version', reset($connection->nodes));
        $this->assertArrayHasKey('http_address', reset($connection->nodes));
    }
AlexGx committed
27
}