mirror of
https://github.com/roundcube/roundcubemail.git
synced 2026-03-23 08:16:57 +01:00
* Assert CS using CI * fix "single_blank_line_at_eof" * fix "statement_indentation" * fix "switch_case_semicolon_to_colon" * fix "control_structure_braces" * fix "statement_indentation" * fix "no_whitespace_in_blank_line" * fix "no_trailing_whitespace_in_comment" * fix "no_trailing_whitespace" * fix "single_space_around_construct" * fix "spaces_inside_parentheses" * fix "ternary_operator_spaces" * fix "trim_array_spaces" * fix "whitespace_after_comma_in_array" * fix "cast_spaces" * fix "unary_operator_spaces" * fix "no_trailing_comma_in_singleline" * fix "ordered_imports" * fix "no_unused_imports" * Check composer.json format * fix CI job name * file header comments are not phpdoc * fix "phpdoc_indent" * fix "braces_position" * fix "phpdoc_types" * fix "no_blank_lines_after_class_opening" * fix "no_multiple_statements_per_line" * fix "multiline_comment_opening_closing" * fix "single_line_empty_body" * fix "non_printable_character" * fix "phpdoc_trim_consecutive_blank_line_separation" * fix "include" * fix "no_mixed_echo_print" --------- Co-authored-by: Aleksander Machniak <alec@alec.pl>
113 lines
4.2 KiB
PHP
113 lines
4.2 KiB
PHP
<?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(731, $object->count(), "Threads count");
|
|
$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");
|
|
|
|
$tree = $object->get_tree();
|
|
$expected = [
|
|
4 => [
|
|
18 => [
|
|
39 => [
|
|
100 => []
|
|
]
|
|
]
|
|
],
|
|
5 => [
|
|
6 => [],
|
|
8 => [
|
|
11 => [],
|
|
13 => [
|
|
15 => []
|
|
],
|
|
465 => []
|
|
],
|
|
209 => []
|
|
],
|
|
19 => [
|
|
314 => []
|
|
]
|
|
];
|
|
|
|
$this->assertSame([], $tree[1]);
|
|
$this->assertSame([], $tree[2]);
|
|
$this->assertSame([], $tree[14]);
|
|
$this->assertSame([], $tree[3]);
|
|
$this->assertSame($expected[4], $tree[4]);
|
|
$this->assertSame($expected[5], $tree[5]);
|
|
$this->assertSame($expected[19], $tree[19]);
|
|
|
|
$clone = clone $object;
|
|
$clone->filter([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([784]);
|
|
$this->assertSame(118, $object->count_messages(), "Messages filter");
|
|
$this->assertSame(1, $object->count(), "Messages filter (count)");
|
|
}
|
|
|
|
/**
|
|
* thread parser test (empty result)
|
|
*/
|
|
function test_parse_empty()
|
|
{
|
|
$object = new rcube_result_thread('INBOX', "* THREAD");
|
|
|
|
$this->assertSame(true, $object->is_empty(), "Object is empty");
|
|
$this->assertSame(false, $object->is_error(), "Object is error");
|
|
$this->assertSame(null, $object->max(), "Max message UID");
|
|
$this->assertSame(null, $object->min(), "Min message UID");
|
|
$this->assertSame(0, $object->count(), "Threads count");
|
|
$this->assertSame(0, $object->count_messages(), "Messages count");
|
|
$this->assertSame(false, $object->exists(1720, true), "Message exists");
|
|
$this->assertSame(false, $object->exists(1720), "Message exists (bool)");
|
|
$this->assertSame(null, $object->get_element('FIRST'), "Get first element");
|
|
$this->assertSame(null, $object->get_element('LAST'), "Get last element");
|
|
$this->assertSame(null, $object->get_element(2), "Get specified element");
|
|
}
|
|
}
|