Adding the functions test with some incomplete tests
authorRobert Sesek <rsesek@bluestatic.org>
Wed, 16 Aug 2006 18:33:12 +0000 (18:33 +0000)
committerRobert Sesek <rsesek@bluestatic.org>
Wed, 16 Aug 2006 18:33:12 +0000 (18:33 +0000)
UnitTest/FunctionsTest.php [new file with mode: 0644]

diff --git a/UnitTest/FunctionsTest.php b/UnitTest/FunctionsTest.php
new file mode 100644 (file)
index 0000000..bff9b26
--- /dev/null
@@ -0,0 +1,128 @@
+<?php
+
+// load piggy
+require_once('./../Loader.php');
+
+/**
+* Functions Test Suite
+*
+* @author              Blue Static
+* @copyright   Copyright ©2002 - [#]year[#], Blue Static
+* @version             $Revision$
+* @package             ISSO Tests
+* 
+*/
+class FunctionsTest extends UnitTestCase
+{
+       public function testSwapCssClasses()
+       {
+               $this->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