2013-08-07 08:38:38 +02:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* wp-mail-real-test.php
|
|
|
|
*
|
|
|
|
* Test script for wp_mail with real addresses.
|
|
|
|
*/
|
|
|
|
|
|
|
|
// parse options
|
|
|
|
$options = 'v:r:d';
|
2017-12-01 00:09:33 +01:00
|
|
|
if ( is_callable( 'getopt' ) ) {
|
|
|
|
$opts = getopt( $options );
|
2013-08-07 08:38:38 +02:00
|
|
|
} else {
|
2017-12-01 00:09:33 +01:00
|
|
|
include( dirname( __FILE__ ) . '/wp-testlib/getopt.php' );
|
|
|
|
$opts = getoptParser::getopt( $options );
|
2013-08-07 08:38:38 +02:00
|
|
|
}
|
|
|
|
|
2017-12-01 00:09:33 +01:00
|
|
|
define( 'DIR_TESTROOT', realpath( dirname( __FILE__ ) ) );
|
2013-08-07 08:38:38 +02:00
|
|
|
|
2017-12-01 00:09:33 +01:00
|
|
|
define( 'TEST_WP', true );
|
|
|
|
define( 'WP_DEBUG', array_key_exists( 'd', $opts ) );
|
2013-08-07 08:38:38 +02:00
|
|
|
|
2017-12-01 00:09:33 +01:00
|
|
|
if ( ! empty( $opts['r'] ) ) {
|
|
|
|
define( 'DIR_WP', realpath( $opts['r'] ) );
|
|
|
|
} elseif ( ! empty( $opts['v'] ) ) {
|
|
|
|
define( 'DIR_WP', DIR_TESTROOT . '/wordpress-' . $opts['v'] );
|
|
|
|
} else {
|
|
|
|
define( 'DIR_WP', DIR_TESTROOT . '/wordpress' );
|
|
|
|
}
|
2013-08-07 08:38:38 +02:00
|
|
|
|
|
|
|
// make sure all useful errors are displayed during setup
|
2017-12-01 00:09:33 +01:00
|
|
|
error_reporting( E_ALL & ~E_DEPRECATED );
|
|
|
|
ini_set( 'display_errors', true );
|
2013-08-07 08:38:38 +02:00
|
|
|
|
2017-12-01 00:09:33 +01:00
|
|
|
require_once( DIR_TESTROOT . '/wp-testlib/utils.php' );
|
2013-08-07 08:38:38 +02:00
|
|
|
|
|
|
|
// configure wp
|
2017-12-01 00:09:33 +01:00
|
|
|
require_once( DIR_TESTROOT . '/wp-config.php' );
|
|
|
|
define( 'ABSPATH', realpath( DIR_WP ) . '/' );
|
2013-08-07 08:38:38 +02:00
|
|
|
|
|
|
|
// install wp
|
2017-12-01 00:09:33 +01:00
|
|
|
define( 'WP_BLOG_TITLE', rand_str() );
|
|
|
|
define( 'WP_USER_NAME', rand_str() );
|
|
|
|
define( 'WP_USER_EMAIL', rand_str() . '@example.com' );
|
2013-08-07 08:38:38 +02:00
|
|
|
|
|
|
|
// initialize wp
|
2017-12-01 00:09:33 +01:00
|
|
|
define( 'WP_INSTALLING', 1 );
|
2013-08-07 08:38:38 +02:00
|
|
|
$_SERVER['PATH_INFO'] = $_SERVER['SCRIPT_NAME']; // prevent a warning from some sloppy code in wp-settings.php
|
2017-12-01 00:09:33 +01:00
|
|
|
require_once( ABSPATH . 'wp-settings.php' );
|
2013-08-07 08:38:38 +02:00
|
|
|
|
|
|
|
drop_tables();
|
|
|
|
|
2017-12-01 00:09:33 +01:00
|
|
|
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
|
|
|
|
wp_install( WP_BLOG_TITLE, WP_USER_NAME, WP_USER_EMAIL, true );
|
2013-08-07 08:38:38 +02:00
|
|
|
|
|
|
|
// make sure we're installed
|
2017-12-01 00:09:33 +01:00
|
|
|
assert( true == is_blog_installed() );
|
2013-08-07 08:38:38 +02:00
|
|
|
|
2019-01-11 07:07:50 +01:00
|
|
|
// phpcs:ignore Generic.NamingConventions.UpperCaseConstantName.ConstantNotUpperCase
|
2017-12-01 00:09:33 +01:00
|
|
|
define( 'PHPUnit_MAIN_METHOD', false );
|
2013-08-07 08:38:38 +02:00
|
|
|
$original_wpdb = $GLOBALS['wpdb'];
|
|
|
|
|
|
|
|
// hide warnings during testing, since that's the normal WP behaviour
|
2017-12-01 00:09:33 +01:00
|
|
|
if ( ! WP_DEBUG ) {
|
|
|
|
error_reporting( E_ALL ^ E_NOTICE );
|
2013-08-07 08:38:38 +02:00
|
|
|
}
|
|
|
|
|
2017-12-01 00:09:33 +01:00
|
|
|
$to = 'To <wp.mail.testing@gmail.com>';
|
|
|
|
$from = 'From <wp.mail.testing+from@gmail.com>';
|
|
|
|
$cc = 'CC <wp.mail.testing+cc@gmail.com>';
|
|
|
|
$bcc = 'BCC <wp.mail.testing+bcc@gmail.com>';
|
|
|
|
$subject = 'RFC2822 Testing';
|
|
|
|
$message = 'My RFC822 Test Message';
|
2013-08-07 08:38:38 +02:00
|
|
|
$headers[] = "From: {$from}";
|
|
|
|
$headers[] = "CC: {$cc}";
|
|
|
|
|
|
|
|
wp_mail( $to, $subject, $message, $headers );
|
|
|
|
|
2017-12-01 00:09:33 +01:00
|
|
|
$headers = array();
|
|
|
|
$subject = 'RFC2822 Testing 2';
|
|
|
|
$message = 'My RFC822 Test Message 2';
|
|
|
|
$to = 'To <wp.mail.testing+to@gmail.com>';
|
2013-08-07 08:38:38 +02:00
|
|
|
$headers[] = "BCC: {$bcc}";
|
|
|
|
wp_mail( '', $subject, $message, $headers );
|
2017-12-01 00:09:33 +01:00
|
|
|
echo "Test emails sent!\n";
|
|
|
|
|