summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Machniak <alec@alec.pl>2012-11-05 19:22:09 +0100
committerAleksander Machniak <alec@alec.pl>2012-11-05 19:22:09 +0100
commite68fa71b0eb66a12adcdf35c411c6f83970749ec (patch)
tree9d348b89a2e1fe15d0877d2ed2d0f3465654c121
parent03970bd54936ecbcfe20015897057dab1ffa7c12 (diff)
Fixed rcube_imap_generic::uncompressMessageSet() result when argument is empty. Added tests.
-rw-r--r--program/include/rcube_imap_generic.php6
-rw-r--r--tests/Framework/ImapGeneric.php18
2 files changed, 23 insertions, 1 deletions
diff --git a/program/include/rcube_imap_generic.php b/program/include/rcube_imap_generic.php
index 52bf0e37a..9c525dcba 100644
--- a/program/include/rcube_imap_generic.php
+++ b/program/include/rcube_imap_generic.php
@@ -3530,6 +3530,10 @@ class rcube_imap_generic
*/
static function uncompressMessageSet($messages)
{
+ if (empty($messages)) {
+ return array();
+ }
+
$result = array();
$messages = explode(',', $messages);
@@ -3538,7 +3542,7 @@ class rcube_imap_generic
$max = max($items[0], $items[1]);
for ($x=$items[0]; $x<=$max; $x++) {
- $result[] = $x;
+ $result[] = (int)$x;
}
unset($messages[$idx]);
}
diff --git a/tests/Framework/ImapGeneric.php b/tests/Framework/ImapGeneric.php
index 0b2cc3d53..2f9b6d10f 100644
--- a/tests/Framework/ImapGeneric.php
+++ b/tests/Framework/ImapGeneric.php
@@ -17,4 +17,22 @@ class Framework_ImapGeneric extends PHPUnit_Framework_TestCase
$this->assertInstanceOf('rcube_imap_generic', $object, "Class constructor");
}
+
+ /**
+ * Test for uncompressMessageSet
+ */
+ function test_uncompressMessageSet()
+ {
+ $result = rcube_imap_generic::uncompressMessageSet(null);
+ $this->assertSame(array(), $result);
+ $this->assertCount(0, $result);
+
+ $result = rcube_imap_generic::uncompressMessageSet('1');
+ $this->assertSame(array(1), $result);
+ $this->assertCount(1, $result);
+
+ $result = rcube_imap_generic::uncompressMessageSet('1:3');
+ $this->assertSame(array(1, 2, 3), $result);
+ $this->assertCount(3, $result);
+ }
}