summaryrefslogtreecommitdiff
path: root/vendor/ruflin/elastica/test/lib/Elastica/Test/Index/StatusTest.php
blob: 24f22ffd6ed95b2dc92f2760949fbe5f8d4bb74b (plain)
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<?php
namespace Elastica\Test\Index;

use Elastica\Index\Status as IndexStatus;
use Elastica\Test\Base as BaseTest;

class StatusTest extends BaseTest
{
    /**
     * @group functional
     */
    public function testGetAliases()
    {
        $indexName = 'test';
        $aliasName = 'test-alias';

        $client = $this->_getClient();
        $index = $client->getIndex($indexName);
        $index->create(array(), true);

        $status = new IndexStatus($index);

        $aliases = $status->getAliases();

        $this->assertTrue(empty($aliases));
        $this->assertInternalType('array', $aliases);

        $index->addAlias($aliasName);
        $status->refresh();

        $aliases = $status->getAliases();

        $this->assertTrue(in_array($aliasName, $aliases));
    }

    /**
     * @group functional
     */
    public function testHasAlias()
    {
        $indexName = 'test';
        $aliasName = 'test-alias';

        $client = $this->_getClient();
        $index = $client->getIndex($indexName);
        $index->create(array(), true);

        $status = new IndexStatus($index);

        $this->assertFalse($status->hasAlias($aliasName));

        $index->addAlias($aliasName);
        $status->refresh();

        $this->assertTrue($status->hasAlias($aliasName));
    }

    /**
     * @group functional
     */
    public function testGetSettings()
    {
        $indexName = 'test';

        $client = $this->_getClient();
        $index = $client->getIndex($indexName);
        $index->create(array(), true);
        $status = $index->getStatus();

        $settings = $status->getSettings();
        $this->assertInternalType('array', $settings);
        $this->assertTrue(isset($settings['index']['number_of_shards']));
    }
}