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