summaryrefslogtreecommitdiff
path: root/vendor/ruflin/elastica/test/lib/Elastica/Test/Node/InfoTest.php
blob: 812f141e99b3e5b072d1e12ef7e408c6bf00ef74 (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
75
76
77
78
79
<?php
namespace Elastica\Test\Node;

use Elastica\Node;
use Elastica\Node\Info as NodeInfo;
use Elastica\Test\Base as BaseTest;

class InfoTest extends BaseTest
{
    /**
     * @group functional
     */
    public function testGet()
    {
        $client = $this->_getClient();
        $names = $client->getCluster()->getNodeNames();
        $name = reset($names);

        $node = new Node($name, $client);
        $info = new NodeInfo($node);

        $this->assertNull($info->get('os', 'mem', 'total'));

        // Load os infos
        $info = new NodeInfo($node, array('os'));

        $this->assertNotNull($info->get('os', 'mem', 'total_in_bytes'));
        $this->assertInternalType('array', $info->get('os', 'mem'));
        $this->assertNull($info->get('test', 'notest', 'notexist'));
    }

    /**
     * @group functional
     */
    public function testHasPlugin()
    {
        $client = $this->_getClient();
        $nodes = $client->getCluster()->getNodes();
        $node = $nodes[0];
        $info = $node->getInfo();

        $pluginName = 'mapper-attachments';

        $this->assertTrue($info->hasPlugin($pluginName));
        $this->assertFalse($info->hasPlugin('foo'));
    }

    /**
     * @group functional
     */
    public function testGetId()
    {
        $client = $this->_getClient();
        $nodes = $client->getCluster()->getNodes();

        $ids = array();

        foreach ($nodes as $node) {
            $id = $node->getInfo()->getId();

            // Checks that the ids are unique
            $this->assertFalse(in_array($id, $ids));
            $ids[] = $id;
        }
    }

    /**
     * @group functional
     */
    public function testGetName()
    {
        $client = $this->_getClient();
        $nodes = $client->getCluster()->getNodes();

        foreach ($nodes as $node) {
            $this->assertEquals('Elastica', $node->getInfo()->getName());
        }
    }
}