Changeset 34118 for branches/4.3/tests/phpunit/tests/user.php
- Timestamp:
- 09/14/2015 01:02:03 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/4.3/tests/phpunit/tests/user.php
r34031 r34118 680 680 } 681 681 682 /** 683 * Testing wp_new_user_notification email statuses. 684 * 685 * @dataProvider data_wp_new_user_notifications 686 * @ticket 33654 687 */ 688 function test_wp_new_user_notification( $notify, $admin_email_sent_expected, $user_email_sent_expected ) { 689 unset( $GLOBALS['phpmailer']->mock_sent ); 690 691 $was_admin_email_sent = false; 692 $was_user_email_sent = false; 693 694 $user = $this->factory->user->create( $this->user_data ); 695 696 wp_new_user_notification( $user, null, $notify ); 697 698 /* 699 * Check to see if a notification email was sent to the 700 * post author `blackburn@battlefield3.com` and and site admin `admin@example.org`. 701 */ 702 if ( ! empty( $GLOBALS['phpmailer']->mock_sent ) ) { 703 $was_admin_email_sent = ( isset( $GLOBALS['phpmailer']->mock_sent[0] ) && WP_TESTS_EMAIL == $GLOBALS['phpmailer']->mock_sent[0]['to'][0][0] ); 704 $was_user_email_sent = ( isset( $GLOBALS['phpmailer']->mock_sent[1] ) && 'blackburn@battlefield3.com' == $GLOBALS['phpmailer']->mock_sent[1]['to'][0][0] ); 705 } 706 707 $this->assertSame( $admin_email_sent_expected, $was_admin_email_sent, 'Admin email result was not as expected in test_wp_new_user_notification' ); 708 $this->assertSame( $user_email_sent_expected , $was_user_email_sent, 'User email result was not as expected in test_wp_new_user_notification' ); 709 } 710 711 /** 712 * Data provider for test_wp_new_user_notification(). 713 * 714 * Passes the three available options for the $notify parameter and the expected email 715 * emails sent status as a bool. 716 * 717 * @return array { 718 * @type array { 719 * @type string $post_args The arguments that will merged with the $_POST array. 720 * @type bool $admin_email_sent_expected The expected result of whether an email was sent to the admin. 721 * @type bool $user_email_sent_expected The expected result of whether an email was sent to the user. 722 * } 723 * } 724 */ 725 function data_wp_new_user_notifications() { 726 return array( 727 array( 728 '', 729 true, 730 false, 731 ), 732 array( 733 'admin', 734 true, 735 false, 736 ), 737 array( 738 'both', 739 true, 740 true, 741 ), 742 ); 743 } 744 745 /** 746 * Set up a user and try sending a notification using the old, deprecated 747 * function signature `wp_new_user_notification( $user, 'plaintext_password' );`. 748 * 749 * @ticket 33654 750 * @expectedDeprecated wp_new_user_notification 751 */ 752 function test_wp_new_user_notification_old_signature_throws_deprecated_warning() { 753 $user = $this->factory->user->create( 754 array( 755 'role' => 'author', 756 'user_login' => 'test_wp_new_user_notification', 757 'user_pass' => 'password', 758 'user_email' => 'test@test.com', 759 ) 760 ); 761 762 wp_new_user_notification( $user, 'this_is_deprecated' ); 763 } 682 764 }
Note: See TracChangeset
for help on using the changeset viewer.