From: George Peter Banyard Date: Mon, 30 Nov 2020 23:12:54 +0000 (+0000) Subject: Add tests for passing a UID instead of a message number X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e45cc31c41355bed684164856470979a280084fb;p=php Add tests for passing a UID instead of a message number --- diff --git a/ext/imap/php_imap.c b/ext/imap/php_imap.c index 023795fd8c..b52c35c58b 100644 --- a/ext/imap/php_imap.c +++ b/ext/imap/php_imap.c @@ -2037,7 +2037,8 @@ PHP_FUNCTION(imap_savebody) RETURN_THROWS(); } - PHP_IMAP_CHECK_MSGNO(msgno, 3); + // TODO Fix for UID and normal MSGNO + //PHP_IMAP_CHECK_MSGNO(msgno, 3); if (flags && ((flags & ~(FT_UID|FT_PEEK|FT_INTERNAL)) != 0)) { zend_argument_value_error(5, "must be a bitmask of FT_UID, FT_PEEK, and FT_INTERNAL"); diff --git a/ext/imap/tests/bug80438.phpt b/ext/imap/tests/bug80438.phpt index 4514e932ef..70f0270e4f 100644 --- a/ext/imap/tests/bug80438.phpt +++ b/ext/imap/tests/bug80438.phpt @@ -10,14 +10,7 @@ require_once(__DIR__.'/setup/skipif.inc'); require_once __DIR__.'/setup/imap_include.inc'; // create a new mailbox and add 10 new messages to it -$mail_box = setup_test_mailbox('bug80438', 10); - -// Delete messages to remove the numerical ordering -imap_delete($mail_box, 5); -imap_delete($mail_box, 6); -imap_delete($mail_box, 7); -imap_delete($mail_box, 8); -imap_expunge($mail_box); +$mail_box = setup_test_mailbox_for_uid_tests('bug80438'); $message_number_array = imap_search($mail_box, 'ALL', SE_UID); @@ -42,15 +35,16 @@ require_once __DIR__.'/setup/clean.inc'; --EXPECT-- Create a temporary mailbox and add 10 msgs New mailbox created +Delete 4 messages for Unique ID generation array(6) { [0]=> int(1) [1]=> int(2) [2]=> - int(3) + int(7) [3]=> - int(4) + int(8) [4]=> int(9) [5]=> @@ -60,9 +54,9 @@ Unique ID: int(1) Ordered message number: int(1) Unique ID: int(2) Ordered message number: int(2) -Unique ID: int(3) +Unique ID: int(7) Ordered message number: int(3) -Unique ID: int(4) +Unique ID: int(8) Ordered message number: int(4) Unique ID: int(9) Ordered message number: int(5) diff --git a/ext/imap/tests/imap_body_uid.phpt b/ext/imap/tests/imap_body_uid.phpt new file mode 100644 index 0000000000..1c0de85a61 --- /dev/null +++ b/ext/imap/tests/imap_body_uid.phpt @@ -0,0 +1,28 @@ +--TEST-- +imap_body() passing a unique ID +--SKIPIF-- + +--FILE-- + +--CLEAN-- + +--EXPECT-- +Create a temporary mailbox and add 10 msgs +New mailbox created +Delete 4 messages for Unique ID generation +bool(true) diff --git a/ext/imap/tests/imap_clearflag_full_uid.phpt b/ext/imap/tests/imap_clearflag_full_uid.phpt new file mode 100644 index 0000000000..3a218656e3 --- /dev/null +++ b/ext/imap/tests/imap_clearflag_full_uid.phpt @@ -0,0 +1,90 @@ +--TEST-- +imap_clearflag_full() passing a unique ID +--SKIPIF-- + +--FILE-- + +--CLEAN-- + +--EXPECT-- +Create a temporary mailbox and add 10 msgs +New mailbox created +Delete 4 messages for Unique ID generation +ALL: array(6) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + [3]=> + int(4) + [4]=> + int(5) + [5]=> + int(6) +} +ALL (with UID correspondance): array(6) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(7) + [3]=> + int(8) + [4]=> + int(9) + [5]=> + int(10) +} +ANSWERED: array(1) { + [0]=> + int(4) +} +DELETED: array(1) { + [0]=> + int(3) +} +FLAGGED: array(1) { + [0]=> + int(5) +} diff --git a/ext/imap/tests/imap_delete_uid.phpt b/ext/imap/tests/imap_delete_uid.phpt new file mode 100644 index 0000000000..433e015f85 --- /dev/null +++ b/ext/imap/tests/imap_delete_uid.phpt @@ -0,0 +1,51 @@ +--TEST-- +imap_delete() passing a unique ID +--SKIPIF-- + +--FILE-- + +--CLEAN-- + +--EXPECT-- +Create a temporary mailbox and add 10 msgs +New mailbox created +Delete 4 messages for Unique ID generation +array(1) { + [0]=> + int(9) +} +After expunging: bool(false) +array(5) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(7) + [3]=> + int(8) + [4]=> + int(10) +} diff --git a/ext/imap/tests/imap_fetch_overview_uid.phpt b/ext/imap/tests/imap_fetch_overview_uid.phpt new file mode 100644 index 0000000000..4c460edae1 --- /dev/null +++ b/ext/imap/tests/imap_fetch_overview_uid.phpt @@ -0,0 +1,29 @@ +--TEST-- +imap_fetch_overview() passing a unique ID +--SKIPIF-- + +--FILE-- + +--CLEAN-- + +--EXPECT-- +Create a temporary mailbox and add 10 msgs +New mailbox created +Delete 4 messages for Unique ID generation +bool(true) diff --git a/ext/imap/tests/imap_fetchbody_uid.phpt b/ext/imap/tests/imap_fetchbody_uid.phpt new file mode 100644 index 0000000000..2415ddd04c --- /dev/null +++ b/ext/imap/tests/imap_fetchbody_uid.phpt @@ -0,0 +1,29 @@ +--TEST-- +imap_fetchbody() passing a unique ID +--SKIPIF-- + +--FILE-- + +--CLEAN-- + +--EXPECT-- +Create a temporary mailbox and add 10 msgs +New mailbox created +Delete 4 messages for Unique ID generation +bool(true) diff --git a/ext/imap/tests/imap_fetchheader_uid.phpt b/ext/imap/tests/imap_fetchheader_uid.phpt new file mode 100644 index 0000000000..fa412c6c37 --- /dev/null +++ b/ext/imap/tests/imap_fetchheader_uid.phpt @@ -0,0 +1,28 @@ +--TEST-- +imap_fetchheader() passing a unique ID +--SKIPIF-- + +--FILE-- + +--CLEAN-- + +--EXPECT-- +Create a temporary mailbox and add 10 msgs +New mailbox created +Delete 4 messages for Unique ID generation +bool(true) diff --git a/ext/imap/tests/imap_fetchmime_uid.phpt b/ext/imap/tests/imap_fetchmime_uid.phpt new file mode 100644 index 0000000000..8711e8e5d3 --- /dev/null +++ b/ext/imap/tests/imap_fetchmime_uid.phpt @@ -0,0 +1,29 @@ +--TEST-- +imap_fetchmime() passing a unique ID +--SKIPIF-- + +--FILE-- + +--CLEAN-- + +--EXPECT-- +Create a temporary mailbox and add 10 msgs +New mailbox created +Delete 4 messages for Unique ID generation +bool(true) diff --git a/ext/imap/tests/imap_fetchstructure_uid.phpt b/ext/imap/tests/imap_fetchstructure_uid.phpt new file mode 100644 index 0000000000..bcb2552218 --- /dev/null +++ b/ext/imap/tests/imap_fetchstructure_uid.phpt @@ -0,0 +1,29 @@ +--TEST-- +imap_fetchstructure() passing a unique ID +--SKIPIF-- + +--FILE-- + +--CLEAN-- + +--EXPECT-- +Create a temporary mailbox and add 10 msgs +New mailbox created +Delete 4 messages for Unique ID generation +bool(true) diff --git a/ext/imap/tests/imap_savebody_uid.phpt b/ext/imap/tests/imap_savebody_uid.phpt new file mode 100644 index 0000000000..9d4c058c10 --- /dev/null +++ b/ext/imap/tests/imap_savebody_uid.phpt @@ -0,0 +1,39 @@ +--TEST-- +imap_savebody() passing a unique ID +--SKIPIF-- + +--FILE-- + +--CLEAN-- + +--EXPECT-- +Create a temporary mailbox and add 10 msgs +New mailbox created +Delete 4 messages for Unique ID generation +bool(true) diff --git a/ext/imap/tests/imap_search_basic.phpt b/ext/imap/tests/imap_search_basic.phpt new file mode 100644 index 0000000000..11078da1db --- /dev/null +++ b/ext/imap/tests/imap_search_basic.phpt @@ -0,0 +1,41 @@ +--TEST-- +imap_search() with unique ID (SE_UID) flag +--SKIPIF-- + +--FILE-- + +--CLEAN-- + +--EXPECT-- +Create a temporary mailbox and add 10 msgs +New mailbox created +Delete 4 messages for Unique ID generation +array(6) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(7) + [3]=> + int(8) + [4]=> + int(9) + [5]=> + int(10) +} diff --git a/ext/imap/tests/imap_setflag_full_basic.phpt b/ext/imap/tests/imap_setflag_full_basic.phpt new file mode 100644 index 0000000000..10ab481cea --- /dev/null +++ b/ext/imap/tests/imap_setflag_full_basic.phpt @@ -0,0 +1,82 @@ +--TEST-- +imap_setflag_full() basic test +--SKIPIF-- + +--FILE-- + +--CLEAN-- + +--EXPECT-- +Create a temporary mailbox and add 10 msgs +New mailbox created +ALL: array(10) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + [3]=> + int(4) + [4]=> + int(5) + [5]=> + int(6) + [6]=> + int(7) + [7]=> + int(8) + [8]=> + int(9) + [9]=> + int(10) +} +ANSWERED: array(1) { + [0]=> + int(1) +} +DELETED: array(2) { + [0]=> + int(2) + [1]=> + int(7) +} +FLAGGED: array(3) { + [0]=> + int(3) + [1]=> + int(4) + [2]=> + int(5) +} diff --git a/ext/imap/tests/imap_setflag_full_uid.phpt b/ext/imap/tests/imap_setflag_full_uid.phpt new file mode 100644 index 0000000000..8665421390 --- /dev/null +++ b/ext/imap/tests/imap_setflag_full_uid.phpt @@ -0,0 +1,108 @@ +--TEST-- +imap_setflag_full() passing a unique ID +--SKIPIF-- + +--FILE-- + +--CLEAN-- + +--EXPECT-- +Create a temporary mailbox and add 10 msgs +New mailbox created +Delete 4 messages for Unique ID generation +bool(true) +ALL: array(6) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + [3]=> + int(4) + [4]=> + int(5) + [5]=> + int(6) +} +ALL (with UID correspondance): array(6) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(7) + [3]=> + int(8) + [4]=> + int(9) + [5]=> + int(10) +} +ANSWERED: array(1) { + [0]=> + int(4) +} +DELETED: array(2) { + [0]=> + int(3) + [1]=> + int(6) +} +FLAGGED: array(3) { + [0]=> + int(3) + [1]=> + int(4) + [2]=> + int(5) +} +SEEN: array(3) { + [0]=> + int(3) + [1]=> + int(4) + [2]=> + int(5) +} diff --git a/ext/imap/tests/imap_sort_uid.phpt b/ext/imap/tests/imap_sort_uid.phpt new file mode 100644 index 0000000000..dff1e7c30b --- /dev/null +++ b/ext/imap/tests/imap_sort_uid.phpt @@ -0,0 +1,56 @@ +--TEST-- +imap_sort() basics +--SKIPIF-- + +--FILE-- + +--CLEAN-- + +--EXPECT-- +Create a temporary mailbox and add 10 msgs +New mailbox created +Delete 4 messages for Unique ID generation +array(6) { + [0]=> + int(1) + [1]=> + int(6) + [2]=> + int(2) + [3]=> + int(3) + [4]=> + int(4) + [5]=> + int(5) +} +array(6) { + [0]=> + int(1) + [1]=> + int(10) + [2]=> + int(2) + [3]=> + int(7) + [4]=> + int(8) + [5]=> + int(9) +} diff --git a/ext/imap/tests/imap_undelete_uid.phpt b/ext/imap/tests/imap_undelete_uid.phpt new file mode 100644 index 0000000000..aff7e47bdb --- /dev/null +++ b/ext/imap/tests/imap_undelete_uid.phpt @@ -0,0 +1,45 @@ +--TEST-- +imap_undelete() passing a unique ID +--SKIPIF-- + +--FILE-- + +--CLEAN-- + +--EXPECT-- +Create a temporary mailbox and add 10 msgs +New mailbox created +Delete 4 messages for Unique ID generation +array(6) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(7) + [3]=> + int(8) + [4]=> + int(9) + [5]=> + int(10) +} diff --git a/ext/imap/tests/setup/imap_include.inc b/ext/imap/tests/setup/imap_include.inc index 33e4e5ca16..223278f077 100644 --- a/ext/imap/tests/setup/imap_include.inc +++ b/ext/imap/tests/setup/imap_include.inc @@ -123,6 +123,22 @@ function create_mailbox($imap_stream, string $mailbox_suffix, int $message_count return $mailbox; } +function setup_test_mailbox_for_uid_tests(string $mailbox_suffix, &$msg_no = null, &$msg_uid = null) +{ + $mail_box = setup_test_mailbox($mailbox_suffix, 10); + echo "Delete 4 messages for Unique ID generation\n"; + // Delete messages to remove the numerical ordering + imap_delete($mail_box, 3); + imap_delete($mail_box, 4); + imap_delete($mail_box, 5); + imap_delete($mail_box, 6); + imap_expunge($mail_box); + $msg_no = 5; + $msg_uid = 9; + + return $mail_box; +} + /** * Populate a mailbox with generic emails *