Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F117750639
ImapGeneric.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
3 KB
Referenced Files
None
Subscribers
None
ImapGeneric.php
View Options
<?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 escape()
*/
function
test_escape
()
{
$this
->
assertSame
(
'NIL'
,
rcube_imap_generic
::
escape
(
null
));
$this
->
assertSame
(
'""'
,
rcube_imap_generic
::
escape
(
''
));
$this
->
assertSame
(
'abc'
,
rcube_imap_generic
::
escape
(
'abc'
));
$this
->
assertSame
(
'"abc"'
,
rcube_imap_generic
::
escape
(
'abc'
,
true
));
$this
->
assertSame
(
'"abc
\"
def"'
,
rcube_imap_generic
::
escape
(
'abc"def'
));
$this
->
assertSame
(
"{3}
\r\n
a
\n
b"
,
rcube_imap_generic
::
escape
(
"a
\n
b"
));
}
/**
* Test for sortHeaders()
*/
function
test_sortHeaders
()
{
$headers
=
[
rcube_message_header
::
from_array
([
'subject'
=>
'Test1'
,
'timestamp'
=>
time
()
-
100
,
]),
rcube_message_header
::
from_array
([
'subject'
=>
'Re: Test2'
,
'timestamp'
=>
time
(),
]),
];
$result
=
rcube_imap_generic
::
sortHeaders
(
$headers
,
'subject'
);
$this
->
assertSame
(
'Test1'
,
$result
[
0
]->
subject
);
$this
->
assertSame
(
'Re: Test2'
,
$result
[
1
]->
subject
);
$result
=
rcube_imap_generic
::
sortHeaders
(
$headers
,
'subject'
,
'DESC'
);
$this
->
assertSame
(
'Re: Test2'
,
$result
[
0
]->
subject
);
$this
->
assertSame
(
'Test1'
,
$result
[
1
]->
subject
);
$result
=
rcube_imap_generic
::
sortHeaders
(
$headers
,
'date'
,
'DESC'
);
$this
->
assertSame
(
'Re: Test2'
,
$result
[
0
]->
subject
);
$this
->
assertSame
(
'Test1'
,
$result
[
1
]->
subject
);
}
/**
* Test for compressMessageSet()
*/
function
test_compressMessageSet
()
{
$result
=
rcube_imap_generic
::
compressMessageSet
([
5
,
4
,
3
]);
$this
->
assertSame
(
'3:5'
,
$result
);
$result
=
rcube_imap_generic
::
compressMessageSet
([
5
,
4
,
3
,
10
,
12
,
13
]);
$this
->
assertSame
(
'3:5,10,12:13'
,
$result
);
$result
=
rcube_imap_generic
::
compressMessageSet
(
'1'
);
$this
->
assertSame
(
'1'
,
$result
);
$result
=
rcube_imap_generic
::
compressMessageSet
(
'-1'
);
$this
->
assertSame
(
'INVALID'
,
$result
);
}
/**
* Test for uncompressMessageSet
*/
function
test_uncompressMessageSet
()
{
$result
=
rcube_imap_generic
::
uncompressMessageSet
(
null
);
$this
->
assertSame
([],
$result
);
$this
->
assertCount
(
0
,
$result
);
$result
=
rcube_imap_generic
::
uncompressMessageSet
(
'1'
);
$this
->
assertSame
([
1
],
$result
);
$this
->
assertCount
(
1
,
$result
);
$result
=
rcube_imap_generic
::
uncompressMessageSet
(
'1:3'
);
$this
->
assertSame
([
1
,
2
,
3
],
$result
);
$this
->
assertCount
(
3
,
$result
);
}
/**
* Test for tokenizeResponse
*/
function
test_tokenizeResponse
()
{
$response
=
"test brack[et] {1}
\r\n
a {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
([
'item1'
,
'item2'
],
$result
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sat, Apr 4, 2:33 AM (1 w, 11 h ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
d1/69/ead94f7e7eabc565ed92dc5f2e54
Default Alt Text
ImapGeneric.php (3 KB)
Attached To
Mode
R113 roundcubemail
Attached
Detach File
Event Timeline