Add more rcube_utils tests
| | |
| | | return mktime(0,0,0, intval($matches[2]), intval($matches[3]), intval($matches[1])); |
| | | } |
| | | else if (is_numeric($date)) { |
| | | return $date; |
| | | return (int) $date; |
| | | } |
| | | |
| | | // Clean malformed data |
| | |
| | | $date = implode(' ', $d); |
| | | } |
| | | |
| | | return $ts; |
| | | return (int) $ts; |
| | | } |
| | | |
| | | |
| | |
| | | $this->assertSame($v[2], $result); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * rcube:utils::strtotime() |
| | | */ |
| | | function test_strtotime() |
| | | { |
| | | $test = array( |
| | | '1' => 1, |
| | | '' => 0, |
| | | ); |
| | | |
| | | foreach ($test as $datetime => $ts) { |
| | | $result = rcube_utils::strtotime($datetime); |
| | | $this->assertSame($ts, $result); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * rcube:utils::normalize _string() |
| | | */ |
| | | function test_normalize_string() |
| | | { |
| | | $test = array( |
| | | '' => '', |
| | | 'abc def' => 'abc def', |
| | | ); |
| | | |
| | | foreach ($test as $input => $output) { |
| | | $result = rcube_utils::normalize_string($input); |
| | | $this->assertSame($output, $result); |
| | | } |
| | | } |
| | | } |