Aleksander Machniak
2016-05-22 0344b168276f80189e2254c75a762aff5b517b6b
commit | author | age
5f8ada 1 <?php
AM 2
3 /**
4  * Test class to test rcube_imap_generic class
5  *
6  * @package Tests
7  */
8 class Framework_ImapGeneric extends PHPUnit_Framework_TestCase
9 {
10
11     /**
12      * Class constructor
13      */
14     function test_class()
15     {
16         $object = new rcube_imap_generic;
17
18         $this->assertInstanceOf('rcube_imap_generic', $object, "Class constructor");
19     }
e68fa7 20
AM 21     /**
22      * Test for uncompressMessageSet
23      */
24     function test_uncompressMessageSet()
25     {
26         $result = rcube_imap_generic::uncompressMessageSet(null);
27         $this->assertSame(array(), $result);
28         $this->assertCount(0, $result);
29
30         $result = rcube_imap_generic::uncompressMessageSet('1');
31         $this->assertSame(array(1), $result);
32         $this->assertCount(1, $result);
33
34         $result = rcube_imap_generic::uncompressMessageSet('1:3');
35         $this->assertSame(array(1, 2, 3), $result);
36         $this->assertCount(3, $result);
37     }
6e57fb 38
AM 39     /**
40      * Test for tokenizeResponse
41      */
42     function test_tokenizeResponse()
43     {
44         $response = "test brack[et] {1}\r\na {0}\r\n (item1 item2)";
45
46         $result = rcube_imap_generic::tokenizeResponse($response, 1);
47         $this->assertSame("test", $result);
48
49         $result = rcube_imap_generic::tokenizeResponse($response, 1);
50         $this->assertSame("brack[et]", $result);
51
52         $result = rcube_imap_generic::tokenizeResponse($response, 1);
53         $this->assertSame("a", $result);
54
55         $result = rcube_imap_generic::tokenizeResponse($response, 1);
56         $this->assertSame("", $result);
57
58         $result = rcube_imap_generic::tokenizeResponse($response, 1);
59         $this->assertSame(array('item1', 'item2'), $result);
60     }
5f8ada 61 }