-
-
Notifications
You must be signed in to change notification settings - Fork 251
/
Copy pathConnectionTest.php
44 lines (34 loc) · 1.43 KB
/
ConnectionTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
namespace yiiunit\extensions\elasticsearch;
use yii\elasticsearch\Connection;
/**
* @group elasticsearch
*/
class ConnectionTest extends TestCase
{
/**
* @var Connection
*/
private $connection;
protected function setUp(): void
{
parent::setUp();
$this->connection = $this->getConnection();
}
public function testCreateUrl()
{
$reflectedMethod = new \ReflectionMethod($this->connection, 'createUrl');
$reflectedMethod->setAccessible(true);
$protocol = $this->connection->nodes[$this->connection->activeNode]['protocol'];
$httpAddress = $this->connection->nodes[$this->connection->activeNode]['http_address'];
$this->assertEquals([$protocol, $httpAddress, ''], $reflectedMethod->invoke($this->connection, []));
$this->assertEquals([$protocol, $httpAddress, '_cat/indices'],
$reflectedMethod->invoke($this->connection, '_cat/indices'));
$this->assertEquals([$protocol, $httpAddress, 'customer'],
$reflectedMethod->invoke($this->connection, 'customer'));
$this->assertEquals([$protocol, $httpAddress, 'customer/external/1'],
$reflectedMethod->invoke($this->connection, ['customer', 'external', '1']));
$this->assertEquals([$protocol, $httpAddress, 'customer/external/1/_update'],
$reflectedMethod->invoke($this->connection, ['customer', 'external', 1, '_update',]));
}
}