summaryrefslogtreecommitdiff
path: root/tests/Framework/ResultThread.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/ResultThread.php
parente445e0acb558b2c4805cef3ed13c84139962a5b3 (diff)
Bring back unit tests (they should be removed when creating a package)
Diffstat (limited to 'tests/Framework/ResultThread.php')
-rw-r--r--tests/Framework/ResultThread.php59
1 files changed, 59 insertions, 0 deletions
diff --git a/tests/Framework/ResultThread.php b/tests/Framework/ResultThread.php
new file mode 100644
index 000000000..55fca4c6a
--- /dev/null
+++ b/tests/Framework/ResultThread.php
@@ -0,0 +1,59 @@
+<?php
+
+/**
+ * Test class to test rcube_result_thread class
+ *
+ * @package Tests
+ */
+class Framework_ResultThread extends PHPUnit_Framework_TestCase
+{
+
+ /**
+ * Class constructor
+ */
+ function test_class()
+ {
+ $object = new rcube_result_thread;
+
+ $this->assertInstanceOf('rcube_result_thread', $object, "Class constructor");
+ }
+
+ /**
+ * thread parser test
+ */
+ function test_parse_thread()
+ {
+ $text = file_get_contents(__DIR__ . '/../src/imap_thread.txt');
+ $object = new rcube_result_thread('INBOX', $text);
+
+ $this->assertSame(false, $object->is_empty(), "Object is empty");
+ $this->assertSame(false, $object->is_error(), "Object is error");
+ $this->assertSame(1721, $object->max(), "Max message UID");
+ $this->assertSame(1, $object->min(), "Min message UID");
+ $this->assertSame(1721, $object->count_messages(), "Messages count");
+ $this->assertSame(1691, $object->exists(1720, true), "Message exists");
+ $this->assertSame(true, $object->exists(1720), "Message exists (bool)");
+ $this->assertSame(1, $object->get_element('FIRST'), "Get first element");
+ $this->assertSame(1719, $object->get_element('LAST'), "Get last element");
+ $this->assertSame(14, (int) $object->get_element(2), "Get specified element");
+
+ $clone = clone $object;
+ $clone->filter(array(7));
+ $clone = $clone->get_tree();
+
+ $this->assertSame(1, count($clone), "Structure check");
+ $this->assertSame(3, count($clone[7]), "Structure check");
+ $this->assertSame(0, count($clone[7][12]), "Structure check");
+ $this->assertSame(1, count($clone[7][167]), "Structure check");
+ $this->assertSame(0, count($clone[7][167][197]), "Structure check");
+ $this->assertSame(2, count($clone[7][458]), "Structure check");
+ $this->assertSame(1, count($clone[7][458][460]), "Structure check");
+ $this->assertSame(0, count($clone[7][458][460][463]), "Structure check");
+ $this->assertSame(1, count($clone[7][458][464]), "Structure check");
+ $this->assertSame(0, count($clone[7][458][464][471]), "Structure check");
+
+ $object->filter(array(784));
+ $this->assertSame(118, $object->count_messages(), "Messages filter");
+ $this->assertSame(1, $object->count(), "Messages filter (count)");
+ }
+}