<commit_before><?php

require_once 'OrientDB/OrientDB.php';

class OrientDBConfigSetTest extends PHPUnit_Framework_TestCase
{

    /**
     * Correct password for root can be found at
     * config/orientdb-server-config.xml in your OrientDB installation
     */
    protected $root_password = '<PASSWORD>';

    protected $db;

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

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

    public function testConfigSetOnNotConnectedDB() {
        $this->setExpectedException('OrientDBWrongCommandException');
        $result = $this->db->configSet('log.console.level', 'info');
    }

    public function testConfigSetOnConnectedDB() {
        $this->db->connect('root', $this->root_password);
        $result = $this->db->configSet('log.console.level', 'info');
        $this->assertTrue($result);
    }

    public function testConfigSetOnNotOpenDB() {
        $this->setExpectedException('OrientDBWrongCommandException');
        $result = $this->db->configSet('log.console.level', 'info');
    }

    public function testConfigSetOnOpenDB() {
        $this->db->DBOpen('demo', 'writer', 'writer');
        $this->setExpectedException('OrientDBWrongCommandException');
        $result = $this->db->configSet('log.console.level', 'info');
    }

    public function testConfigSetWithWrongOption() {
        $this->db->connect('root', $this->root_password);
        $result = $this->db->configSet('NONEXISTENT', 'info');
        $this->assertTrue($result);
    }

    public function testConfigSetWithWrongOptionCount() {
        $this->db->connect('root', $this->root_password);
        $this->setExpectedException('OrientDBWrongParamsException');
        $result = $this->db->configSet();
    }

    public function testConfigSetWithNoValue() {
        $this->db->connect('root', $this->root_password);
        $this->setExpectedException('OrientDBWrongParamsException');
        $result = $this->db->configSet('log.console.level');
    }

    public function testConfigSetWithWrongValue() {
        $this->db->connect('root', $this->root_password);
        $this->setExpectedException('OrientDBException');
        $result = $this->db->configSet('log.console.level', 'WRONGVALUE');
    }

    public function testConfigSetWithCorrectValue() {
        $this->db->connect('root', $this->root_password);
        $option = 'log.console.level';
        $value = 'warning';
        $result = $this->db->configSet($option, $value);
        $dbvalue = $this->db->configGet($option);
        $this->assertEquals($value, $dbvalue);
        // Return log level to info
        $result = $this->db->configSet($option, 'info');
    }
}<commit_msg>Test for returning "info" value #0<commit_after><?php

require_once 'OrientDB/OrientDB.php';

class OrientDBConfigSetTest extends PHPUnit_Framework_TestCase
{

    /**
     * Correct password for root can be found at
     * config/orientdb-server-config.xml in your OrientDB installation
     */
    protected $root_password = '<PASSWORD>';

    protected $db;

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

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

    public function testConfigSetOnNotConnectedDB() {
        $this->setExpectedException('OrientDBWrongCommandException');
        $result = $this->db->configSet('log.console.level', 'info');
    }

    public function testConfigSetOnConnectedDB() {
        $this->db->connect('root', $this->root_password);
        $result = $this->db->configSet('log.console.level', 'info');
        $this->assertTrue($result);
    }

    public function testConfigSetOnNotOpenDB() {
        $this->setExpectedException('OrientDBWrongCommandException');
        $result = $this->db->configSet('log.console.level', 'info');
    }

    public function testConfigSetOnOpenDB() {
        $this->db->DBOpen('demo', 'writer', 'writer');
        $this->setExpectedException('OrientDBWrongCommandException');
        $result = $this->db->configSet('log.console.level', 'info');
    }

    public function testConfigSetWithWrongOption() {
        $this->db->connect('root', $this->root_password);
        $result = $this->db->configSet('NONEXISTENT', 'info');
        $this->assertTrue($result);
    }

    public function testConfigSetWithWrongOptionCount() {
        $this->db->connect('root', $this->root_password);
        $this->setExpectedException('OrientDBWrongParamsException');
        $result = $this->db->configSet();
    }

    public function testConfigSetWithNoValue() {
        $this->db->connect('root', $this->root_password);
        $this->setExpectedException('OrientDBWrongParamsException');
        $result = $this->db->configSet('log.console.level');
    }

    public function testConfigSetWithWrongValue() {
        $this->db->connect('root', $this->root_password);
        $this->setExpectedException('OrientDBException');
        $result = $this->db->configSet('log.console.level', 'WRONGVALUE');
    }

    public function testConfigSetWithCorrectValue() {
        $this->db->connect('root', $this->root_password);
        $option = 'log.console.level';
        $startvalue = 'info';
        $value = 'warning';
        $result = $this->db->configSet($option, $value);
        $dbvalue = $this->db->configGet($option);
        $this->assertEquals($value, $dbvalue);
        // Return log level to info
        $result = $this->db->configSet($option, 'info');
        $returnvalue = $this->db->configGet($option);
        $this->assertEquals($startvalue, $returnvalue);
    }
}
{'fraction_non_alphanumeric': 0.16002832359709684, 'fraction_numerical': 0.0015932023366967605, 'mean_word_length': 3.309687261632342, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 114, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7043412', 'n_tokens_mistral': 1650, 'n_tokens_neox': 1628, 'n_words': 267}