diff options
author | Olivier DOUCET <odoucet@php.net> | 2009-11-23 21:48:57 +0000 |
---|---|---|
committer | Olivier DOUCET <odoucet@php.net> | 2009-11-23 21:48:57 +0000 |
commit | db8c6d5dcfbb737d1d45e452e6ec6d49628381f3 (patch) | |
tree | f079c38ec2ffcaf769196398dae5e51d7d770bbb /ext/imap | |
parent | eab96b63ca5f3d31c1b2a53152984c104bbdb504 (diff) | |
download | php-git-db8c6d5dcfbb737d1d45e452e6ec6d49628381f3.tar.gz |
Adding IMAP tests (PHP 5.3)
Diffstat (limited to 'ext/imap')
-rw-r--r-- | ext/imap/tests/imap_body.phpt | 21 | ||||
-rw-r--r-- | ext/imap/tests/imap_fetchstructure_basic.phpt | 70 | ||||
-rw-r--r-- | ext/imap/tests/imap_gc_error.phpt | 7 | ||||
-rw-r--r-- | ext/imap/tests/imap_getsubscribed_basic.phpt | 68 | ||||
-rw-r--r-- | ext/imap/tests/imap_headerinfo_basic.phpt | 129 | ||||
-rw-r--r-- | ext/imap/tests/imap_headerinfo_error.phpt | 36 | ||||
-rw-r--r-- | ext/imap/tests/imap_list_basic.phpt | 47 | ||||
-rw-r--r-- | ext/imap/tests/imap_lsub_basic.phpt | 61 | ||||
-rw-r--r-- | ext/imap/tests/imap_mail_copy.phpt | 54 | ||||
-rw-r--r-- | ext/imap/tests/imap_mail_copy_basic.phpt | 46 | ||||
-rw-r--r-- | ext/imap/tests/imap_mail_move.phpt | 54 | ||||
-rw-r--r-- | ext/imap/tests/imap_mail_move_basic.phpt | 46 | ||||
-rw-r--r-- | ext/imap/tests/imap_open_error.phpt | 5 | ||||
-rw-r--r-- | ext/imap/tests/imap_renamemailbox_basic.phpt | 66 | ||||
-rw-r--r-- | ext/imap/tests/imap_rfc822_parse_headers_basic.phpt | 122 | ||||
-rw-r--r-- | ext/imap/tests/imap_savebody_basic.phpt | 61 | ||||
-rw-r--r-- | ext/imap/tests/imap_timeout_basic.phpt | 60 | ||||
-rw-r--r-- | ext/imap/tests/imap_undelete_basic.phpt | 29 | ||||
-rw-r--r-- | ext/imap/tests/imap_undelete_error.phpt | 36 |
19 files changed, 1018 insertions, 0 deletions
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-- +<?php +require_once(dirname(__FILE__).'/skipif.inc'); +?> +--FILE-- +<?php +echo "Checking with no parameters\n"; +imap_fetchstructure(); + +echo "Checking with incorrect parameter type\n"; +imap_fetchstructure(''); +imap_fetchstructure(false); + +require_once(dirname(__FILE__).'/imap_include.inc'); +$stream_id = setup_test_mailbox('', 1); + +imap_fetchstructure($stream_id); +imap_fetchstructure($stream_id,0); + +$z = imap_fetchstructure($stream_id,1); + + +$fields = array('type','encoding','ifsubtype','subtype', +'ifdescription','lines','bytes','parameters'); + +foreach ($fields as $key) { + var_dump(isset($z->$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-- +<?php +require_once('clean.inc'); +?> +--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-- +<?php +require_once(dirname(__FILE__).'/skipif.inc'); +?> +--FILE-- +<?php +echo "Checking with no parameters\n"; +imap_getsubscribed(); + +echo "Checking with incorrect parameter type\n"; +imap_getsubscribed(''); +imap_getsubscribed(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_getsubscribed($stream_id); +imap_getsubscribed($stream_id,$default_mailbox); +var_dump(imap_getsubscribed($stream_id,$default_mailbox,'ezDvfXvbvcxSerz')); + + +echo "Checking OK\n"; + +$newbox = $default_mailbox . "." . $mailbox_prefix; + +imap_createmailbox($stream_id, $newbox); +imap_subscribe($stream_id, $newbox); + +$z = imap_getsubscribed($stream_id,$default_mailbox,'*'); + +var_dump(is_array($z)); +var_dump($z[0]); + +imap_close($stream_id); +?> +--CLEAN-- +<?php +require_once('clean.inc'); +?> +--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-- +<?php +require_once(dirname(__FILE__).'/skipif.inc'); +?> +--FILE-- +<?php + +require_once(dirname(__FILE__).'/imap_include.inc'); +$stream_id = setup_test_mailbox('', 1); + +$z = imap_headerinfo($stream_id, 1); + +$fields = array ('toaddress','to','fromaddress','from', +'reply_toaddress','reply_to', + 'senderaddress', 'sender', +'subject','Subject', + 'Recent','Unseen','Flagged','Answered','Deleted','Draft', + 'Msgno','MailDate','Size','udate'); + +echo "Check general fields\n"; +foreach ($fields as $key) { + var_dump(isset($z->$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-- +<?php +require_once('clean.inc'); +?> +--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-- +<?php +require_once(dirname(__FILE__).'/skipif.inc'); +?> +--FILE-- +<?php +echo "Checking with no parameters\n"; +imap_headerinfo(); + +echo "Checking with incorrect parameter type\n"; +imap_headerinfo(''); +imap_headerinfo(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_headerinfo($stream_id); + +imap_close($stream_id); +?> +--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-- +<?php +require_once(dirname(__FILE__).'/skipif.inc'); +?> +--FILE-- +<?php +echo "Checking with no parameters\n"; +imap_list(); + +echo "Checking with incorrect parameter type\n"; +imap_list(''); +imap_list(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_list($stream_id); +imap_list($stream_id,$default_mailbox); +imap_list($stream_id,$default_mailbox,'ezerz'); + + +$z = imap_list($stream_id,$default_mailbox,'*'); +var_dump(is_array($z)); +var_dump($z[0]); + +imap_close($stream_id); +?> +--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-- +<?php +require_once(dirname(__FILE__).'/skipif.inc'); +?> +--FILE-- +<?php +echo "Checking with no parameters\n"; +imap_lsub(); + +echo "Checking with incorrect parameter type\n"; +imap_lsub(''); +imap_lsub(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_lsub($stream_id); +imap_lsub($stream_id,$default_mailbox); +var_dump(imap_lsub($stream_id,$default_mailbox,'ezDvfXvbvcxSerz')); + + +echo "Checking OK\n"; + +$newbox = $default_mailbox . "." . $mailbox_prefix; + +imap_createmailbox($stream_id, $newbox); +imap_subscribe($stream_id, $newbox); + +$z = imap_lsub($stream_id,$default_mailbox,'*'); + +var_dump(is_array($z)); +var_dump($z[0]); + +imap_close($stream_id); +?> +--CLEAN-- +<?php +require_once('clean.inc'); +?> +--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-- +<?php +require_once(dirname(__FILE__).'/skipif.inc'); +?> +--FILE-- +<?php +echo "Checking with no parameters\n"; +imap_mail_copy(); + + +echo "Checking with incorrect parameter type\n"; +imap_mail_copy(''); +imap_mail_copy(false); + + +// more tests +require_once(dirname(__FILE__).'/imap_include.inc'); + + +echo "Test with IMAP server\n"; +$stream_id = imap_open($default_mailbox, $username, $password) or + die("Cannot connect to mailbox $default_mailbox: " . imap_last_error()); + +var_dump(imap_mail_copy($stream_id)); +var_dump(imap_mail_copy($stream_id,-1)); +var_dump(imap_mail_copy($stream_id, '')); + +imap_close($stream_id); +?> +===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-- +<?php +require_once(dirname(__FILE__).'/skipif.inc'); +?> +--FILE-- +<?php +/* Prototype : bool imap_mail_copy ( resource $imap_stream , string $msglist , string $mailbox [, int $options = 0 ] ) + * Description: Copies mail messages specified by msglist to specified mailbox. + * Source code: ext/imap/php_imap.c + */ + +echo "*** Testing imap_mail_copy() : basic functionality ***\n"; + +require_once(dirname(__FILE__).'/imap_include.inc'); + + +echo "Create a new mailbox for test\n"; +$imap_stream = setup_test_mailbox("", 1); +if (!is_resource($imap_stream)) { + exit("TEST FAILED: Unable to create test mailbox\n"); +} + +$check = imap_check($imap_stream); +echo "Msg Count in new mailbox: ". $check->Nmsgs . "\n"; + +var_dump(imap_mail_copy($imap_stream, '1', 'INBOX.'.$mailbox_prefix)); + +imap_close($imap_stream); +?> +===Done=== +--CLEAN-- +<?php +require_once('clean.inc'); +?> +--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-- +<?php +require_once(dirname(__FILE__).'/skipif.inc'); +?> +--FILE-- +<?php +echo "Checking with no parameters\n"; +imap_mail_move(); + + +echo "Checking with incorrect parameter type\n"; +imap_mail_move(''); +imap_mail_move(false); + + +// more tests +require_once(dirname(__FILE__).'/imap_include.inc'); + + +echo "Test with IMAP server\n"; +$stream_id = imap_open($default_mailbox, $username, $password) or + die("Cannot connect to mailbox $default_mailbox: " . imap_last_error()); + +var_dump(imap_mail_move($stream_id)); +var_dump(imap_mail_move($stream_id,-1)); +var_dump(imap_mail_move($stream_id, '')); + +imap_close($stream_id); +?> +===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-- +<?php +require_once(dirname(__FILE__).'/skipif.inc'); +?> +--FILE-- +<?php +/* Prototype : bool imap_mail_move ( resource $imap_stream , string $msglist , string $mailbox [, int $options = 0 ] ) + * Description: Copies mail messages specified by msglist to specified mailbox. + * Source code: ext/imap/php_imap.c + */ + +echo "*** Testing imap_mail_move() : basic functionality ***\n"; + +require_once(dirname(__FILE__).'/imap_include.inc'); + + +echo "Create a new mailbox for test\n"; +$imap_stream = setup_test_mailbox("", 1); +if (!is_resource($imap_stream)) { + exit("TEST FAILED: Unable to create test mailbox\n"); +} + +$check = imap_check($imap_stream); +echo "Msg Count in new mailbox: ". $check->Nmsgs . "\n"; + +var_dump(imap_mail_move($imap_stream, '1', 'INBOX.'.$mailbox_prefix)); + +imap_close($imap_stream); +?> +===Done=== +--CLEAN-- +<?php +require_once('clean.inc'); +?> +--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-- +<?php +require_once(dirname(__FILE__).'/skipif.inc'); +?> +--FILE-- +<?php +echo "Checking with no parameters\n"; +imap_renamemailbox(); + +echo "Checking with incorrect parameter type\n"; +imap_renamemailbox(''); +imap_renamemailbox(false); + + +require_once(dirname(__FILE__).'/imap_include.inc'); + +$stream_id = setup_test_mailbox('', 1); + +if (!is_resource($stream_id)) { + exit("TEST FAILED: Unable to create test mailbox\n"); +} + +$newbox = $default_mailbox . "." . $mailbox_prefix; + +imap_renamemailbox($stream_id, $newbox.'not'); +imap_renamemailbox($stream_id, $newbox); + +//commented because of bug #49901 +//$ancError = error_reporting(0); +//$z = imap_renamemailbox($stream_id, $newbox.'not2', $newbox.'2'); +//var_dump($z); +//error_reporting($ancError); +echo "Checking OK\n"; + + +var_dump(imap_createmailbox($stream_id, $newbox.'.test')); +var_dump(imap_renamemailbox($stream_id, $newbox.'.test', $newbox.'.testd')); + +imap_close($stream_id); +?> +--CLEAN-- +<?php +require_once('clean.inc'); +?> +--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-- +<?php +require_once(dirname(__FILE__).'/skipif.inc'); +?> +--FILE-- +<?php + +require_once(dirname(__FILE__).'/imap_include.inc'); +$stream_id = setup_test_mailbox('', 1); + +$z = imap_headerinfo($stream_id, 1); + +$fields = array ('toaddress','to','fromaddress','from', +'reply_toaddress','reply_to', + 'senderaddress', 'sender', +'subject','Subject', + 'MailDate','Size','udate'); + + +echo "Check general fields\n"; +foreach ($fields as $key) { + var_dump(isset($z->$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-- +<?php +require_once('clean.inc'); +?> +--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-- +<?php +require_once(dirname(__FILE__).'/skipif.inc'); +?> +--FILE-- +<?php +echo "Checking with no parameters\n"; +imap_savebody(); + +echo "Checking with incorrect parameter type\n"; +imap_savebody(''); +imap_savebody(false); + +require_once(dirname(__FILE__).'/imap_include.inc'); +$stream_id = setup_test_mailbox('', 1); + +imap_savebody($stream_id); + +$file = dirname(__FILE__).'/tmpsavebody.txt'; + +//with URL +$z = imap_savebody($stream_id, $file, 1); +var_dump($z); +echo "Size: ".filesize($file)."\n"; + +//With FOPEN +$fp = fopen($file, 'w'); +$z = imap_savebody($stream_id, $fp, 1); +fclose($fp); +var_dump($z); +echo "Size: ".filesize($file)."\n"; + +imap_close($stream_id); +?> +--CLEAN-- +<?php +@unlink(dirname(__FILE__).'/tmpsavebody.txt'); +require_once('clean.inc'); +?> +--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-- +<?php +require_once(dirname(__FILE__).'/skipif.inc'); +?> +--FILE-- +<?php +echo "Checking with no parameters\n"; +imap_timeout(); + +echo "Checking with incorrect parameter type\n"; +imap_timeout(''); +imap_timeout(false); + +echo "GET values:\n"; +var_dump(imap_timeout(IMAP_OPENTIMEOUT)); +var_dump(imap_timeout(IMAP_READTIMEOUT)); +var_dump(imap_timeout(IMAP_WRITETIMEOUT)); +var_dump(imap_timeout(IMAP_CLOSETIMEOUT)); + +echo "SET values:\n"; +var_dump(imap_timeout(IMAP_OPENTIMEOUT, 10)); +var_dump(imap_timeout(IMAP_READTIMEOUT, 10)); +var_dump(imap_timeout(IMAP_WRITETIMEOUT, 10)); + +//IMAP_CLOSETIMEOUT not implemented +//var_dump(imap_timeout(IMAP_CLOSETIMEOUT, 10)); + +echo "CHECK values:\n"; +var_dump(imap_timeout(IMAP_OPENTIMEOUT)); +var_dump(imap_timeout(IMAP_READTIMEOUT)); +var_dump(imap_timeout(IMAP_WRITETIMEOUT)); + +//IMAP_CLOSETIMEOUT not implemented +//var_dump(imap_timeout(IMAP_CLOSETIMEOUT)); + +?> +--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-- +<?php +require_once(dirname(__FILE__).'/skipif.inc'); +?> +--FILE-- +<?php + +require_once(dirname(__FILE__).'/imap_include.inc'); +$stream_id = setup_test_mailbox('', 1); + +imap_delete($stream_id, 1); + +var_dump(imap_undelete($stream_id, 1)); + +imap_close($stream_id); + +?> +--CLEAN-- +<?php +require_once('clean.inc'); +?> +--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-- +<?php +require_once(dirname(__FILE__).'/skipif.inc'); +?> +--FILE-- +<?php +echo "Checking with no parameters\n"; +imap_undelete(); + +echo "Checking with incorrect parameter type\n"; +imap_undelete(''); +imap_undelete(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_undelete($stream_id); + +imap_close($stream_id); +?> +--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 |