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