<?php

/**
 * @author Anton Terekhov <anton@netmonsters.ru>
 * @copyright Copyright Anton Terekhov, NetMonsters LLC, 2011-2012
 * @license https://github.com/AntonTerekhov/OrientDB-PHP/blob/master/LICENSE
 * @link https://github.com/AntonTerekhov/OrientDB-PHP
 * @package OrientDB-PHP
 */

require_once 'OrientDB/OrientDB.php';
require_once 'OrientDB_TestCase.php';

/**
 * DBOpen() test in OrientDB tests
 *
 * @author Anton Terekhov <anton@netmonsters.ru>
 * @package OrientDB-PHP
 * @subpackage Tests
 */
class OrientDBDBOpenTest extends OrientDB_TestCase
{

    protected function setUp()
    {
        $this->db = new OrientDB('localhost', 2424);
    }

    protected function tearDown()
    {
        $this->db = null;
    }

    public function testDBOpen()
    {
        $config = $this->db->DBOpen('demo', 'admin', 'admin');
        $this->assertInternalType('array', $config);
        $this->assertArrayHasKey('clusters', $config);
        $this->assertInternalType('array', $config['clusters']);
        $this->assertArrayHasKey('config', $config);

        $cluster = $config['clusters'][0];
        $this->assertInstanceOf('StdClass', $cluster);
        $this->assertAttributeInternalType('string', 'name', $cluster);
        $this->assertAttributeInternalType('integer', 'id', $cluster);
        $this->assertAttributeInternalType('string', 'type', $cluster);
        $this->assertAttributeInternalType('integer', 'datasegmentid', $cluster);
    }
}