Skip to:
Content

BuddyPress.org

Changeset 10470


Ignore:
Timestamp:
01/27/2016 04:43:44 PM (4 years ago)
Author:
djpaul
Message:

Introduce base classes for new Email implementation.

  • Class BP_Email represents an email; the bits you see in your email client like the subject, message, recipients. It also encapsulates custom email headers and tokens.
  • Class BP_Email_Recipient represents an email recipient. It holds an email address and recipient name. If the class is instantiated with a WordPress user ID, then it also has a WP_User reference.
  • Interface BP_Email_Delivery is what mail delivery services will use to implement support for emails sent by BuddyPress.
  • Class BP_PHPMailer implements BP_Email_Delivery for PHPMailer.

See #6592. Props timersys, mercime, boonebgorges, hnla, DJPaul.

Location:
trunk
Files:
7 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-core/bp-core-classes.php

    r10417 r10470  
    2626require dirname( __FILE__ ) . '/classes/class-bp-attachment-avatar.php';
    2727require dirname( __FILE__ ) . '/classes/class-bp-attachment-cover-image.php';
     28require dirname( __FILE__ ) . '/classes/class-bp-email-recipient.php';
     29require dirname( __FILE__ ) . '/classes/class-bp-email.php';
     30require dirname( __FILE__ ) . '/classes/class-bp-email-delivery.php';
     31require dirname( __FILE__ ) . '/classes/class-bp-phpmailer.php';
  • trunk/tests/phpunit/includes/install.php

    r9836 r10470  
    1414require_once $config_file_path;
    1515require_once $tests_dir_path . '/includes/functions.php';
     16require_once $tests_dir_path . '/includes/mock-mailer.php';
    1617
    1718function _load_buddypress() {
     
    4950}
    5051
     52function _bp_mock_mailer( $class ) {
     53    return 'BP_UnitTest_Mailer';
     54}
     55tests_add_filter( 'bp_send_email_delivery_class', '_bp_mock_mailer' );
     56
    5157// Install BuddyPress
    5258bp_version_updater();
  • trunk/tests/phpunit/includes/loader.php

    r9819 r10470  
    88// Bootstrap BP
    99require dirname( __FILE__ ) . '/../../../src/bp-loader.php';
     10
     11require_once( dirname( __FILE__ ) . '/mock-mailer.php' );
     12function _bp_mock_mailer( $class ) {
     13    return 'BP_UnitTest_Mailer';
     14}
     15tests_add_filter( 'bp_send_email_delivery_class', '_bp_mock_mailer' );
  • trunk/tests/phpunit/testcases/core/functions.php

    r10159 r10470  
    708708        $this->assertTrue( empty( $not_image ) );
    709709    }
     710
     711    public function test_emails_should_have_correct_link_color() {
     712        $appearance = bp_email_get_appearance_settings();
     713
     714        $content    = '<a href="http://example.com">example</a>';
     715        $link_color = 'style="color: ' . esc_attr( $appearance['highlight_color'] ) . ';';
     716        $result     = bp_email_add_link_color_to_template( $content, 'template', 'add-content' );
     717        $this->assertContains( $link_color, $result );
     718
     719        $content     = '<a href="http://example.com" style="display: block">example</a>';
     720        $link_color .= 'display: block';
     721        $result      = bp_email_add_link_color_to_template( $content, 'template', 'add-content' );
     722        $this->assertContains( $link_color, $result );
     723    }
    710724}
Note: See TracChangeset for help on using the changeset viewer.