2 // vim: foldmethod=marker
12 class Ethna_Util_Test extends Ethna_UnitTestBase
14 // {{{ testCheckMailAddress
15 function testCheckMailAddress()
22 'example@example@example.com',
25 foreach ($fail_words as $word) {
26 $this->assertFalse(Ethna_Util::checkMailAddress($word));
29 $result = Ethna_Util::checkMailAddress('hogefuga.net');
30 $this->assertFalse($result);
32 $result = Ethna_Util::checkMailAddress('hoge@fuga.net');
33 $this->assertTrue($result);
38 function testIsAbsolute()
40 if (ETHNA_OS_WINDOWS) {
41 $absolute_paths = array(
46 $absolute_paths = array(
52 $invalid_params = array(
59 foreach ($absolute_paths as $path) {
60 $this->assertTrue(Ethna_Util::isAbsolute($path));
63 foreach ($invalid_params as $path) {
64 $this->assertFalse(Ethna_Util::isAbsolute($path));
70 function testIsRootDir()
72 $this->assertTrue(DIRECTORY_SEPARATOR);
74 if (ETHNA_OS_WINDOWS) {
75 $this->assertTrue (Ethna_Util::isRootDir("C:\\"));
76 $this->assertFalse(Ethna_Util::isRootDir("C:\\Program Files\\hoge\\fuga.txt"));
77 $this->assertFalse(Ethna_Util::isRootDir("C:\\Program Files\\hoge"));
78 $this->assertFalse(Ethna_Util::isRootDir("C:\\hoge\\"));
79 $this->assertFalse(Ethna_Util::isRootDir("C:\\hoge.txt"));
81 $this->assertFalse(Ethna_Util::isRootDir("/home/ethna/test.txt"));
82 $this->assertFalse(Ethna_Util::isRootDir("/home/ethna/"));
83 $this->assertFalse(Ethna_Util::isRootDir("/home/ethna"));
84 $this->assertFalse(Ethna_Util::isRootDir("/test.txt"));
90 function testGetRandom()
94 $r = Ethna_Util::getRandom();
95 $this->assertNotNULL($r);
96 $this->assertEqual(64, strlen($r));
101 function testGetEra()
103 unset($GLOBALS['_Ethna_controller']);
104 $tmp_ctl = new Ethna_Controller();
107 $last_showa_t = mktime(0,0,0,12,31,1988);
108 $r = Ethna_Util::getEra($last_showa_t);
109 $this->assertEqual('昭和', $r[0]);
110 $this->assertEqual(63, $r[1]);
113 $first_heisei_t = mktime(0,0,0,1,1,1989);
114 $r = Ethna_Util::getEra($first_heisei_t);
115 $this->assertEqual('平成', $r[0]);
116 $this->assertEqual(1, $r[1]);