mirror of
https://github.com/Mibew/design.git
synced 2025-05-07 02:53:09 +03:00
68 lines
1.9 KiB
PHP
68 lines
1.9 KiB
PHP
<?php
|
|
|
|
require_once dirname(__FILE__) . '/../../../../webim/libs/classes/settings.php';
|
|
require_once dirname(__FILE__) . '/../../../../webim/libs/config.php';
|
|
require_once dirname(__FILE__) . '/../../../../webim/libs/classes/database.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() {
|
|
$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')
|
|
);
|
|
}
|
|
|
|
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);
|
|
}
|
|
|
|
}
|
|
|
|
?>
|