-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Minor fix to xajax stuff in listcontent
add a new test (now testing classes that use the database is possible) remove a few scripts we don't use. minor fix to cms_userprefs.
- Loading branch information
calguy1000
committed
Nov 23, 2012
1 parent
4fd77f3
commit 448dc16
Showing
8 changed files
with
142 additions
and
134 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<?php | ||
|
||
//require_once('cms_test_base.php'); | ||
require_once(CMSMS.'/lib/adodb_lite/adodb.inc.php'); | ||
|
||
function &cmsms() | ||
{ | ||
return CmsApp::get_instance(); | ||
} | ||
|
||
function cms_db_prefix() | ||
{ | ||
$config = cmsms()->GetConfig(); | ||
return $config['db_prefix']; | ||
} | ||
|
||
final class CmsApp | ||
{ | ||
private $_db; | ||
private static $_instance; | ||
|
||
public static function &get_instance() | ||
{ | ||
if( !self::$_instance ) { | ||
self::$_instance = new CmsApp; | ||
} | ||
return self::$_instance; | ||
} | ||
|
||
protected function __construct() | ||
{ | ||
} | ||
|
||
public function &GetDb() | ||
{ | ||
if( !$this->_db ) { | ||
$config = $this->GetConfig(); | ||
$this->_db = ADONewConnection('mysqli','pear:date:extend'); | ||
$r = $this->_db->Connect($config['db_host'],$config['db_user'],$config['db_pass'],$config['db_name']); | ||
if( !$r ) { | ||
$str = "Attempt to connect to database {$config['db_name']} on {$config['db_user']}@{$config['db_host']} failed"; | ||
throw new Exception($str); | ||
} | ||
$this->_db->SetFetchMode(ADODB_FETCH_ASSOC); | ||
} | ||
return $this->_db; | ||
} | ||
|
||
public function GetConfig() | ||
{ | ||
global $test_settings; | ||
return $test_settings; | ||
} | ||
|
||
|
||
} // end of class | ||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<?php | ||
|
||
require_once('class.CmsApp.pseudo.php'); | ||
require_once(CMSMS.'/lib/classes/class.cms_siteprefs.php'); | ||
|
||
class Test_cms_siteprefs extends UnitTestCase | ||
{ | ||
public function setUp() | ||
{ | ||
parent::setUp(); | ||
|
||
$config = cmsms()->GetConfig(); | ||
$dbdict = NewDataDictionary(cmsms()->GetDb()); | ||
$taboptarray = array('mysql' => 'ENGINE MyISAM CHARACTER SET utf8 COLLATE utf8_general_ci', | ||
'mysqli' => 'ENGINE MyISAM CHARACTER SET utf8 COLLATE utf8_general_ci'); | ||
|
||
$flds = " | ||
sitepref_name C(255) KEY, | ||
sitepref_value text, | ||
create_date DT, | ||
modified_date DT | ||
"; | ||
$sqlarray = $dbdict->CreateTableSQL($config['db_prefix'].'siteprefs', $flds, $taboptarray); | ||
$return = $dbdict->ExecuteSQLArray($sqlarray); | ||
} | ||
|
||
public function tearDown() | ||
{ | ||
$config = cmsms()->GetConfig(); | ||
$dbdict = NewDataDictionary(cmsms()->GetDb()); | ||
$sqlarray = $dbdict->DropTableSQL($config['db_prefix'].'siteprefs'); | ||
$return = $dbdict->ExecuteSQLArray($sqlarray); | ||
} | ||
|
||
public function TestSetGet1() | ||
{ | ||
cms_siteprefs::set('test1','val1'); | ||
cms_siteprefs::set('test2','val2'); | ||
$this->assertEqual(cms_siteprefs::get('test1'),'val1'); | ||
} | ||
|
||
public function TestExists() | ||
{ | ||
$this->assertTrue(cms_siteprefs::exists('test1')); | ||
} | ||
|
||
public function TestRemove() | ||
{ | ||
cms_siteprefs::remove('test2'); | ||
$this->assertFalse(cms_siteprefs::exists('test2')); | ||
} | ||
|
||
public function TestExists2() | ||
{ | ||
cms_siteprefs::set('test1',''); | ||
$this->assertTrue(cms_siteprefs::exists('test1')); | ||
|
||
cms_siteprefs::set('test1',null); | ||
$this->assertTrue(cms_siteprefs::exists('test1')); | ||
} | ||
} // end of class | ||
?> |