]> src.bluestatic.org Git - isso.git/blob - UnitTest/FunctionsTest.php
Removing BSLoader and we'll just go with a singleton instance of BSRegister
[isso.git] / UnitTest / FunctionsTest.php
1 <?php
2
3 // load piggy
4 require_once('./../Register.php');
5
6 /**
7 * Functions Test Suite
8 *
9 * @author Blue Static
10 * @copyright Copyright ©2002 - [#]year[#], Blue Static
11 * @version $Revision$
12 * @package ISSO Tests
13 *
14 */
15 class FunctionsTest extends UnitTestCase
16 {
17 public function testSwapCssClasses()
18 {
19 $this->assertEqual('', BSFunctions::$cssClass);
20
21 BSFunctions::SwapCssClasses('1', '2');
22 $this->assertEqual('2', BSFunctions::$cssClass);
23
24 BSFunctions::SwapCssClasses('1', '2');
25 $this->assertEqual('1', BSFunctions::$cssClass);
26
27 BSFunctions::SwapCssClasses('1', '2');
28 $this->assertEqual('2', BSFunctions::$cssClass);
29 }
30
31 public function testFetchSourcePath()
32 {
33 $this->assertEqual('a' . DIRECTORY_SEPARATOR, BSFunctions::FetchSourcePath('a'));
34 }
35
36 public function testDownloadFile()
37 {
38
39 }
40
41 public function testIsValidEmail()
42 {
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'));
46
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'));
51 }
52
53 public function testIsBrowser()
54 {
55
56 }
57
58 public function testRandom()
59 {
60 $values = array();
61 for ($i = 0; $i < 100; $i++)
62 {
63 $random = BSFunctions::Random(5);
64 $this->assertEqual(5, strlen($random));
65 $this->assertFalse(in_array($random, $values));
66 $values[] = $random;
67 }
68 }
69
70 public function testArraySetCurrent()
71 {
72 $array = array('a', 'b', 'c', 'd');
73
74 $this->assertEqual('a', current($array));
75 $this->assertEqual('b', next($array));
76 $this->assertEqual('c', next($array));
77
78 BSFunctions::ArraySetCurrent($array, 0);
79 $this->assertEqual('a', current($array));
80
81 BSFunctions::ArraySetCurrent($array, 3);
82 $this->assertEqual('d', current($array));
83 }
84
85 public function testFetchMicrotimeDiff()
86 {
87
88 }
89
90 public function testFetchExtension()
91 {
92 $this->assertEqual('txt', BSFunctions::FetchExtension('test.txt'));
93 $this->assertEqual('', BSFunctions::FetchExtension('test'));
94 $this->assertEqual('xml', BSFunctions::FetchExtension('test.file.xml'));
95 }
96
97 public function testFetchMaxPhpFileSize()
98 {
99
100 }
101
102 public function testScanDirectory()
103 {
104
105 }
106
107 public function testConvertLineBreaks()
108 {
109 $string = "test\r\nstring\r\n";
110 $this->assertFalse(strpos("\r", BSFunctions::ConvertLineBreaks($string)));
111 }
112
113 public function testArrayStripEmpty()
114 {
115 $array = array(1, 4, 6);
116 $this->assertEqual(3, sizeof(BSFunctions::ArrayStripEmpty($array)));
117
118 $array = array(1, 0, 5, '');
119 $this->assertEqual(2, sizeof(BSFunctions::ArrayStripEmpty($array)));
120
121 $array = array('', 'test' => array('', 6));
122 $array = BSFunctions::ArrayStripEmpty($array);
123 $this->assertEqual(1, sizeof($array));
124 $this->assertEqual(1, sizeof($array['test']));
125 }
126 }
127
128 ?>