diff --git src/bp-core/classes/class-bp-email.php src/bp-core/classes/class-bp-email.php
index d35cffb9b..96c690b79 100644
|
|
class BP_Email { |
197 | 197 | $this->set_from( $from_address, $from_name ); |
198 | 198 | $this->set_reply_to( bp_get_option( 'admin_email' ), $from_name ); |
199 | 199 | |
| 200 | // Prefer HTML emails unless filtered to plaintext. |
| 201 | $this->set_content_type( $this->content_type ); |
| 202 | |
200 | 203 | /** |
201 | 204 | * Fires inside __construct() method for BP_Email class. |
202 | 205 | * |
diff --git tests/phpunit/testcases/core/class-bp-email.php tests/phpunit/testcases/core/class-bp-email.php
index 478d14948..7a7b0e299 100644
|
|
class BP_Tests_Email extends BP_UnitTestCase_Emails { |
29 | 29 | $this->assertSame( $message, $email->get_subject() ); |
30 | 30 | } |
31 | 31 | |
| 32 | /** |
| 33 | * @ticket BP9169 |
| 34 | */ |
| 35 | public function test_default_content_type() { |
| 36 | $email = new BP_Email( 'activity-at-message' ); |
| 37 | |
| 38 | $this->assertSame( 'html', $email->get_content_type() ); |
| 39 | } |
| 40 | |
| 41 | /** |
| 42 | * @ticket BP9169 |
| 43 | */ |
| 44 | public function test_set_content_type_to_plaintext() { |
| 45 | $email = new BP_Email( 'activity-at-message' ); |
| 46 | $email->set_content_type( 'plaintext' ); |
| 47 | |
| 48 | $this->assertSame( 'plaintext', $email->get_content_type() ); |
| 49 | } |
| 50 | |
| 51 | /** |
| 52 | * @ticket BP9169 |
| 53 | */ |
| 54 | public function test_set_content_type_to_plaintext_via_filter() { |
| 55 | add_filter( 'bp_email_set_content_type', array( $this, 'bp_disable_html_emails' ) ); |
| 56 | $email = new BP_Email( 'activity-at-message' ); |
| 57 | remove_filter( 'bp_email_set_content_type', array( $this, 'bp_disable_html_emails' ) ); |
| 58 | |
| 59 | $this->assertSame( 'plaintext', $email->get_content_type() ); |
| 60 | } |
| 61 | public function bp_disable_html_emails( $content_type ) { |
| 62 | return 'plaintext'; |
| 63 | } |
| 64 | |
32 | 65 | public function test_valid_html_content() { |
33 | 66 | $message = '<b>test</b>'; |
34 | 67 | $email = new BP_Email( 'activity-at-message' ); |
… |
… |
class BP_Tests_Email extends BP_UnitTestCase_Emails { |
49 | 82 | $this->assertSame( $message, $email->get_content() ); |
50 | 83 | } |
51 | 84 | |
| 85 | /** |
| 86 | * @ticket BP9169 |
| 87 | */ |
| 88 | public function test_plaintext_strip_tags() { |
| 89 | $message = '<b>test</b>'; |
| 90 | $plainmsg = 'test'; |
| 91 | $email = new BP_Email( 'activity-at-message' ); |
| 92 | |
| 93 | $email->set_content_plaintext( $message ); |
| 94 | $email->set_content_type( 'plaintext' ); |
| 95 | |
| 96 | $this->assertSame( $plainmsg, $email->get_content() ); |
| 97 | } |
| 98 | |
52 | 99 | public function test_valid_template() { |
53 | 100 | $message = 'test'; |
54 | 101 | $email = new BP_Email( 'activity-at-message' ); |