]>
src.bluestatic.org Git - isso.git/blob - UnitTest/FunctionsTest.php
4 require_once('./../Register.php');
10 * @copyright Copyright ©2002 - [#]year[#], Blue Static
15 class FunctionsTest
extends UnitTestCase
17 public function testSwapCssClasses()
19 $this->assertEqual('', BSFunctions
::$cssClass);
21 BSFunctions
::SwapCssClasses('1', '2');
22 $this->assertEqual('2', BSFunctions
::$cssClass);
24 BSFunctions
::SwapCssClasses('1', '2');
25 $this->assertEqual('1', BSFunctions
::$cssClass);
27 BSFunctions
::SwapCssClasses('1', '2');
28 $this->assertEqual('2', BSFunctions
::$cssClass);
31 public function testFetchSourcePath()
33 $this->assertEqual('a' . DIRECTORY_SEPARATOR
, BSFunctions
::FetchSourcePath('a'));
36 public function testDownloadFile()
41 public function testIsValidEmail()
43 $this->assertTrue(BSFunctions
::IsValidEmail('test@example.com'));
44 $this->assertTrue(BSFunctions
::IsValidEmail('test@example.co.uk'));
45 $this->assertTrue(BSFunctions
::IsValidEmail('test.foo_hi@example.edu.k12.paloalto.ca.us'));
47 $this->assertFalse(BSFunctions
::IsValidEmail(''));
48 $this->assertFalse(BSFunctions
::IsValidEmail('te#st@example.com'));
49 $this->assertFalse(BSFunctions
::IsValidEmail('@example.com'));
50 $this->assertFalse(BSFunctions
::IsValidEmail('test@.com'));
53 public function testIsBrowser()
58 public function testRandom()
61 for ($i = 0; $i < 100; $i++
)
63 $random = BSFunctions
::Random(5);
64 $this->assertEqual(5, strlen($random));
65 $this->assertFalse(in_array($random, $values));
70 public function testArraySetCurrent()
72 $array = array('a', 'b', 'c', 'd');
74 $this->assertEqual('a', current($array));
75 $this->assertEqual('b', next($array));
76 $this->assertEqual('c', next($array));
78 BSFunctions
::ArraySetCurrent($array, 0);
79 $this->assertEqual('a', current($array));
81 BSFunctions
::ArraySetCurrent($array, 3);
82 $this->assertEqual('d', current($array));
85 public function testFetchMicrotimeDiff()
90 public function testFetchExtension()
92 $this->assertEqual('txt', BSFunctions
::FetchExtension('test.txt'));
93 $this->assertEqual('', BSFunctions
::FetchExtension('test'));
94 $this->assertEqual('xml', BSFunctions
::FetchExtension('test.file.xml'));
97 public function testFetchMaxPhpFileSize()
102 public function testScanDirectory()
107 public function testConvertLineBreaks()
109 $string = "test\r\nstring\r\n";
110 $this->assertFalse(strpos("\r", BSFunctions
::ConvertLineBreaks($string)));
113 public function testArrayStripEmpty()
115 $array = array(1, 4, 6);
116 $this->assertEqual(3, sizeof(BSFunctions
::ArrayStripEmpty($array)));
118 $array = array(1, 0, 5, '');
119 $this->assertEqual(2, sizeof(BSFunctions
::ArrayStripEmpty($array)));
121 $array = array('', 'test' => array('', 6));
122 $array = BSFunctions
::ArrayStripEmpty($array);
123 $this->assertEqual(1, sizeof($array));
124 $this->assertEqual(1, sizeof($array['test']));