1--TEST--
2Test imap_close() function : basic functionality
3--EXTENSIONS--
4imap
5--SKIPIF--
6<?php
7require_once(__DIR__.'/setup/skipif.inc');
8?>
9--FILE--
10<?php
11echo "*** Testing imap_close() : basic functionality ***\n";
12
13// include file for required variables in imap_open()
14require_once(__DIR__.'/setup/imap_include.inc');
15
16// Initialize required variables
17$stream_id = setup_test_mailbox('imapclosebasic', 3, $mailbox); // set up temp mailbox with 3 messages
18$options = CL_EXPUNGE;
19
20// mark messages in inbox for deletion
21for ($i = 1; $i < 4; $i++) {
22    imap_delete($stream_id, $i);
23}
24
25// Calling imap_close() with all possible arguments
26echo "\n-- Call to imap_close() with all possible arguments --\n";
27var_dump( imap_close($stream_id, $options) );
28
29// check that CL_EXPUNGE worked
30$stream_id = imap_open($mailbox, IMAP_MAILBOX_USERNAME, IMAP_MAILBOX_PASSWORD);
31echo "There are now " . imap_num_msg($stream_id) . " msgs in mailbox '$mailbox'\n";
32
33// Calling imap_close() with mandatory arguments
34echo "\n-- Call to imap_close() with mandatory arguments --\n";
35var_dump( imap_close($stream_id) );
36?>
37--CLEAN--
38<?php
39$mailbox_suffix = 'imapclosebasic';
40require_once(__DIR__.'/setup/clean.inc');
41?>
42--EXPECTF--
43*** Testing imap_close() : basic functionality ***
44Create a temporary mailbox and add 3 msgs
45New mailbox created
46
47-- Call to imap_close() with all possible arguments --
48bool(true)
49There are now 0 msgs in mailbox '%sINBOX.phpttestimapclosebasic'
50
51-- Call to imap_close() with mandatory arguments --
52bool(true)
53