Make WordPress Core


Ignore:
Timestamp:
11/30/2017 11:09:33 PM (7 years ago)
Author:
pento
Message:

Code is Poetry.
WordPress' code just... wasn't.
This is now dealt with.

Props jrf, pento, netweb, GaryJ, jdgrimes, westonruter, Greg Sherwood from PHPCS, and everyone who's ever contributed to WPCS and PHPCS.
Fixes #41057.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/wp-mail-real-test.php

    r35350 r42343  
    88// parse options
    99$options = 'v:r:d';
    10 if (is_callable('getopt')) {
    11     $opts = getopt($options);
     10if ( is_callable( 'getopt' ) ) {
     11    $opts = getopt( $options );
    1212} 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 );
    1515}
    1616
    17 define('DIR_TESTROOT', realpath(dirname(__FILE__)));
     17define( 'DIR_TESTROOT', realpath( dirname( __FILE__ ) ) );
    1818
    19 define('TEST_WP', true);
    20 define('WP_DEBUG', array_key_exists('d', $opts) );
     19define( 'TEST_WP', true );
     20define( 'WP_DEBUG', array_key_exists( 'd', $opts ) );
    2121
    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');
     22if ( ! 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}
    2929
    3030// make sure all useful errors are displayed during setup
    31 error_reporting(E_ALL & ~E_DEPRECATED);
    32 ini_set('display_errors', true);
     31error_reporting( E_ALL & ~E_DEPRECATED );
     32ini_set( 'display_errors', true );
    3333
    34 require_once(DIR_TESTROOT.'/wp-testlib/utils.php');
     34require_once( DIR_TESTROOT . '/wp-testlib/utils.php' );
    3535
    3636// configure wp
    37 require_once(DIR_TESTROOT.'/wp-config.php');
    38 define('ABSPATH', realpath(DIR_WP).'/');
     37require_once( DIR_TESTROOT . '/wp-config.php' );
     38define( 'ABSPATH', realpath( DIR_WP ) . '/' );
    3939
    4040// 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');
     41define( 'WP_BLOG_TITLE', rand_str() );
     42define( 'WP_USER_NAME', rand_str() );
     43define( 'WP_USER_EMAIL', rand_str() . '@example.com' );
    4444
    4545// initialize wp
    46 define('WP_INSTALLING', 1);
     46define( 'WP_INSTALLING', 1 );
    4747$_SERVER['PATH_INFO'] = $_SERVER['SCRIPT_NAME']; // prevent a warning from some sloppy code in wp-settings.php
    48 require_once(ABSPATH.'wp-settings.php');
     48require_once( ABSPATH . 'wp-settings.php' );
    4949
    5050drop_tables();
    5151
    52 require_once(ABSPATH.'wp-admin/includes/upgrade.php');
    53 wp_install(WP_BLOG_TITLE, WP_USER_NAME, WP_USER_EMAIL, true);
     52require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
     53wp_install( WP_BLOG_TITLE, WP_USER_NAME, WP_USER_EMAIL, true );
    5454
    5555// make sure we're installed
    56 assert(true == is_blog_installed());
     56assert( true == is_blog_installed() );
    5757
    58 define('PHPUnit_MAIN_METHOD', false);
     58define( 'PHPUnit_MAIN_METHOD', false );
    5959$original_wpdb = $GLOBALS['wpdb'];
    6060
    6161// hide warnings during testing, since that's the normal WP behaviour
    62 if ( !WP_DEBUG ) {
    63     error_reporting(E_ALL ^ E_NOTICE);
     62if ( ! WP_DEBUG ) {
     63    error_reporting( E_ALL ^ E_NOTICE );
    6464}
    6565
    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';
    7272$headers[] = "From: {$from}";
    7373$headers[] = "CC: {$cc}";
     
    7575wp_mail( $to, $subject, $message, $headers );
    7676
    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>';
    8181$headers[] = "BCC: {$bcc}";
    8282wp_mail( '', $subject, $message, $headers );
    83 echo "Test emails sent!\n"
    84 ?>
     83echo "Test emails sent!\n";
     84
Note: See TracChangeset for help on using the changeset viewer.