]> granicus.if.org Git - php/commitdiff
Add unit test for mail.log ini setting.
authorMartin Jansen <martin@divbyzero.net>
Sun, 6 Jan 2013 07:59:10 +0000 (08:59 +0100)
committerLars Strojny <lstrojny@php.net>
Sun, 6 Jan 2013 14:04:27 +0000 (15:04 +0100)
ext/standard/tests/mail/mail_log.phpt [new file with mode: 0644]

diff --git a/ext/standard/tests/mail/mail_log.phpt b/ext/standard/tests/mail/mail_log.phpt
new file mode 100644 (file)
index 0000000..86346ec
--- /dev/null
@@ -0,0 +1,48 @@
+--TEST--
+Test mail() function : mail.log ini setting
+--INI--
+sendmail_path=tee /tmp/mail.out >/dev/null
+mail.log = /tmp/mail.log
+--SKIPIF--
+<?php
+if(substr(PHP_OS, 0, 3) == "WIN")
+  die("skip Won't run on Windows");
+?>
+--FILE--
+<?php
+date_default_timezone_set("UTC");
+
+$logfile = ini_get("mail.log");
+if (file_exists($logfile)) {
+       unlink($logfile);
+}
+touch($logfile);
+clearstatcache();
+
+$to = "test@example.com";
+$subject = "mail.log test";
+$message = "Testing mail.log";
+$headers = "X-Test: 1";
+
+var_dump(filesize($logfile) == 0);
+clearstatcache();
+
+var_dump(mail($to, $subject, $message, $headers));
+
+var_dump(filesize($logfile) > 0);
+clearstatcache();
+
+echo file_get_contents($logfile);
+?>
+Done
+--CLEAN--
+<?php
+unlink("/tmp/mail.log");
+unlink("/tmp/mail.out");
+?>
+--EXPECTF--
+bool(true)
+bool(true)
+bool(true)
+[%d-%s-%d %d:%d:%d UTC] mail() on [%smail_log.php:%d]: To: test@example.com -- Headers: X-Test: 1
+Done