Make WordPress Core

Ticket #34377: 34377.1.diff

File 34377.1.diff, 3.5 KB (added by danielbachhuber, 9 years ago)
  • src/wp-includes/pluggable.php

    diff --git a/src/wp-includes/pluggable.php b/src/wp-includes/pluggable.php
    index 93ad0ac..e1694a6 100644
    a b if ( !function_exists('wp_new_user_notification') ) : 
    17191719 * @param int    $user_id    User ID.
    17201720 * @param null   $deprecated Not used (argument deprecated).
    17211721 * @param string $notify     Optional. Type of notification that should happen. Accepts 'admin' or an empty
    1722  *                           string (admin only), or 'both' (admin and user). The empty string value was kept
    1723  *                           for backward-compatibility purposes with the renamed parameter. Default empty.
     1722 *                           string (admin only), or 'both' (admin and user).
    17241723 */
    17251724function wp_new_user_notification( $user_id, $deprecated = null, $notify = '' ) {
    17261725        if ( $deprecated !== null ) {
    function wp_new_user_notification( $user_id, $deprecated = null, $notify = '' ) 
    17401739
    17411740        @wp_mail(get_option('admin_email'), sprintf(__('[%s] New User Registration'), $blogname), $message);
    17421741
    1743         if ( 'admin' === $notify || empty( $notify ) ) {
     1742        if ( 'admin' === $notify || ( empty( $deprecated ) && empty( $notify ) ) ) {
    17441743                return;
    17451744        }
    17461745
  • tests/phpunit/tests/user.php

    diff --git a/tests/phpunit/tests/user.php b/tests/phpunit/tests/user.php
    index c70aa97..e585ca8 100644
    a b class Tests_User extends WP_UnitTestCase { 
    996996         * @ticket 33654
    997997         * @expectedDeprecated wp_new_user_notification
    998998         */
    999         function test_wp_new_user_notification_old_signature_throws_deprecated_warning() {
    1000                 wp_new_user_notification( self::$author_id, 'this_is_deprecated' );
     999        function test_wp_new_user_notification_old_signature_throws_deprecated_warning_but_sends() {
     1000                unset( $GLOBALS['phpmailer']->mock_sent );
     1001
     1002                $was_admin_email_sent = false;
     1003                $was_user_email_sent = false;
     1004                wp_new_user_notification( self::$contrib_id, 'this_is_a_test_password' );
     1005
     1006                /*
     1007                 * Check to see if a notification email was sent to the
     1008                 * post author `blackburn@battlefield3.com` and and site admin `admin@example.org`.
     1009                 */
     1010                if ( ! empty( $GLOBALS['phpmailer']->mock_sent ) ) {
     1011                        $was_admin_email_sent = ( isset( $GLOBALS['phpmailer']->mock_sent[0] ) && WP_TESTS_EMAIL == $GLOBALS['phpmailer']->mock_sent[0]['to'][0][0] );
     1012                        $was_user_email_sent = ( isset( $GLOBALS['phpmailer']->mock_sent[1] ) && 'blackburn@battlefield3.com' == $GLOBALS['phpmailer']->mock_sent[1]['to'][0][0] );
     1013                }
     1014
     1015                $this->assertTrue( $was_admin_email_sent );
     1016                $this->assertTrue( $was_user_email_sent );
     1017        }
     1018
     1019        /**
     1020         * Set up a user and try sending a notification using `wp_new_user_notification( $user );`.
     1021         *
     1022         * @ticket 34377
     1023         */
     1024        function test_wp_new_user_notification_old_signature_no_password() {
     1025                unset( $GLOBALS['phpmailer']->mock_sent );
     1026
     1027                $was_admin_email_sent = false;
     1028                $was_user_email_sent = false;
     1029                wp_new_user_notification( self::$contrib_id );
     1030
     1031                /*
     1032                 * Check to see if a notification email was sent to the
     1033                 * post author `blackburn@battlefield3.com` and and site admin `admin@example.org`.
     1034                 */
     1035                if ( ! empty( $GLOBALS['phpmailer']->mock_sent ) ) {
     1036                        $was_admin_email_sent = ( isset( $GLOBALS['phpmailer']->mock_sent[0] ) && WP_TESTS_EMAIL == $GLOBALS['phpmailer']->mock_sent[0]['to'][0][0] );
     1037                        $was_user_email_sent = ( isset( $GLOBALS['phpmailer']->mock_sent[1] ) && 'blackburn@battlefield3.com' == $GLOBALS['phpmailer']->mock_sent[1]['to'][0][0] );
     1038                }
     1039
     1040                $this->assertTrue( $was_admin_email_sent );
     1041                $this->assertFalse( $was_user_email_sent );
    10011042        }
    10021043
    10031044        /**