From 21ce4c1fa71ad813cc3f741a3cb65f84959fb36a Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Wed, 16 Aug 2006 18:33:12 +0000 Subject: [PATCH] Adding the functions test with some incomplete tests --- UnitTest/FunctionsTest.php | 128 +++++++++++++++++++++++++++++++++++++ 1 file changed, 128 insertions(+) create mode 100644 UnitTest/FunctionsTest.php diff --git a/UnitTest/FunctionsTest.php b/UnitTest/FunctionsTest.php new file mode 100644 index 0000000..bff9b26 --- /dev/null +++ b/UnitTest/FunctionsTest.php @@ -0,0 +1,128 @@ +assertEqual('', BSFunctions::$cssClass); + + BSFunctions::SwapCssClasses('1', '2'); + $this->assertEqual('2', BSFunctions::$cssClass); + + BSFunctions::SwapCssClasses('1', '2'); + $this->assertEqual('1', BSFunctions::$cssClass); + + BSFunctions::SwapCssClasses('1', '2'); + $this->assertEqual('2', BSFunctions::$cssClass); + } + + public function testFetchSourcePath() + { + $this->assertEqual('a' . DIRECTORY_SEPARATOR, BSFunctions::FetchSourcePath('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->assertFalse(BSFunctions::IsValidEmail('')); + $this->assertFalse(BSFunctions::IsValidEmail('te#st@example.com')); + $this->assertFalse(BSFunctions::IsValidEmail('@example.com')); + $this->assertFalse(BSFunctions::IsValidEmail('test@.com')); + } + + public function testIsBrowser() + { + + } + + public function testRandom() + { + $values = array(); + for ($i = 0; $i < 100; $i++) + { + $random = BSFunctions::Random(5); + $this->assertEqual(5, strlen($random)); + $this->assertFalse(in_array($random, $values)); + $values[] = $random; + } + } + + public function testArraySetCurrent() + { + $array = array('a', 'b', 'c', 'd'); + + $this->assertEqual('a', current($array)); + $this->assertEqual('b', next($array)); + $this->assertEqual('c', next($array)); + + BSFunctions::ArraySetCurrent($array, 0); + $this->assertEqual('a', current($array)); + + BSFunctions::ArraySetCurrent($array, 3); + $this->assertEqual('d', current($array)); + } + + public function testFetchMicrotimeDiff() + { + + } + + public function testFetchExtension() + { + $this->assertEqual('txt', BSFunctions::FetchExtension('test.txt')); + $this->assertEqual('', BSFunctions::FetchExtension('test')); + $this->assertEqual('xml', BSFunctions::FetchExtension('test.file.xml')); + } + + public function testFetchMaxPhpFileSize() + { + + } + + public function testScanDirectory() + { + + } + + public function testConvertLineBreaks() + { + $string = "test\r\nstring\r\n"; + $this->assertFalse(strpos("\r", BSFunctions::ConvertLineBreaks($string))); + } + + public function testArrayStripEmpty() + { + $array = array(1, 4, 6); + $this->assertEqual(3, sizeof(BSFunctions::ArrayStripEmpty($array))); + + $array = array(1, 0, 5, ''); + $this->assertEqual(2, sizeof(BSFunctions::ArrayStripEmpty($array))); + + $array = array('', 'test' => array('', 6)); + $array = BSFunctions::ArrayStripEmpty($array); + $this->assertEqual(1, sizeof($array)); + $this->assertEqual(1, sizeof($array['test'])); + } +} + +?> \ No newline at end of file -- 2.43.5