summaryrefslogtreecommitdiff
path: root/tests/Framework/ImapGeneric.php
diff options
context:
space:
mode:
authorAleksander Machniak <alec@alec.pl>2014-02-05 20:18:51 +0100
committerAleksander Machniak <alec@alec.pl>2014-02-05 20:18:51 +0100
commitb37954110d2184279a7f400d8750996a27b8f666 (patch)
tree0a0b3d1ecd72c157b4d229cb4ecd9ed928198b32 /tests/Framework/ImapGeneric.php
parente445e0acb558b2c4805cef3ed13c84139962a5b3 (diff)
Bring back unit tests (they should be removed when creating a package)
Diffstat (limited to 'tests/Framework/ImapGeneric.php')
-rw-r--r--tests/Framework/ImapGeneric.php61
1 files changed, 61 insertions, 0 deletions
diff --git a/tests/Framework/ImapGeneric.php b/tests/Framework/ImapGeneric.php
new file mode 100644
index 000000000..af73158e5
--- /dev/null
+++ b/tests/Framework/ImapGeneric.php
@@ -0,0 +1,61 @@
+<?php
+
+/**
+ * Test class to test rcube_imap_generic class
+ *
+ * @package Tests
+ */
+class Framework_ImapGeneric extends PHPUnit_Framework_TestCase
+{
+
+ /**
+ * Class constructor
+ */
+ function test_class()
+ {
+ $object = new rcube_imap_generic;
+
+ $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);
+ }
+
+ /**
+ * Test for tokenizeResponse
+ */
+ function test_tokenizeResponse()
+ {
+ $response = "test brack[et] {1}\r\na {0}\r\n (item1 item2)";
+
+ $result = rcube_imap_generic::tokenizeResponse($response, 1);
+ $this->assertSame("test", $result);
+
+ $result = rcube_imap_generic::tokenizeResponse($response, 1);
+ $this->assertSame("brack[et]", $result);
+
+ $result = rcube_imap_generic::tokenizeResponse($response, 1);
+ $this->assertSame("a", $result);
+
+ $result = rcube_imap_generic::tokenizeResponse($response, 1);
+ $this->assertSame("", $result);
+
+ $result = rcube_imap_generic::tokenizeResponse($response, 1);
+ $this->assertSame(array('item1', 'item2'), $result);
+ }
+}