assertEquals('', BSFunctions::$cssClass); BSFunctions::swap_css_classes('1', '2'); $this->assertEquals('2', BSFunctions::$cssClass); BSFunctions::swap_css_classes('1', '2'); $this->assertEquals('1', BSFunctions::$cssClass); BSFunctions::swap_css_classes('1', '2'); $this->assertEquals('2', BSFunctions::$cssClass); } public function testFetchSourcePath() { $this->assertEquals('a' . DIRECTORY_SEPARATOR, BSFunctions::fetch_source_path('a')); } public function testDownloadFile() { } public function testIsValidEmail() { $this->assertTrue(BSFunctions::is_valid_email('test@example.com')); $this->assertTrue(BSFunctions::is_valid_email('test@example.co.uk')); $this->assertTrue(BSFunctions::is_valid_email('test.foo_hi@example.edu.k12.paloalto.ca.us')); $this->assertFalse(BSFunctions::is_valid_email('')); $this->assertFalse(BSFunctions::is_valid_email('te#st@example.com')); $this->assertFalse(BSFunctions::is_valid_email('@example.com')); $this->assertFalse(BSFunctions::is_valid_email('test@.com')); } public function testRandom() { // test fixed length $values = array(); for ($i = 0; $i < 100; $i++) { $random = BSFunctions::random(5); $this->assertEquals(5, strlen($random)); $values[] = $random; } $this->assertEquals(sizeof(array_unique($values)), sizeof($values)); // test random length $values = array(); for ($i = 0; $i < 100; $i++) { $random = BSFunctions::random(); $length = strlen($random); $this->assertTrue($length >= 20 && $length <= 65); $values[] = $random; } $this->assertEquals(sizeof(array_unique($values)), sizeof($values)); } public function testArraySetCurrent() { $array = array('a', 'b', 'c', 'd'); $this->assertEquals('a', current($array)); $this->assertEquals('b', next($array)); $this->assertEquals('c', next($array)); BSFunctions::array_set_current($array, 0); $this->assertEquals('a', current($array)); BSFunctions::array_set_current($array, 3); $this->assertEquals('d', current($array)); } public function testFetchMicrotimeDiff() { } public function testFetchExtension() { $this->assertEquals('txt', BSFunctions::fetch_extension('test.txt')); $this->assertEquals('', BSFunctions::fetch_extension('test')); $this->assertEquals('xml', BSFunctions::fetch_extension('test.file.xml')); } public function testFetchMaxPhpFileSize() { } public function testScanDirectory() { } public function testConvertLineBreaks() { $string = "test\r\nstring\r\n"; $this->assertFalse(strpos("\r", BSFunctions::convert_line_breaks($string))); } public function testArrayStripEmpty() { $array = array(1, 4, 6); $this->assertEquals(3, sizeof(BSFunctions::array_strip_empty($array))); $array = array(1, 0, 5, ''); $this->assertEquals(2, sizeof(BSFunctions::array_strip_empty($array))); $array = array('', 'test' => array('', 6)); $array = BSFunctions::array_strip_empty($array); $this->assertEquals(1, sizeof($array)); $this->assertEquals(1, sizeof($array['test'])); } } ?>