Skip to:
Content

BuddyPress.org

Changeset 10503


Ignore:
Timestamp:
02/03/2016 11:35:11 PM (4 years ago)
Author:
djpaul
Message:

Tests, Emails: use real email type, rather than dummy.

This will slow the tests a bit as a Post will be queried for, but by using a genuine email type, we trigger the 2.5 backwards compatibility code, allowing us to test both the class and anything we have hooked into it by default.

See #6592

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/testcases/core/class-bp-email.php

    r10482 r10503  
    3333    public function test_valid_subject() {
    3434        $message = 'test';
    35         $email   = new BP_Email( 'fake_type' );
     35        $email   = new BP_Email( 'activity-at-message' );
    3636
    3737        $email->set_subject( $message );
     
    4141    public function test_valid_html_content() {
    4242        $message = '<b>test</b>';
    43         $email   = new BP_Email( 'fake_type' );
     43        $email   = new BP_Email( 'activity-at-message' );
    4444
    4545        $email->set_content_html( $message );
     
    5151    public function test_valid_plaintext_content() {
    5252        $message = 'test';
    53         $email   = new BP_Email( 'fake_type' );
     53        $email   = new BP_Email( 'activity-at-message' );
    5454
    5555        $email->set_content_plaintext( $message );
     
    6161    public function test_valid_template() {
    6262        $message = 'test';
    63         $email   = new BP_Email( 'fake_type' );
     63        $email   = new BP_Email( 'activity-at-message' );
    6464
    6565        $email->set_template( $message );
     
    7070        $original = array( 'test1' => 'hello', 'test2' => 'world' );
    7171
    72         $email = new BP_Email( 'fake_type' );
     72        $email = new BP_Email( 'activity-at-message' );
    7373        $email->set_tokens( $original );
    7474
     
    8585
    8686    public function test_headers() {
    87         $email = new BP_Email( 'fake_type' );
     87        $email = new BP_Email( 'activity-at-message' );
    8888
    8989        $headers = array( 'custom_header' => 'custom_value' );
     
    9393
    9494    public function test_validation() {
    95         $email = new BP_Email( 'fake_type' );
     95        $email = new BP_Email( 'activity-at-message' );
    9696        $email->set_from( 'test1@example.com' )->set_to( 'test2@example.com' )->set_subject( 'testing' );
    9797        $email->set_content_html( 'testing' );
     
    101101
    102102    public function test_invalid_characters_are_stripped_from_tokens() {
    103         $email = new BP_Email( 'fake_type' );
     103        $email = new BP_Email( 'activity-at-message' );
    104104        $email->set_tokens( array( 'te{st}1' => 'hello world' ) );
    105105
     
    112112    public function test_token_are_escaped() {
    113113        $token = '<blink>';
    114         $email = new BP_Email( 'fake_type' );
     114        $email = new BP_Email( 'activity-at-message' );
    115115        $email->set_content_html( '{{test}}' )->set_tokens( array( 'test' => $token ) );
    116116
     
    123123    public function test_token_are_not_escaped() {
    124124        $token = '<blink>';
    125         $email = new BP_Email( 'fake_type' );
     125        $email = new BP_Email( 'activity-at-message' );
    126126        $email->set_content_html( '{{{test}}}' )->set_tokens( array( 'test' => $token ) );
    127127
     
    133133
    134134    public function test_invalid_headers() {
    135         $email = new BP_Email( 'fake_type' );
     135        $email = new BP_Email( 'activity-at-message' );
    136136
    137137        $headers = array( 'custom:header' => 'custom:value' );
     
    142142
    143143    public function test_validation_with_missing_required_data() {
    144         $email  = new BP_Email( 'fake_type' );
     144        $email  = new BP_Email( 'activity-at-message' );
    145145        $email->set_from( 'test1@example.com' )->set_to( 'test2@example.com' )->set_subject( 'testing' );  // Content
    146146        $result = $email->validate();
     
    151151
    152152    public function test_validation_with_missing_template() {
    153         $email  = new BP_Email( 'fake_type' );
     153        $email  = new BP_Email( 'activity-at-message' );
    154154        $email->set_from( 'test1@example.com' )->set_to( 'test2@example.com' )->set_subject( 'testing' );
    155155        $email->set_content_html( 'testing' )->set_template( '' );
     
    163163    public function test_invalid_tags_should_be_removed_from_html_content() {
    164164        $message = '<b>hello world</b><iframe src="https://example.com"></iframe><b>hello world</b>';
    165         $email   = new BP_Email( 'fake_type' );
     165        $email   = new BP_Email( 'activity-at-message' );
    166166
    167167        $email->set_content_html( $message );
     
    174174        $email1 = 'test1@example.com';
    175175        $email2 = 'test2@example.com';
    176         $email  = new BP_Email( 'fake_type' );
     176        $email  = new BP_Email( 'activity-at-message' );
    177177
    178178        $email->set_to( array( $email1, $email2 ) );
     
    187187        $user1 = get_user_by( 'id', $this->u1 );
    188188        $user2 = get_user_by( 'id', $this->u2 );
    189         $email = new BP_Email( 'fake_type' );
     189        $email = new BP_Email( 'activity-at-message' );
    190190
    191191        $email->set_to( array( $user1, $user2 ) );
     
    200200        $user1 = get_user_by( 'id', $this->u1 );
    201201        $user2 = get_user_by( 'id', $this->u2 );
    202         $email = new BP_Email( 'fake_type' );
     202        $email = new BP_Email( 'activity-at-message' );
    203203        $email->set_to( array( $this->u1, $this->u2 ) );
    204204        $addresses = $email->get_to();
     
    213213        $user2 = get_user_by( 'id', $this->u2 );
    214214        $user3 = 'test3@example.com';
    215         $email = new BP_Email( 'fake_type' );
     215        $email = new BP_Email( 'activity-at-message' );
    216216
    217217        $email->set_to( array( $user1, $this->u2, $user3 ) );
     
    225225
    226226    public function test_replacing_existing_recipients_with_new_recipients() {
    227         $email              = new BP_Email( 'fake_type' );
     227        $email              = new BP_Email( 'activity-at-message' );
    228228        $original_recipient = 'test1@example.com';
    229229        $new_recipient      = 'test2@example.com';
     
    239239
    240240    public function test_appending_new_recipients_to_existing_recipients() {
    241         $email              = new BP_Email( 'fake_type' );
     241        $email              = new BP_Email( 'activity-at-message' );
    242242        $original_recipient = 'test1@example.com';
    243243        $new_recipient      = 'test2@example.com';
Note: See TracChangeset for help on using the changeset viewer.