|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* wp-mail-real-test.php |
|
4
|
|
|
* |
|
5
|
|
|
* Test script for wp_mail with real addresses. |
|
6
|
|
|
*/ |
|
7
|
|
|
|
|
8
|
|
|
// parse options |
|
9
|
|
|
$options = 'v:r:d'; |
|
10
|
|
|
if (is_callable('getopt')) { |
|
|
|
|
|
|
11
|
|
|
$opts = getopt($options); |
|
12
|
|
|
} else { |
|
13
|
|
|
include dirname(__FILE__) . '/wp-testlib/getopt.php'; |
|
14
|
|
|
$opts = getoptParser::getopt($options); |
|
15
|
|
|
} |
|
16
|
|
|
|
|
17
|
|
|
define('DIR_TESTROOT', realpath(dirname(__FILE__))); |
|
18
|
|
|
|
|
19
|
|
|
define('TEST_WP', true); |
|
20
|
|
|
define('WP_DEBUG', array_key_exists('d', $opts)); |
|
21
|
|
|
|
|
22
|
|
|
if (!empty($opts['r'])) { |
|
|
|
|
|
|
23
|
|
|
define('DIR_WP', realpath($opts['r'])); |
|
24
|
|
|
} else |
|
25
|
|
|
if (!empty($opts['v'])) { |
|
|
|
|
|
|
26
|
|
|
define('DIR_WP', DIR_TESTROOT.'/wordpress-'.$opts['v']); |
|
27
|
|
|
} else { |
|
28
|
|
|
define('DIR_WP', DIR_TESTROOT.'/wordpress'); |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
|
|
// make sure all useful errors are displayed during setup |
|
32
|
|
|
error_reporting(E_ALL & ~E_DEPRECATED); |
|
33
|
|
|
ini_set('display_errors', true); |
|
34
|
|
|
|
|
35
|
|
|
require_once DIR_TESTROOT.'/wp-testlib/utils.php'; |
|
36
|
|
|
|
|
37
|
|
|
// configure wp |
|
38
|
|
|
require_once DIR_TESTROOT.'/wp-config.php'; |
|
39
|
|
|
define('ABSPATH', realpath(DIR_WP).'/'); |
|
40
|
|
|
|
|
41
|
|
|
// install wp |
|
42
|
|
|
define('WP_BLOG_TITLE', rand_str()); |
|
43
|
|
|
define('WP_USER_NAME', rand_str()); |
|
44
|
|
|
define('WP_USER_EMAIL', rand_str().'@example.com'); |
|
45
|
|
|
|
|
46
|
|
|
// initialize wp |
|
47
|
|
|
define('WP_INSTALLING', 1); |
|
48
|
|
|
$_SERVER['PATH_INFO'] = $_SERVER['SCRIPT_NAME']; // prevent a warning from some sloppy code in wp-settings.php |
|
|
|
|
|
|
49
|
|
|
require_once ABSPATH.'wp-settings.php'; |
|
50
|
|
|
|
|
51
|
|
|
drop_tables(); |
|
52
|
|
|
|
|
53
|
|
|
require_once ABSPATH.'wp-admin/includes/upgrade.php'; |
|
54
|
|
|
wp_install(WP_BLOG_TITLE, WP_USER_NAME, WP_USER_EMAIL, true); |
|
55
|
|
|
|
|
56
|
|
|
// make sure we're installed |
|
57
|
|
|
assert(true == is_blog_installed()); |
|
58
|
|
|
|
|
59
|
|
|
define('PHPUnit_MAIN_METHOD', false); |
|
60
|
|
|
$original_wpdb = $GLOBALS['wpdb']; |
|
61
|
|
|
|
|
62
|
|
|
// hide warnings during testing, since that's the normal WP behaviour |
|
63
|
|
|
if (!WP_DEBUG ) { |
|
|
|
|
|
|
64
|
|
|
error_reporting(E_ALL ^ E_NOTICE); |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
$to = "To <[email protected]>"; |
|
68
|
|
|
$from = "From <[email protected]>"; |
|
69
|
|
|
$cc = "CC <[email protected]>"; |
|
70
|
|
|
$bcc = "BCC <[email protected]>"; |
|
71
|
|
|
$subject = "RFC2822 Testing"; |
|
72
|
|
|
$message = "My RFC822 Test Message"; |
|
73
|
|
|
$headers[] = "From: {$from}"; |
|
74
|
|
|
$headers[] = "CC: {$cc}"; |
|
75
|
|
|
|
|
76
|
|
|
wp_mail($to, $subject, $message, $headers); |
|
77
|
|
|
|
|
78
|
|
|
$headers = array(); |
|
79
|
|
|
$subject = "RFC2822 Testing 2"; |
|
80
|
|
|
$message = "My RFC822 Test Message 2"; |
|
81
|
|
|
$to = "To <[email protected]>"; |
|
82
|
|
|
$headers[] = "BCC: {$bcc}"; |
|
83
|
|
|
wp_mail('', $subject, $message, $headers); |
|
84
|
|
|
echo "Test emails sent!\n" |
|
85
|
|
|
?> |
|
|
|
|
|