mirror of
https://gh.wpcy.net/https://github.com/discourse/wp-discourse.git
synced 2026-05-24 03:25:27 +08:00
Some checks failed
WP-Discourse Formatting / Formatting on PHP 5.6 (push) Has been cancelled
WP-Discourse Formatting / Formatting on PHP 7.0 (push) Has been cancelled
WP-Discourse Formatting / Formatting on PHP 7.4 (push) Has been cancelled
WP-Discourse Formatting / Formatting on PHP 8.0 (push) Has been cancelled
WP-Discourse Tests / Tests on PHP 8.2 (push) Has been cancelled
Fixes a bug where the new user notification emails sends even when $send_notification_to_user is falsey.
59 lines
1.3 KiB
PHP
Vendored
59 lines
1.3 KiB
PHP
Vendored
<?php
|
|
/**
|
|
* Class WPNewUserNotificationTest
|
|
*
|
|
* @package WPDiscourse
|
|
*/
|
|
|
|
namespace WPDiscourse\Test;
|
|
|
|
use WPDiscourse\Test\UnitTest;
|
|
|
|
/**
|
|
* WP New User Notification test case.
|
|
*/
|
|
class WPNewUserNotificationTest extends UnitTest {
|
|
|
|
/**
|
|
* User id
|
|
*
|
|
* @access protected
|
|
* @var int
|
|
*/
|
|
protected $user_id;
|
|
|
|
public function setUp(): void {
|
|
parent::setUp();
|
|
|
|
update_option( 'discourse_sso_provider', array( 'enable-sso' => 1 ) );
|
|
|
|
$this->user_id = self::factory()->user->create();
|
|
}
|
|
|
|
public function tearDown(): void {
|
|
reset_phpmailer_instance();
|
|
}
|
|
|
|
public function test_send_wp_new_user_notification() {
|
|
$this->assertEmpty( tests_retrieve_phpmailer_instance()->get_sent() );
|
|
|
|
wp_new_user_notification( $this->user_id, null, 'user' );
|
|
|
|
$this->assertNotEmpty( tests_retrieve_phpmailer_instance()->get_sent() );
|
|
}
|
|
|
|
/**
|
|
* Test that wp_send_new_user_notification_to_user filter is respected.
|
|
*/
|
|
public function test_disable_wp_new_user_notification() {
|
|
add_filter( 'wp_send_new_user_notification_to_user', '__return_false' );
|
|
|
|
$this->assertEmpty( tests_retrieve_phpmailer_instance()->get_sent() );
|
|
|
|
wp_new_user_notification( $this->user_id, null, 'user' );
|
|
|
|
$this->assertEmpty( tests_retrieve_phpmailer_instance()->get_sent() );
|
|
|
|
remove_filter( 'wp_send_new_user_notification_to_user', '__return_false' );
|
|
}
|
|
}
|