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