3 require_once 'PHPUnit/Framework.php';
9 * @copyright Copyright ©2002 - [#]year[#], Blue Static
14 class FunctionsTest
extends PHPUnit_Framework_TestCase
16 public function setUp()
18 require_once('ISSO/App.php');
21 public function testSwapCssClasses()
23 $this->assertEquals('', BSFunctions
::$cssClass);
25 BSFunctions
::SwapCssClasses('1', '2');
26 $this->assertEquals('2', BSFunctions
::$cssClass);
28 BSFunctions
::SwapCssClasses('1', '2');
29 $this->assertEquals('1', BSFunctions
::$cssClass);
31 BSFunctions
::SwapCssClasses('1', '2');
32 $this->assertEquals('2', BSFunctions
::$cssClass);
35 public function testFetchSourcePath()
37 $this->assertEquals('a' . DIRECTORY_SEPARATOR
, BSFunctions
::FetchSourcePath('a'));
40 public function testDownloadFile()
45 public function testIsValidEmail()
47 $this->assertTrue(BSFunctions
::IsValidEmail('test@example.com'));
48 $this->assertTrue(BSFunctions
::IsValidEmail('test@example.co.uk'));
49 $this->assertTrue(BSFunctions
::IsValidEmail('test.foo_hi@example.edu.k12.paloalto.ca.us'));
51 $this->assertFalse(BSFunctions
::IsValidEmail(''));
52 $this->assertFalse(BSFunctions
::IsValidEmail('te#st@example.com'));
53 $this->assertFalse(BSFunctions
::IsValidEmail('@example.com'));
54 $this->assertFalse(BSFunctions
::IsValidEmail('test@.com'));
57 public function testIsBrowser()
62 public function testRandom()
65 for ($i = 0; $i < 100; $i++
)
67 $random = BSFunctions
::Random(5);
68 $this->assertEquals(5, strlen($random));
69 $this->assertFalse(in_array($random, $values));
74 public function testArraySetCurrent()
76 $array = array('a', 'b', 'c', 'd');
78 $this->assertEquals('a', current($array));
79 $this->assertEquals('b', next($array));
80 $this->assertEquals('c', next($array));
82 BSFunctions
::ArraySetCurrent($array, 0);
83 $this->assertEquals('a', current($array));
85 BSFunctions
::ArraySetCurrent($array, 3);
86 $this->assertEquals('d', current($array));
89 public function testFetchMicrotimeDiff()
94 public function testFetchExtension()
96 $this->assertEquals('txt', BSFunctions
::FetchExtension('test.txt'));
97 $this->assertEquals('', BSFunctions
::FetchExtension('test'));
98 $this->assertEquals('xml', BSFunctions
::FetchExtension('test.file.xml'));
101 public function testFetchMaxPhpFileSize()
106 public function testScanDirectory()
111 public function testConvertLineBreaks()
113 $string = "test\r\nstring\r\n";
114 $this->assertFalse(strpos("\r", BSFunctions
::ConvertLineBreaks($string)));
117 public function testArrayStripEmpty()
119 $array = array(1, 4, 6);
120 $this->assertEquals(3, sizeof(BSFunctions
::ArrayStripEmpty($array)));
122 $array = array(1, 0, 5, '');
123 $this->assertEquals(2, sizeof(BSFunctions
::ArrayStripEmpty($array)));
125 $array = array('', 'test' => array('', 6));
126 $array = BSFunctions
::ArrayStripEmpty($array);
127 $this->assertEquals(1, sizeof($array));
128 $this->assertEquals(1, sizeof($array['test']));