diff options
author | Wez Furlong <wez@php.net> | 2002-04-03 13:38:43 +0000 |
---|---|---|
committer | Wez Furlong <wez@php.net> | 2002-04-03 13:38:43 +0000 |
commit | 74dd73711b85c2d04cc85f6bc6778275172da2b2 (patch) | |
tree | 2717e52eb9d690154037be447815bbe5615153df | |
parent | 5f53f02d14e5b8de5f721fd7eb8e19a70bd5e965 (diff) | |
download | php-git-74dd73711b85c2d04cc85f6bc6778275172da2b2.tar.gz |
add test for mailparse_extract_part_file
-rw-r--r-- | ext/mailparse/tests/006.phpt | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/ext/mailparse/tests/006.phpt b/ext/mailparse/tests/006.phpt new file mode 100644 index 0000000000..2d8c79efb7 --- /dev/null +++ b/ext/mailparse/tests/006.phpt @@ -0,0 +1,88 @@ +--TEST-- +Check extract_part_file +--SKIPIF-- +<?php if (!extension_loaded("mailparse")) print "skip"; ?> +--POST-- +--GET-- +--FILE-- +<?php +$text = <<<EOD +To: fred@bloggs.com +Mime-Version: 1.0 +Content-Type: text/plain +Subject: A simple MIME message + +hello, this is some text hello. +blah blah blah. + +EOD; + +$fp = tmpfile(); +fwrite($fp, $text); +rewind($fp); + + +$mime = mailparse_msg_create(); +mailparse_msg_parse($mime, $text); + +echo "Extract to output\n"; +mailparse_msg_extract_part_file($mime, $fp); + +echo "Extract and return as string\n"; +$result = mailparse_msg_extract_part_file($mime, $fp, null); +echo "-->\n"; +echo $result; + +echo "Extract to open file\n"; +$fpdest = tmpfile(); +mailparse_msg_extract_part_file($mime, $fp, $fpdest); +echo "rewinding\n"; +rewind($fpdest); +fpassthru($fpdest); + +echo "Extract via user function\n"; +$cbdata = ""; +function callback($data) { + $GLOBALS["cbdata"] .= $data; +} +mailparse_msg_extract_part_file($mime, $fp, "callback"); +echo "callback data is:\n"; +echo $cbdata; + +echo "Extract whole part to output\n"; +mailparse_msg_extract_whole_part_file($mime, $fp); + +echo "Extract part from string to output\n"; +mailparse_msg_extract_part($mime, $text); +fclose($fpdest); +fclose($fp); + +?> +--EXPECT-- +Extract to output +hello, this is some text hello. +blah blah blah. +Extract and return as string +--> +hello, this is some text hello. +blah blah blah. +Extract to open file +rewinding +hello, this is some text hello. +blah blah blah. +Extract via user function +callback data is: +hello, this is some text hello. +blah blah blah. +Extract whole part to output +To: fred@bloggs.com +Mime-Version: 1.0 +Content-Type: text/plain +Subject: A simple MIME message + +hello, this is some text hello. +blah blah blah. +Extract part from string to output +hello, this is some text hello. +blah blah blah. + |