mirror of
https://github.com/Mibew/mibew.git
synced 2025-04-11 10:20:12 +03:00
81 lines
2.3 KiB
PHP
81 lines
2.3 KiB
PHP
<?php
|
|
|
|
require_once dirname(__FILE__) . '/../../../../../mibew/libs/classes/settings.php';
|
|
require_once dirname(__FILE__) . '/../../../../../mibew/libs/classes/database.php';
|
|
require_once dirname(__FILE__) . '/../config.php';
|
|
|
|
/**
|
|
* Test class for Settings.
|
|
* Generated by PHPUnit on 2012-07-16 at 15:07:10.
|
|
*/
|
|
class SettingsTest extends PHPUnit_Framework_TestCase {
|
|
|
|
public static function setUpBeforeClass() {
|
|
global $db_host, $db_name, $db_user, $db_pass, $tables_prefix,
|
|
$db_encoding, $force_charset_in_connection, $use_persistent_connection;
|
|
Database::initialize(
|
|
$db_host,
|
|
$db_user,
|
|
$db_pass,
|
|
$use_persistent_connection,
|
|
$db_name,
|
|
$tables_prefix,
|
|
$force_charset_in_connection,
|
|
$db_encoding
|
|
);
|
|
$db = Database::getInstance();
|
|
$db->query(
|
|
"INSERT INTO {chatconfig} (vckey, vcvalue) " .
|
|
"VALUES (?, ?)",
|
|
array('some_test_key', 'some_test_value')
|
|
);
|
|
}
|
|
|
|
public static function tearDownAfterClass() {
|
|
$db = Database::getInstance();
|
|
$db->query(
|
|
"DELETE FROM {chatconfig} WHERE vckey = ? OR vckey = ?",
|
|
array('some_test_key', 'some_another_test_key')
|
|
);
|
|
Database::destroy();
|
|
}
|
|
|
|
public function testGet() {
|
|
$this->assertEquals('some_test_value', Settings::get('some_test_key'));
|
|
}
|
|
|
|
public function testSet() {
|
|
Settings::set('some_test_key', 'some_another_value');
|
|
$this->assertEquals('some_another_value', Settings::get('some_test_key'));
|
|
Settings::set('some_test_key', 'some_test_value');
|
|
}
|
|
|
|
public function testUpdate() {
|
|
$db = Database::getInstance();
|
|
Settings::set('some_test_key', 'some_value_for_update');
|
|
Settings::set('some_another_test_key', 'some_another_value_for_update');
|
|
Settings::update();
|
|
list($count) = $db->query(
|
|
"SELECT COUNT(*) FROM {chatconfig} WHERE vckey = ? AND vcvalue = ?",
|
|
array('some_test_key', 'some_value_for_update'),
|
|
array(
|
|
'return_rows' => Database::RETURN_ONE_ROW,
|
|
'fetch_type' => Database::FETCH_NUM
|
|
)
|
|
);
|
|
$this->assertEquals(1, $count);
|
|
list($count) = $db->query(
|
|
"SELECT COUNT(*) FROM {chatconfig} WHERE vckey = ? AND vcvalue = ?",
|
|
array('some_another_test_key', 'some_another_value_for_update'),
|
|
array(
|
|
'return_rows' => Database::RETURN_ONE_ROW,
|
|
'fetch_type' => Database::FETCH_NUM
|
|
)
|
|
);
|
|
$this->assertEquals(1, $count);
|
|
}
|
|
|
|
}
|
|
|
|
?>
|