| | 808 | /** |
| | 809 | * @ticket 33654 |
| | 810 | * @dataProvider data_wp_new_user_notifications |
| | 811 | */ |
| | 812 | function test_wp_new_user_notification( $param, $admin_expected, $user_expected ) { |
| | 813 | |
| | 814 | $admin_email_sent = false; |
| | 815 | $user_email_sent = false; |
| | 816 | |
| | 817 | $user = $this->factory->user->create( |
| | 818 | array( |
| | 819 | 'role' => 'author', |
| | 820 | 'user_login' => 'test_wp_new_user_notification', |
| | 821 | 'user_pass' => 'password', |
| | 822 | 'user_email' => 'test@test.com', |
| | 823 | ) |
| | 824 | ); |
| | 825 | |
| | 826 | wp_new_user_notification( $user, null, $param ); |
| | 827 | |
| | 828 | /** |
| | 829 | * Check to see if a notification email was sent to the post author `test@test.com`. |
| | 830 | */ |
| | 831 | |
| | 832 | |
| | 833 | if ( isset( $GLOBALS['phpmailer']->mock_sent ) && ! empty( $GLOBALS['phpmailer']->mock_sent ) ) { |
| | 834 | $admin_email_sent = ( isset( $GLOBALS['phpmailer']->mock_sent[0] ) && 'admin@example.org' == $GLOBALS['phpmailer']->mock_sent[0]['to'][0][0] ) ? true : false; |
| | 835 | $user_email_sent = ( isset( $GLOBALS['phpmailer']->mock_sent[1] ) && 'test@test.com' == $GLOBALS['phpmailer']->mock_sent[1]['to'][0][0] ) ? true : false; |
| | 836 | unset( $GLOBALS['phpmailer']->mock_sent ); |
| | 837 | } |
| | 838 | |
| | 839 | $this->assertSame( $admin_expected, $admin_email_sent ); |
| | 840 | $this->assertSame( $user_expected , $user_email_sent ); |
| | 841 | } |
| | 842 | |
| | 843 | function data_wp_new_user_notifications() { |
| | 844 | |
| | 845 | return array( |
| | 846 | array( |
| | 847 | '', |
| | 848 | true, |
| | 849 | false, |
| | 850 | ), |
| | 851 | array( |
| | 852 | 'admin', |
| | 853 | true, |
| | 854 | false, |
| | 855 | ), |
| | 856 | array( |
| | 857 | 'both', |
| | 858 | true, |
| | 859 | true, |
| | 860 | ), |
| | 861 | ); |
| | 862 | } |