Thomas Bruederli
2014-08-19 fc52af24f1418d6590a2d37a0d8cc31b123e38f6
tests/Framework/Utils.php
@@ -206,4 +206,66 @@
            $this->assertSame(explode(',', $text), $result);
        }
    }
    /**
     * rcube_utils::get_boolean()
     */
    function test_get_boolean()
    {
        $input = array(
            false, 'false', '0', 'no', 'off', 'nein', 'FALSE', '', null,
        );
        foreach ($input as $idx => $value) {
            $this->assertFalse(get_boolean($value), "Invalid result for $idx test item");
        }
        $input = array(
            true, 'true', '1', 1, 'yes', 'anything', 1000,
        );
        foreach ($input as $idx => $value) {
            $this->assertTrue(get_boolean($value), "Invalid result for $idx test item");
        }
    }
    /**
     * rcube:utils::strtotime()
     */
    function test_strtotime()
    {
        $test = array(
            '1' => 1,
            '' => 0,
            '2013-04-22' => 1366581600,
            '2013/04/22' => 1366581600,
            '2013.04.22' => 1366581600,
            '22-04-2013' => 1366581600,
            '22/04/2013' => 1366581600,
            '22.04.2013' => 1366581600,
            '22.4.2013'  => 1366581600,
            '20130422'   => 1366581600,
        );
        foreach ($test as $datetime => $ts) {
            $result = rcube_utils::strtotime($datetime);
            $this->assertSame($ts, $result, "Error parsing date: $datetime");
        }
    }
    /**
     * 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);
        }
    }
}