From: Olivier DOUCET Date: Mon, 23 Nov 2009 21:48:57 +0000 (+0000) Subject: Adding IMAP tests (PHP 5.3) X-Git-Tag: php-5.3.2RC1~199 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=db8c6d5dcfbb737d1d45e452e6ec6d49628381f3;p=php Adding IMAP tests (PHP 5.3) --- diff --git a/ext/imap/tests/imap_body.phpt b/ext/imap/tests/imap_body.phpt index 08f63db47d..40f35f07aa 100644 --- a/ext/imap/tests/imap_body.phpt +++ b/ext/imap/tests/imap_body.phpt @@ -15,6 +15,18 @@ imap_body(); echo "Checking with incorrect parameter type\n"; imap_body(''); imap_body(false); +require_once(dirname(__FILE__).'/imap_include.inc'); +$stream_id = imap_open($default_mailbox, $username, $password) or + die("Cannot connect to mailbox $default_mailbox: " . imap_last_error()); +imap_body($stream_id); +imap_body($stream_id,-1); +imap_body($stream_id,1,-1); + +//Access not existing +var_dump(imap_body($stream_id, 999, FT_UID)); + +imap_close($stream_id); + ?> --EXPECTF-- Checking with no parameters @@ -25,3 +37,12 @@ Checking with incorrect parameter type Warning: imap_body() expects at least 2 parameters, 1 given in %s on line %d Warning: imap_body() expects at least 2 parameters, 1 given in %s on line %d + +Warning: imap_body() expects at least 2 parameters, 1 given in %s on line %d + +Warning: imap_body(): Bad message number in %s on line %d + +Warning: imap_body(): invalid value for the options parameter in %s on line %d + +Warning: imap_body(): Bad message number in %s on line %d +bool(false) \ No newline at end of file diff --git a/ext/imap/tests/imap_fetchstructure_basic.phpt b/ext/imap/tests/imap_fetchstructure_basic.phpt new file mode 100644 index 0000000000..7ad4fc5622 --- /dev/null +++ b/ext/imap/tests/imap_fetchstructure_basic.phpt @@ -0,0 +1,70 @@ +--TEST-- +imap_fetchstructure() function : basic functionality +--CREDITS-- +Olivier Doucet +--SKIPIF-- + +--FILE-- +$key)); +} +var_dump($z->type); +var_dump($z->encoding); +var_dump($z->bytes); +var_dump($z->lines); +var_dump(is_object($z->parameters)); + +imap_close($stream_id); +?> +--CLEAN-- + +--EXPECTF-- +Checking with no parameters + +Warning: imap_fetchstructure() expects at least 2 parameters, 0 given in %s on line %d +Checking with incorrect parameter type + +Warning: imap_fetchstructure() expects at least 2 parameters, 1 given in %s on line %d + +Warning: imap_fetchstructure() expects at least 2 parameters, 1 given in %s on line %d +Create a temporary mailbox and add 1 msgs +.. mailbox '{%s}%s' created + +Warning: imap_fetchstructure() expects at least 2 parameters, 1 given in %s on line %d +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +int(%d) +int(%d) +int(%d) +int(%d) +bool(true) \ No newline at end of file diff --git a/ext/imap/tests/imap_gc_error.phpt b/ext/imap/tests/imap_gc_error.phpt index c0830c000d..f8e6201eba 100644 --- a/ext/imap/tests/imap_gc_error.phpt +++ b/ext/imap/tests/imap_gc_error.phpt @@ -16,6 +16,11 @@ echo "Checking with incorrect parameter type\n"; imap_gc('', false); imap_gc(false, false); +require_once(dirname(__FILE__).'/imap_include.inc'); +$stream_id = imap_open($default_mailbox, $username, $password) or + die("Cannot connect to mailbox $default_mailbox: " . imap_last_error()); +imap_gc($stream_id, -1); + ?> --EXPECTF-- Checking with no parameters @@ -26,3 +31,5 @@ Checking with incorrect parameter type Warning: imap_gc() expects parameter 1 to be resource, %unicode_string_optional% given in %s on line %d Warning: imap_gc() expects parameter 1 to be resource, boolean given in %s on line %d + +Warning: imap_gc(): invalid value for the flags parameter in %s on line %d diff --git a/ext/imap/tests/imap_getsubscribed_basic.phpt b/ext/imap/tests/imap_getsubscribed_basic.phpt new file mode 100644 index 0000000000..ba8a42daa8 --- /dev/null +++ b/ext/imap/tests/imap_getsubscribed_basic.phpt @@ -0,0 +1,68 @@ +--TEST-- +imap_getsubscribed() function : basic functionality +--CREDITS-- +Olivier Doucet +--SKIPIF-- + +--FILE-- + +--CLEAN-- + +--EXPECTF-- +Checking with no parameters + +Warning: imap_getsubscribed() expects exactly 3 parameters, 0 given in %s on line %d +Checking with incorrect parameter type + +Warning: imap_getsubscribed() expects exactly 3 parameters, 1 given in %s on line %d + +Warning: imap_getsubscribed() expects exactly 3 parameters, 1 given in %s on line %d + +Warning: imap_getsubscribed() expects exactly 3 parameters, 1 given in %s on line %d + +Warning: imap_getsubscribed() expects exactly 3 parameters, 2 given in %s on line %d +bool(false) +Checking OK +bool(true) +object(stdClass)#%d (%d) { + [%sname"]=> + string(%d) "{%s}%s" + [%sattributes"]=> + int(%d) + [%sdelimiter"]=> + string(%d) "%s" +} \ No newline at end of file diff --git a/ext/imap/tests/imap_headerinfo_basic.phpt b/ext/imap/tests/imap_headerinfo_basic.phpt new file mode 100644 index 0000000000..b772476afc --- /dev/null +++ b/ext/imap/tests/imap_headerinfo_basic.phpt @@ -0,0 +1,129 @@ +--TEST-- +imap_headerinfo() function : basic functionality +--CREDITS-- +Olivier Doucet +--SKIPIF-- + +--FILE-- +$key)); +} + +echo "Check type\n"; +var_dump($z->toaddress); +var_dump($z->fromaddress); +var_dump($z->reply_toaddress); +var_dump($z->senderaddress); +var_dump($z->subject); +var_dump($z->Subject); + +if ($z->Recent == 'R' || $z->Recent == 'N' || $z->Recent == ' ') { + echo "Recent: OK"; +} else { + echo "Recent: error: ".$z->Recent; +} +echo "\n"; + +if ($z->Unseen == 'U' || $z->Unseen == ' ') { + echo "Unseen: OK"; +} else { + echo "Unseen: error: ".$z->Unseen; +} +echo "\n"; + +if ($z->Flagged == 'F' || $z->Flagged == ' ') { + echo "Flagged: OK"; +} else { + echo "Flagged: error: ".$z->Flagged; +} +echo "\n"; + +if ($z->Answered == 'A' || $z->Answered == ' ') { + echo "Answered: OK"; +} else { + echo "Answered: error"; +} +echo "\n"; + +if ($z->Deleted == 'D' || $z->Deleted == ' ') { + echo "Deleted: OK"; +} else { + echo "Deleted: error"; +} +echo "\n"; + +if ($z->Draft == 'X' || $z->Draft == ' ') { + echo "Draft: OK"; +} else { + echo "Draft: error"; +} +echo "\n"; + +var_dump($z->Msgno); +var_dump($z->Size); +var_dump($z->udate); + +imap_close($stream_id); + +?> +--CLEAN-- + +--EXPECTF-- +Create a temporary mailbox and add 1 msgs +.. mailbox '{%s}%s' created +Check general fields +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +Check type +string(%d) "%s" +string(%d) "%s" +string(%d) "%s" +string(%d) "%s" +string(%d) "%s" +string(%d) "%s" +Recent: OK +Unseen: OK +Flagged: OK +Answered: OK +Deleted: OK +Draft: OK +string(%d) "%s" +string(%d) "%d" +int(%d) \ No newline at end of file diff --git a/ext/imap/tests/imap_headerinfo_error.phpt b/ext/imap/tests/imap_headerinfo_error.phpt new file mode 100644 index 0000000000..b526096fe1 --- /dev/null +++ b/ext/imap/tests/imap_headerinfo_error.phpt @@ -0,0 +1,36 @@ +--TEST-- +imap_headerinfo() incorrect parameter count +--CREDITS-- +Olivier Doucet +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +Checking with no parameters + +Warning: imap_headerinfo() expects at least 2 parameters, 0 given in %s on line %d +Checking with incorrect parameter type + +Warning: imap_headerinfo() expects at least 2 parameters, 1 given in %s on line %d + +Warning: imap_headerinfo() expects at least 2 parameters, 1 given in %s on line %d + +Warning: imap_headerinfo() expects at least 2 parameters, 1 given in %s on line %d diff --git a/ext/imap/tests/imap_list_basic.phpt b/ext/imap/tests/imap_list_basic.phpt new file mode 100644 index 0000000000..36f07f755a --- /dev/null +++ b/ext/imap/tests/imap_list_basic.phpt @@ -0,0 +1,47 @@ +--TEST-- +imap_list() function : basic functionality +--CREDITS-- +Olivier Doucet +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +Checking with no parameters + +Warning: imap_list() expects exactly 3 parameters, 0 given in %s on line %d +Checking with incorrect parameter type + +Warning: imap_list() expects exactly 3 parameters, 1 given in %s on line %d + +Warning: imap_list() expects exactly 3 parameters, 1 given in %s on line %d + +Warning: imap_list() expects exactly 3 parameters, 1 given in %s on line %d + +Warning: imap_list() expects exactly 3 parameters, 2 given in %s on line %d +bool(true) +string(%s) "{%s}%s" \ No newline at end of file diff --git a/ext/imap/tests/imap_lsub_basic.phpt b/ext/imap/tests/imap_lsub_basic.phpt new file mode 100644 index 0000000000..153ca2a1bf --- /dev/null +++ b/ext/imap/tests/imap_lsub_basic.phpt @@ -0,0 +1,61 @@ +--TEST-- +imap_lsub() function : basic functionality +--CREDITS-- +Olivier Doucet +--SKIPIF-- + +--FILE-- + +--CLEAN-- + +--EXPECTF-- +Checking with no parameters + +Warning: imap_lsub() expects exactly 3 parameters, 0 given in %s on line %d +Checking with incorrect parameter type + +Warning: imap_lsub() expects exactly 3 parameters, 1 given in %s on line %d + +Warning: imap_lsub() expects exactly 3 parameters, 1 given in %s on line %d + +Warning: imap_lsub() expects exactly 3 parameters, 1 given in %s on line %d + +Warning: imap_lsub() expects exactly 3 parameters, 2 given in %s on line %d +bool(false) +Checking OK +bool(true) +string(%s) "{%s}%s" \ No newline at end of file diff --git a/ext/imap/tests/imap_mail_copy.phpt b/ext/imap/tests/imap_mail_copy.phpt new file mode 100644 index 0000000000..47c5e61bb0 --- /dev/null +++ b/ext/imap/tests/imap_mail_copy.phpt @@ -0,0 +1,54 @@ +--TEST-- +Test imap_mail_copy() incorrect parameters +--CREDITS-- +Olivier Doucet +--SKIPIF-- + +--FILE-- + +===Done=== +--EXPECTF-- +Checking with no parameters + +Warning: imap_mail_copy() expects at least 3 parameters, 0 given in %s on line %d +Checking with incorrect parameter type + +Warning: imap_mail_copy() expects at least 3 parameters, 1 given in %s on line %d + +Warning: imap_mail_copy() expects at least 3 parameters, 1 given in %s on line %d +Test with IMAP server + +Warning: imap_mail_copy() expects at least 3 parameters, 1 given in %s on line %d +NULL + +Warning: imap_mail_copy() expects at least 3 parameters, 2 given in %s on line %d +NULL + +Warning: imap_mail_copy() expects at least 3 parameters, 2 given in %s on line %d +NULL +===Done=== \ No newline at end of file diff --git a/ext/imap/tests/imap_mail_copy_basic.phpt b/ext/imap/tests/imap_mail_copy_basic.phpt new file mode 100644 index 0000000000..a7b9421e31 --- /dev/null +++ b/ext/imap/tests/imap_mail_copy_basic.phpt @@ -0,0 +1,46 @@ +--TEST-- +Test imap_mail_copy() function : basic functionality +--CREDITS-- +Olivier Doucet +--SKIPIF-- + +--FILE-- +Nmsgs . "\n"; + +var_dump(imap_mail_copy($imap_stream, '1', 'INBOX.'.$mailbox_prefix)); + +imap_close($imap_stream); +?> +===Done=== +--CLEAN-- + +--EXPECTF-- +*** Testing imap_mail_copy() : basic functionality *** +Create a new mailbox for test +Create a temporary mailbox and add 1 msgs +.. mailbox '%s' created +Msg Count in new mailbox: 1 +bool(true) +===Done=== \ No newline at end of file diff --git a/ext/imap/tests/imap_mail_move.phpt b/ext/imap/tests/imap_mail_move.phpt new file mode 100644 index 0000000000..67ddea713a --- /dev/null +++ b/ext/imap/tests/imap_mail_move.phpt @@ -0,0 +1,54 @@ +--TEST-- +Test imap_mail_move() incorrect parameters +--CREDITS-- +Olivier Doucet +--SKIPIF-- + +--FILE-- + +===Done=== +--EXPECTF-- +Checking with no parameters + +Warning: imap_mail_move() expects at least 3 parameters, 0 given in %s on line %d +Checking with incorrect parameter type + +Warning: imap_mail_move() expects at least 3 parameters, 1 given in %s on line %d + +Warning: imap_mail_move() expects at least 3 parameters, 1 given in %s on line %d +Test with IMAP server + +Warning: imap_mail_move() expects at least 3 parameters, 1 given in %s on line %d +NULL + +Warning: imap_mail_move() expects at least 3 parameters, 2 given in %s on line %d +NULL + +Warning: imap_mail_move() expects at least 3 parameters, 2 given in %s on line %d +NULL +===Done=== \ No newline at end of file diff --git a/ext/imap/tests/imap_mail_move_basic.phpt b/ext/imap/tests/imap_mail_move_basic.phpt new file mode 100644 index 0000000000..a543582565 --- /dev/null +++ b/ext/imap/tests/imap_mail_move_basic.phpt @@ -0,0 +1,46 @@ +--TEST-- +Test imap_mail_move() function : basic functionality +--CREDITS-- +Olivier Doucet +--SKIPIF-- + +--FILE-- +Nmsgs . "\n"; + +var_dump(imap_mail_move($imap_stream, '1', 'INBOX.'.$mailbox_prefix)); + +imap_close($imap_stream); +?> +===Done=== +--CLEAN-- + +--EXPECTF-- +*** Testing imap_mail_move() : basic functionality *** +Create a new mailbox for test +Create a temporary mailbox and add 1 msgs +.. mailbox '%s' created +Msg Count in new mailbox: 1 +bool(true) +===Done=== \ No newline at end of file diff --git a/ext/imap/tests/imap_open_error.phpt b/ext/imap/tests/imap_open_error.phpt index 7934ee2ef7..83b0eba80e 100644 --- a/ext/imap/tests/imap_open_error.phpt +++ b/ext/imap/tests/imap_open_error.phpt @@ -20,6 +20,9 @@ echo "Checking with incorrect parameters\n" ; imap_open('', '', ''); imap_open('', '', '', -1); +require_once(dirname(__FILE__).'/imap_include.inc'); +imap_open($default_mailbox, $username, $password, NIL, -1); + ?> --EXPECTF-- Checking with no parameters @@ -39,4 +42,6 @@ Warning: imap_open(): Couldn't open stream in %s on line %d Warning: imap_open(): Couldn't open stream in %s on line %d +Warning: imap_open(): Retries must be greater or equal to 0 in %s on line %d + Notice: Unknown: Can't open mailbox : no such mailbox (errflg=2) in Unknown on line 0 diff --git a/ext/imap/tests/imap_renamemailbox_basic.phpt b/ext/imap/tests/imap_renamemailbox_basic.phpt new file mode 100644 index 0000000000..b445f1d3e4 --- /dev/null +++ b/ext/imap/tests/imap_renamemailbox_basic.phpt @@ -0,0 +1,66 @@ +--TEST-- +imap_renamemailbox() function : basic functionality +--CREDITS-- +Olivier Doucet +--SKIPIF-- + +--FILE-- + +--CLEAN-- + +--EXPECTF-- +Checking with no parameters + +Warning: imap_renamemailbox() expects exactly 3 parameters, 0 given in %s on line %d +Checking with incorrect parameter type + +Warning: imap_renamemailbox() expects exactly 3 parameters, 1 given in %s on line %d + +Warning: imap_renamemailbox() expects exactly 3 parameters, 1 given in %s on line %d +Create a temporary mailbox and add 1 msgs +.. mailbox '{%s}%s' created + +Warning: imap_renamemailbox() expects exactly 3 parameters, 2 given in %s on line %d + +Warning: imap_renamemailbox() expects exactly 3 parameters, 2 given in %s on line %d +Checking OK +bool(true) +bool(true) diff --git a/ext/imap/tests/imap_rfc822_parse_headers_basic.phpt b/ext/imap/tests/imap_rfc822_parse_headers_basic.phpt new file mode 100644 index 0000000000..e4253925d2 --- /dev/null +++ b/ext/imap/tests/imap_rfc822_parse_headers_basic.phpt @@ -0,0 +1,122 @@ +--TEST-- +imap_rfc822_parse_headers() function : basic functionality +--CREDITS-- +Olivier Doucet +--SKIPIF-- + +--FILE-- +$key)); +} + +echo "Check type\n"; +var_dump($z->toaddress); +var_dump($z->fromaddress); +var_dump($z->reply_toaddress); +var_dump($z->senderaddress); +var_dump($z->subject); +var_dump($z->Subject); + +if ($z->Recent == 'R' || $z->Recent == 'N' || $z->Recent == ' ') { + echo "Recent: OK"; +} else { + echo "Recent: error"; +} +echo "\n"; + +if ($z->Unseen == 'U' || $z->Unseen == ' ') { + echo "Unseen: OK"; +} else { + echo "Unseen: error"; +} +echo "\n"; + +if ($z->Flagged == 'F' || $z->Flagged == ' ') { + echo "Flagged: OK"; +} else { + echo "Flagged: error"; +} +echo "\n"; + +if ($z->Answered == 'A' || $z->Answered == ' ') { + echo "Answered: OK"; +} else { + echo "Answered: error"; +} +echo "\n"; + +if ($z->Deleted == 'D' || $z->Deleted == ' ') { + echo "Deleted: OK"; +} else { + echo "Deleted: error"; +} +echo "\n"; + +if ($z->Draft == 'X' || $z->Draft == ' ') { + echo "Draft: OK"; +} else { + echo "Draft: error"; +} +echo "\n"; + +var_dump($z->Msgno); +var_dump($z->Size); +var_dump($z->udate); + +imap_close($stream_id); + +?> +--CLEAN-- + +--EXPECTF-- +Create a temporary mailbox and add 1 msgs +.. mailbox '{%s}%s' created +Check general fields +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +Check type +string(%d) "%s" +string(%d) "%s" +string(%d) "%s" +string(%d) "%s" +string(%d) "%s" +string(%d) "%s" +Recent: OK +Unseen: OK +Flagged: OK +Answered: OK +Deleted: OK +Draft: OK +string(%d) "%s" +string(%d) "%d" +int(%d) \ No newline at end of file diff --git a/ext/imap/tests/imap_savebody_basic.phpt b/ext/imap/tests/imap_savebody_basic.phpt new file mode 100644 index 0000000000..91e6ce03e9 --- /dev/null +++ b/ext/imap/tests/imap_savebody_basic.phpt @@ -0,0 +1,61 @@ +--TEST-- +imap_savebody() function : basic functionality +--CREDITS-- +Olivier Doucet +--SKIPIF-- + +--FILE-- + +--CLEAN-- + +--EXPECTF-- +Checking with no parameters + +Warning: imap_savebody() expects at least 3 parameters, 0 given in %s on line %d +Checking with incorrect parameter type + +Warning: imap_savebody() expects at least 3 parameters, 1 given in %s on line %d + +Warning: imap_savebody() expects at least 3 parameters, 1 given in %s on line %d +Create a temporary mailbox and add 1 msgs +.. mailbox '{%s}%s' created + +Warning: imap_savebody() expects at least 3 parameters, 1 given in %s on line %d +bool(true) +Size: %d +bool(true) +Size: %d + diff --git a/ext/imap/tests/imap_timeout_basic.phpt b/ext/imap/tests/imap_timeout_basic.phpt new file mode 100644 index 0000000000..c2727e56b7 --- /dev/null +++ b/ext/imap/tests/imap_timeout_basic.phpt @@ -0,0 +1,60 @@ +--TEST-- +imap_timeout() function : basic functionality +--CREDITS-- +Olivier Doucet +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +Checking with no parameters + +Warning: imap_timeout() expects at least 1 parameter, 0 given in %s on line %d +Checking with incorrect parameter type + +Warning: imap_timeout() expects parameter 1 to be long, %s given in %s on line %d +GET values: +int(%d) +int(%d) +int(%d) +int(%d) +SET values: +bool(true) +bool(true) +bool(true) +CHECK values: +int(10) +int(10) +int(10) diff --git a/ext/imap/tests/imap_undelete_basic.phpt b/ext/imap/tests/imap_undelete_basic.phpt new file mode 100644 index 0000000000..4b48b1b09a --- /dev/null +++ b/ext/imap/tests/imap_undelete_basic.phpt @@ -0,0 +1,29 @@ +--TEST-- +imap_undelete() function : basic functionality +--CREDITS-- +Olivier Doucet +--SKIPIF-- + +--FILE-- + +--CLEAN-- + +--EXPECTF-- +Create a temporary mailbox and add 1 msgs +.. mailbox '{%s}%s' created +bool(true) \ No newline at end of file diff --git a/ext/imap/tests/imap_undelete_error.phpt b/ext/imap/tests/imap_undelete_error.phpt new file mode 100644 index 0000000000..c82801e15a --- /dev/null +++ b/ext/imap/tests/imap_undelete_error.phpt @@ -0,0 +1,36 @@ +--TEST-- +imap_undelete() incorrect parameter count +--CREDITS-- +Olivier Doucet +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +Checking with no parameters + +Warning: imap_undelete() expects at least 2 parameters, 0 given in %s on line %d +Checking with incorrect parameter type + +Warning: imap_undelete() expects at least 2 parameters, 1 given in %s on line %d + +Warning: imap_undelete() expects at least 2 parameters, 1 given in %s on line %d + +Warning: imap_undelete() expects at least 2 parameters, 1 given in %s on line %d