From 896e2b4e5193af26f7bfe8ad96f7a90b8d96c35e Mon Sep 17 00:00:00 2001
From: Aleksander Machniak <alec@alec.pl>
Date: Tue, 28 May 2013 15:26:44 -0400
Subject: [PATCH] Add more rcube_utils tests
---
tests/Framework/Utils.php | 32 ++++++++++++++++++++++++++++++++
program/lib/Roundcube/rcube_utils.php | 4 ++--
2 files changed, 34 insertions(+), 2 deletions(-)
diff --git a/program/lib/Roundcube/rcube_utils.php b/program/lib/Roundcube/rcube_utils.php
index 23f24a4..29baa82 100644
--- a/program/lib/Roundcube/rcube_utils.php
+++ b/program/lib/Roundcube/rcube_utils.php
@@ -733,7 +733,7 @@
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
@@ -762,7 +762,7 @@
$date = implode(' ', $d);
}
- return $ts;
+ return (int) $ts;
}
diff --git a/tests/Framework/Utils.php b/tests/Framework/Utils.php
index c62e688..abfb7cb 100644
--- a/tests/Framework/Utils.php
+++ b/tests/Framework/Utils.php
@@ -262,4 +262,36 @@
$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);
+ }
+ }
}
--
Gitblit v1.9.1