<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[BuddyPress][10481] trunk: Emails: update `set_to`, `set_bcc`, `set_cc` to correctly handle multiple recipients.</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="http://buddypress.trac.wordpress.org/changeset/10481">10481</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"http://buddypress.trac.wordpress.org/changeset/10481","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>djpaul</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2016-01-28 19:26:34 +0000 (Thu, 28 Jan 2016)</dd>
</dl>
<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>Emails: update `set_to`, `set_bcc`, `set_cc` to correctly handle multiple recipients.
Also tweaks the PHPDoc to make the intended use of the array argument
clearer.
See <a href="http://buddypress.trac.wordpress.org/ticket/6592">#6592</a></pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcbpcorebpcorefunctionsphp">trunk/src/bp-core/bp-core-functions.php</a></li>
<li><a href="#trunksrcbpcoreclassesclassbpemailrecipientphp">trunk/src/bp-core/classes/class-bp-email-recipient.php</a></li>
<li><a href="#trunksrcbpcoreclassesclassbpemailphp">trunk/src/bp-core/classes/class-bp-email.php</a></li>
<li><a href="#trunktestsphpunittestcasescoreclassbpemailphp">trunk/tests/phpunit/testcases/core/class-bp-email.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcbpcorebpcorefunctionsphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/bp-core/bp-core-functions.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/bp-core/bp-core-functions.php 2016-01-27 21:16:15 UTC (rev 10480)
+++ trunk/src/bp-core/bp-core-functions.php 2016-01-28 19:26:34 UTC (rev 10481)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2838,7 +2838,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $email_type Type of email being sent.
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string|array|int|WP_User $to Either a email address, user ID, WP_User object,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * or an array containg the address and name.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * or an array containing any combination of the above.
</ins><span class="cx" style="display: block; padding: 0 10px"> * @param array $args {
</span><span class="cx" style="display: block; padding: 0 10px"> * Optional. Array of extra. parameters.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span></span></pre></div>
<a id="trunksrcbpcoreclassesclassbpemailrecipientphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/bp-core/classes/class-bp-email-recipient.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/bp-core/classes/class-bp-email-recipient.php 2016-01-27 21:16:15 UTC (rev 10480)
+++ trunk/src/bp-core/classes/class-bp-email-recipient.php 2016-01-28 19:26:34 UTC (rev 10481)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -49,7 +49,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 2.5.0
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string|array|int|WP_User $email_or_user Either a email address, user ID, WP_User object,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * or an array containg the address and name.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * or an array containing any combination of the above.
</ins><span class="cx" style="display: block; padding: 0 10px"> * @param string $name Optional. If $email_or_user is a string, this is the recipient's name.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function __construct( $email_or_user, $name = '' ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -94,7 +94,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 2.5.0
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string|array|int|WP_User $email_or_user Either a email address, user ID, WP_User object,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * or an array containg the address and name.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * or an array containing any combination of the above.
</ins><span class="cx" style="display: block; padding: 0 10px"> * @param string $name If $email_or_user is a string, this is the recipient's name.
</span><span class="cx" style="display: block; padding: 0 10px"> * @param BP_Email_Recipient $this Current instance of the email type class.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span></span></pre></div>
<a id="trunksrcbpcoreclassesclassbpemailphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/bp-core/classes/class-bp-email.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/bp-core/classes/class-bp-email.php 2016-01-27 21:16:15 UTC (rev 10480)
+++ trunk/src/bp-core/classes/class-bp-email.php 2016-01-28 19:26:34 UTC (rev 10481)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -519,13 +519,22 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 2.5.0
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string|array|int|WP_User $bcc_address Either a email address, user ID, WP_User object,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * or an array containg the address and name.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * or an array containing any combination of the above.
</ins><span class="cx" style="display: block; padding: 0 10px"> * @param string $name Optional. If $bcc_address is a string, this is the recipient's name.
</span><span class="cx" style="display: block; padding: 0 10px"> * @return BP_Email
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function set_bcc( $bcc_address, $name = '' ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $bcc = array( new BP_Email_Recipient( $bcc_address, $name ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $bcc = array();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( is_array( $bcc_address ) ) {
+ foreach ( $bcc_address as $address ) {
+ $bcc[] = new BP_Email_Recipient( $address );
+ }
+
+ } else {
+ $bcc = array( new BP_Email_Recipient( $bcc_address, $name ) );
+ }
+
</ins><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Filters the new value of the email's "BCC" property.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -533,7 +542,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @param BP_Email_Recipient[] $bcc BCC recipients.
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string|array|int|WP_User $bcc_address Either a email address, user ID, WP_User object,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * or an array containg the address and name.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * or an array containing any combination of the above.
</ins><span class="cx" style="display: block; padding: 0 10px"> * @param string $name Optional. If $bcc_address is a string, this is the recipient's name.
</span><span class="cx" style="display: block; padding: 0 10px"> * @param BP_Email $this Current instance of the email type class.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -554,13 +563,22 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 2.5.0
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string|array|int|WP_User $cc_address Either a email address, user ID, WP_User object,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * or an array containg the address and name.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * or an array containing any combination of the above.
</ins><span class="cx" style="display: block; padding: 0 10px"> * @param string $name Optional. If $cc_address is a string, this is the recipient's name.
</span><span class="cx" style="display: block; padding: 0 10px"> * @return BP_Email
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function set_cc( $cc_address, $name = '' ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $cc = array( new BP_Email_Recipient( $cc_address, $name ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $cc = array();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( is_array( $cc_address ) ) {
+ foreach ( $cc_address as $address ) {
+ $cc[] = new BP_Email_Recipient( $address );
+ }
+
+ } else {
+ $cc = array( new BP_Email_Recipient( $cc_address, $name ) );
+ }
+
</ins><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Filters the new value of the email's "CC" property.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -568,7 +586,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @param BP_Email_Recipient[] $cc CC recipients.
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string|array|int|WP_User $cc_address Either a email address, user ID, WP_User object,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * or an array containg the address and name.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * or an array containing any combination of the above.
</ins><span class="cx" style="display: block; padding: 0 10px"> * @param string $name Optional. If $cc_address is a string, this is the recipient's name.
</span><span class="cx" style="display: block; padding: 0 10px"> * @param BP_Email $this Current instance of the email type class.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -657,8 +675,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 2.5.0
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string|array|int|WP_User $email_address Either a email address, user ID, WP_User object,
- * or an array containg the address and name.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param string|array|int|WP_User $email_address Either a email address, user ID, or WP_User object.
</ins><span class="cx" style="display: block; padding: 0 10px"> * @param string $name Optional. If $email_address is a string, this is the recipient's name.
</span><span class="cx" style="display: block; padding: 0 10px"> * @return BP_Email
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -671,8 +688,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 2.5.0
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @param BP_Email_Recipient $from Sender details.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string|array|int|WP_User $email_address Either a email address, user ID, WP_User object,
- * or an array containg the address and name.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param string|array|int|WP_User $email_address Either a email address, user ID, or WP_User object.
</ins><span class="cx" style="display: block; padding: 0 10px"> * @param string $name Optional. If $email_address is a string, this is the recipient's name.
</span><span class="cx" style="display: block; padding: 0 10px"> * @param BP_Email $this Current instance of the email type class.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -726,7 +742,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 2.5.0
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string|array|int|WP_User $email_address Either a email address, user ID, WP_User object,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * or an array containg the address and name.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * or an array containing any combination of the above.
</ins><span class="cx" style="display: block; padding: 0 10px"> * @param string $name Optional. If $email_address is a string, this is the recipient's name.
</span><span class="cx" style="display: block; padding: 0 10px"> * @return BP_Email
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -740,7 +756,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @param BP_Email_Recipient $reply_to "Reply to" recipient.
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string|array|int|WP_User $email_address Either a email address, user ID, WP_User object,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * or an array containg the address and name.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * or an array containing any combination of the above.
</ins><span class="cx" style="display: block; padding: 0 10px"> * @param string $name Optional. If $email_address is a string, this is the recipient's name.
</span><span class="cx" style="display: block; padding: 0 10px"> * @param BP_Email $this Current instance of the email type class.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -815,13 +831,22 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 2.5.0
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string|array|int|WP_User $to_address Either a email address, user ID, WP_User object,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * or an array containg the address and name.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * or an array containing any combination of the above.
</ins><span class="cx" style="display: block; padding: 0 10px"> * @param string $name Optional. If $to_address is a string, this is the recipient's name.
</span><span class="cx" style="display: block; padding: 0 10px"> * @return BP_Email
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function set_to( $to_address, $name = '' ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $to = array( new BP_Email_Recipient( $to_address, $name ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $to = array();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( is_array( $to_address ) ) {
+ foreach ( $to_address as $address ) {
+ $to[] = new BP_Email_Recipient( $address );
+ }
+
+ } else {
+ $to = array( new BP_Email_Recipient( $to_address, $name ) );
+ }
+
</ins><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Filters the new value of the email's "to" property.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span></span></pre></div>
<a id="trunktestsphpunittestcasescoreclassbpemailphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/testcases/core/class-bp-email.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/testcases/core/class-bp-email.php 2016-01-27 21:16:15 UTC (rev 10480)
+++ trunk/tests/phpunit/testcases/core/class-bp-email.php 2016-01-28 19:26:34 UTC (rev 10481)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -4,8 +4,22 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @group BP_Email
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> class BP_Tests_Email extends BP_UnitTestCase {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ protected $u1;
+ protected $u2;
+
</ins><span class="cx" style="display: block; padding: 0 10px"> public function setUp() {
</span><span class="cx" style="display: block; padding: 0 10px"> parent::setUp();
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ $this->u1 = $this->factory->user->create( array(
+ 'display_name' => 'Unit Test',
+ 'user_email' => 'test1@example.com',
+ ) );
+
+ $this->u2 = $this->factory->user->create( array(
+ 'display_name' => 'Unit Test2',
+ 'user_email' => 'test2@example.com',
+ ) );
+
</ins><span class="cx" style="display: block; padding: 0 10px"> remove_filter( 'bp_email_get_headers', 'bp_email_set_default_headers', 6, 4 );
</span><span class="cx" style="display: block; padding: 0 10px"> remove_filter( 'bp_email_get_tokens', 'bp_email_set_default_tokens', 6, 4 );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -155,4 +169,57 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( '<b>hello world</b><b>hello world</b>', $email->get_content() );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ public function test_multiple_recipients_are_supported_by_address() {
+ $email1 = 'test1@example.com';
+ $email2 = 'test2@example.com';
+ $email = new BP_Email( 'fake_type' );
+
+ $email->set_to( array( $email1, $email2 ) );
+ $addresses = $email->get_to();
+
+ $this->assertCount( 2, $addresses );
+ $this->assertSame( $email1, $addresses[0]->get_address() );
+ $this->assertSame( $email2, $addresses[1]->get_address() );
+ }
+
+ public function test_multiple_recipients_are_supported_by_wp_user_object() {
+ $user1 = get_user_by( 'id', $this->u1 );
+ $user2 = get_user_by( 'id', $this->u2 );
+ $email = new BP_Email( 'fake_type' );
+
+ $email->set_to( array( $user1, $user2 ) );
+ $addresses = $email->get_to();
+
+ $this->assertCount( 2, $addresses );
+ $this->assertSame( $user1->user_email, $addresses[0]->get_address() );
+ $this->assertSame( $user2->user_email, $addresses[1]->get_address() );
+ }
+
+ public function test_multiple_recipients_are_supported_by_wp_user_id() {
+ $user1 = get_user_by( 'id', $this->u1 );
+ $user2 = get_user_by( 'id', $this->u2 );
+ $email = new BP_Email( 'fake_type' );
+ $email->set_to( array( $this->u1, $this->u2 ) );
+ $addresses = $email->get_to();
+
+ $this->assertCount( 2, $addresses );
+ $this->assertSame( $user1->user_email, $addresses[0]->get_address() );
+ $this->assertSame( $user2->user_email, $addresses[1]->get_address() );
+ }
+
+ public function test_multiple_recipients_are_supported() {
+ $user1 = get_user_by( 'id', $this->u1 );
+ $user2 = get_user_by( 'id', $this->u2 );
+ $user3 = 'test3@example.com';
+ $email = new BP_Email( 'fake_type' );
+
+ $email->set_to( array( $user1, $this->u2, $user3 ) );
+ $addresses = $email->get_to();
+
+ $this->assertCount( 3, $addresses );
+ $this->assertSame( $user1->user_email, $addresses[0]->get_address() );
+ $this->assertSame( $user2->user_email, $addresses[1]->get_address() );
+ $this->assertSame( $user3, $addresses[2]->get_address() );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre>
</div>
</div>
</body>
</html>