*
* @return array List of timezones
*/
- public static function fetch_time_zone_list()
+ public static function fetch_timezone_list()
{
$opt = array();
require_once 'PHPUnit/Framework.php';
require_once ISSO . '/Api.php';
+require_once ISSO . '/DbMySql.php';
/**
* ApiTest
public function setUp()
{
- $this->db = BSApp::LoadModule('DbMySql');
+ BSApp::$db = $this->db = new BSDbMySql();
$this->db->connect(TEST_DB_MYSQL_HOST, TEST_DB_MYSQL_USER, TEST_DB_MYSQL_PASSWORD, TEST_DB_MYSQL_DATABASE);
$this->fixture = new TestApiFixture();
require_once ISSO . '/App.php';
}
- public function testLoadModule()
- {
- $this->assertTrue(BSApp::LoadModule('Input') instanceof BSInput);
- }
-
- public function testLoadBadModule()
- {
- try
- {
- BSApp::LoadModule('nonExistentModule');
- $this->fail('exception expected');
- }
- catch (Exception $e)
- {}
- }
-
- public function testSetGetAppPath()
- {
- BSApp::SetAppPath(getcwd());
- $this->assertEquals(getcwd() . DIRECTORY_SEPARATOR, BSApp::GetAppPath());
- }
-
- public function testSetGetAppVersion()
- {
- BSApp::SetAppVersion('1.0-test');
- $this->assertEquals('1.0-test', BSApp::GetAppVersion());
- }
-
- public function testSetGetApplication()
- {
- BSApp::SetApplication('ISSO Tests');
- $this->assertEquals('ISSO Tests', BSApp::GetApplication());
- }
-
- public function testSetGetWebPath()
- {
- $path = DIRECTORY_SEPARATOR . 'Server' . DIRECTORY_SEPARATOR . 'htdocs' . DIRECTORY_SEPARATOR . 'ISSO';
- BSApp::SetWebPath($path);
- $this->assertEquals($path . DIRECTORY_SEPARATOR, BSApp::GetWebPath());
- }
-
public function testSetGetDebug()
{
- BSApp::SetDebug(true);
- $this->assertSame(true, BSApp::GetDebug());
+ BSApp::set_debug(true);
+ $this->assertSame(true, BSApp::get_debug());
}
public function testDebugList()
{
- $this->assertEquals('<select><option>Debug Notices (0)</option></select>', BSApp::GetDebugList());
-
- BSApp::Debug('dbg');
- $this->assertEquals('<select><option>Debug Notices (1)</option><option>--- dbg</option></select>', BSApp::GetDebugList());
- }
-
- public function testRegisterValue()
- {
- BSApp::Registry()->someKey = 'someValue';
-
- $registry = BSApp::Registry();
- $this->assertEquals($registry->someKey, 'someValue');
- }
-
- public function testGetAll()
- {
- BSApp::Registry()->test = 1;
- $this->assertType('array', BSApp::Registry()->allObjects());
- $this->assertSame(sizeof(BSApp::Registry()->allObjects()), 3);
- }
-
- public function testOverWriteRegister()
- {
- BSApp::Registry()->valueToOverWrite = 1;
- BSApp::Registry()->valueToOverWrite = 2;
- $this->assertEquals(2, BSApp::Registry()->valueToOverWrite);
- }
-
- public function testGet()
- {
- BSApp::Registry()->testGet = 123;
- $this->assertEquals(123, BSApp::Registry()->testGet);
- }
-
- public function testUnregister()
- {
- BSApp::Registry()->testUnregister = 1;
- unset(BSApp::Registry()->testUnregister);
- $this->assertObjectNotHasAttribute('testUnregister', BSApp::Registry());
- }
-
- public function testGetNoExist()
- {
- try
- {
- BSApp::Registry()->doesNotExist;
- $this->fail('exception expected');
- }
- catch (Exception $e)
- {}
- }
-
- public function testUnregisterNoExist()
- {
- try
- {
- unset(BSApp::Registry()->keyThatWontExist);
- $this->fail('exception expected');
- }
- catch (Exception $e)
- {}
- }
-
- public function testGetType()
- {
- $input = BSApp::LoadModule('Input');
- BSApp::Registry()->input = $input;
- $this->assertSame($input, BSApp::Registry()->getType('Input'));
-
- $this->assertEquals(null, BSApp::Registry()->getType('Date'));
- }
-
- public function testRequiredModules()
- {
- try
- {
- BSApp::RequiredModules(array('Input'));
- }
- catch (Exception $e)
- {
- $this->fail('unexpcted exception');
- }
-
- try
- {
- BSApp::RequiredModules(array('Input', 'Db'));
- $this->fail('exception expected');
- }
- catch (Exception $e)
- {}
+ $this->assertEquals('<select><option>Debug Notices (0)</option></select>', BSApp::get_debug_list());
- try
- {
- BSApp::RequiredModules(array('Date'));
- $this->fail('exception expected');
- }
- catch (Exception $e)
- {}
+ BSApp::debug('dbg');
+ $this->assertEquals('<select><option>Debug Notices (1)</option><option>--- dbg</option></select>', BSApp::get_debug_list());
}
}
require_once 'tests.config.php';
require_once ISSO . '/App.php';
- $this->fixture = BSApp::LoadModule('DbMySql');
+ $this->fixture = new BSDbMySql();
$this->fixture->connect(TEST_DB_MYSQL_HOST, TEST_DB_MYSQL_USER, TEST_DB_MYSQL_PASSWORD, TEST_DB_MYSQL_DATABASE);
$this->fixture->query("
CREATE TABLE test
{
try
{
- BSApp::LoadModule('DbMySql')->connect('localhost', '--invalid user--', '--invalid password--', '--nodatabase--');
+ $test = new BSDbMySql();
+ $test->connect('localhost', '--invalid user--', '--invalid password--', '--nodatabase--');
$this->fail('exception expected');
}
catch (BSDbException $e)
{
require_once 'tests.config.php';
require_once ISSO . '/App.php';
+ require_once ISSO . '/DbMySqlI.php';
- $this->fixture = BSApp::LoadModule('DbMySqlI');
+ $this->fixture = new BSDbMySqlI();
$this->fixture->connect(TEST_DB_MYSQL_HOST, TEST_DB_MYSQL_USER, TEST_DB_MYSQL_PASSWORD, TEST_DB_MYSQL_DATABASE);
$this->fixture->query("
CREATE TABLE test
{
try
{
- BSApp::LoadModule('DbMySqlI')->connect('localhost', '--invalid user--', '--invalid password--', '--nodatabase--');
+ $test = new BSDbMySqlI();
+ $test->connect('localhost', '--invalid user--', '--invalid password--', '--nodatabase--');
$this->fail('exception expected');
}
catch (BSDbException $e)
public function setUp()
{
require_once ISSO . '/App.php';
- $this->fixture = BSApp::LoadModule('Date');
+ require_once ISSO . '/Date.php';
+ $this->fixture = new BSDate();
}
public function testGmtTimes()
public function testTimezoneList()
{
- $this->assertEquals(sizeof(BSDate::FetchTimeZoneList()), 30);
+ $this->assertEquals(sizeof(BSDate::fetch_timezone_list()), 30);
}
}
{
$this->assertEquals('', BSFunctions::$cssClass);
- BSFunctions::SwapCssClasses('1', '2');
+ BSFunctions::swap_css_classes('1', '2');
$this->assertEquals('2', BSFunctions::$cssClass);
- BSFunctions::SwapCssClasses('1', '2');
+ BSFunctions::swap_css_classes('1', '2');
$this->assertEquals('1', BSFunctions::$cssClass);
- BSFunctions::SwapCssClasses('1', '2');
+ BSFunctions::swap_css_classes('1', '2');
$this->assertEquals('2', BSFunctions::$cssClass);
}
public function testFetchSourcePath()
{
- $this->assertEquals('a' . DIRECTORY_SEPARATOR, BSFunctions::FetchSourcePath('a'));
+ $this->assertEquals('a' . DIRECTORY_SEPARATOR, BSFunctions::fetch_source_path('a'));
}
public function testDownloadFile()
public function testIsValidEmail()
{
- $this->assertTrue(BSFunctions::IsValidEmail('test@example.com'));
- $this->assertTrue(BSFunctions::IsValidEmail('test@example.co.uk'));
- $this->assertTrue(BSFunctions::IsValidEmail('test.foo_hi@example.edu.k12.paloalto.ca.us'));
+ $this->assertTrue(BSFunctions::is_valid_email('test@example.com'));
+ $this->assertTrue(BSFunctions::is_valid_email('test@example.co.uk'));
+ $this->assertTrue(BSFunctions::is_valid_email('test.foo_hi@example.edu.k12.paloalto.ca.us'));
- $this->assertFalse(BSFunctions::IsValidEmail(''));
- $this->assertFalse(BSFunctions::IsValidEmail('te#st@example.com'));
- $this->assertFalse(BSFunctions::IsValidEmail('@example.com'));
- $this->assertFalse(BSFunctions::IsValidEmail('test@.com'));
+ $this->assertFalse(BSFunctions::is_valid_email(''));
+ $this->assertFalse(BSFunctions::is_valid_email('te#st@example.com'));
+ $this->assertFalse(BSFunctions::is_valid_email('@example.com'));
+ $this->assertFalse(BSFunctions::is_valid_email('test@.com'));
}
public function testIsBrowser()
$values = array();
for ($i = 0; $i < 100; $i++)
{
- $random = BSFunctions::Random(5);
+ $random = BSFunctions::random(5);
$this->assertEquals(5, strlen($random));
$this->assertFalse(in_array($random, $values));
$values[] = $random;
$this->assertEquals('b', next($array));
$this->assertEquals('c', next($array));
- BSFunctions::ArraySetCurrent($array, 0);
+ BSFunctions::array_set_current($array, 0);
$this->assertEquals('a', current($array));
- BSFunctions::ArraySetCurrent($array, 3);
+ BSFunctions::array_set_current($array, 3);
$this->assertEquals('d', current($array));
}
public function testFetchExtension()
{
- $this->assertEquals('txt', BSFunctions::FetchExtension('test.txt'));
- $this->assertEquals('', BSFunctions::FetchExtension('test'));
- $this->assertEquals('xml', BSFunctions::FetchExtension('test.file.xml'));
+ $this->assertEquals('txt', BSFunctions::fetch_extension('test.txt'));
+ $this->assertEquals('', BSFunctions::fetch_extension('test'));
+ $this->assertEquals('xml', BSFunctions::fetch_extension('test.file.xml'));
}
public function testFetchMaxPhpFileSize()
public function testConvertLineBreaks()
{
$string = "test\r\nstring\r\n";
- $this->assertFalse(strpos("\r", BSFunctions::ConvertLineBreaks($string)));
+ $this->assertFalse(strpos("\r", BSFunctions::convert_line_breaks($string)));
}
public function testArrayStripEmpty()
{
$array = array(1, 4, 6);
- $this->assertEquals(3, sizeof(BSFunctions::ArrayStripEmpty($array)));
+ $this->assertEquals(3, sizeof(BSFunctions::array_strip_empty($array)));
$array = array(1, 0, 5, '');
- $this->assertEquals(2, sizeof(BSFunctions::ArrayStripEmpty($array)));
+ $this->assertEquals(2, sizeof(BSFunctions::array_strip_empty($array)));
$array = array('', 'test' => array('', 6));
- $array = BSFunctions::ArrayStripEmpty($array);
+ $array = BSFunctions::array_strip_empty($array);
$this->assertEquals(1, sizeof($array));
$this->assertEquals(1, sizeof($array['test']));
}
}*/
require_once ISSO . '/App.php';
- $this->fixture = BSApp::LoadModule('Input');
+ require_once ISSO . '/Input.php';
+ $this->fixture = new BSInput();
}
public function testSanitizeInputData()
require_once 'PHPUnit/Framework.php';
require_once ISSO . '/Installer.php';
+require_once ISSO . '/Input.php';
class InstallerTest extends PHPUnit_Framework_TestCase
{
global $rig;
$rig = $this;
- BSApp::Registry()->input = $this->input = BSApp::LoadModule('Input');
+ BSApp::$input = new BSInput();
}
private function _loadClass()
public function setUp()
{
require_once ISSO . '/App.php';
+ require_once ISSO . '/Template.php';
- $this->fixture = BSApp::LoadModule('Template');
+ $this->fixture = new BSTemplate();
$this->fixture->setTemplateDirectory(TEST_TEMPLATE_PATH);
$this->fixture->setExtension('test.tpl');
if ($this->db == null)
{
- $this->db = BSApp::LoadModule('DbMySql');
+ require_once ISSO . '/DbMySql.php';
+ $this->db = new BSDbMySql();
$this->db->connect(TEST_DB_MYSQL_HOST, TEST_DB_MYSQL_USER, TEST_DB_MYSQL_PASSWORD, TEST_DB_MYSQL_DATABASE);
$this->db->query("CREATE TABLE template (filename VARCHAR (250) NOT NULL, template TEXT NOT NULL, timestamp INT NOT NULL);");
- BSApp::Registry()->db = $this->db;
+ BSApp::$db = $this->db;
}
}