forked from php/php-src
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathimap_fetchheader_variation5.phpt
61 lines (50 loc) · 1.4 KB
/
imap_fetchheader_variation5.phpt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
--TEST--
Test imap_fetchheader() function : usage variations - $message_num argument
--EXTENSIONS--
imap
--SKIPIF--
<?php
require_once(__DIR__.'/setup/skipif.inc');
?>
--FILE--
<?php
/*
* Pass different integers and strings as $message_num argument
* to test behaviour of imap_fetchheader()
*/
echo "*** Testing imap_fetchheader() : usage variations ***\n";
require_once(__DIR__.'/setup/imap_include.inc');
$stream_id = setup_test_mailbox('imapfetchheadervar5', 3, $mailbox, false); // set up temp mailbox with 3 msgs
$sequences = [0, /* out of range */ 4, 1];
foreach($sequences as $message_num) {
echo "\n-- \$message_num is $message_num --\n";
try {
var_dump(imap_fetchheader($stream_id, $message_num));
} catch (\ValueError $e) {
echo $e->getMessage() . \PHP_EOL;
}
}
// clear error stack
imap_errors();
?>
--CLEAN--
<?php
$mailbox_suffix = 'imapfetchheadervar5';
require_once(__DIR__.'/setup/clean.inc');
?>
--EXPECTF--
*** Testing imap_fetchheader() : usage variations ***
Create a temporary mailbox and add 3 msgs
New mailbox created
-- $message_num is 0 --
imap_fetchheader(): Argument #2 ($message_num) must be greater than 0
-- $message_num is 4 --
Warning: imap_fetchheader(): Bad message number in %s on line %d
bool(false)
-- $message_num is 1 --
string(%d) "From: foo@anywhere.com
Subject: Test msg 1
To: %s
MIME-Version: 1.0
Content-Type: MULTIPART/mixed; BOUNDARY="%s=:%d"
"