WordPress.org

Make WordPress Core

Changeset 347 in tests


Ignore:
Timestamp:
05/06/2011 05:31:19 PM (7 years ago)
Author:
duck_
Message:

PHPMailer::Lang() is private and calling it will fatal error. Other cleanup of MockPHPMailer::Send().

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wp-testlib/mock-mailer.php

    r87 r347  
    44
    55class MockPHPMailer extends PHPMailer {
    6 
    76    var $mock_sent = array();
    87
    98    // override the Send function so it doesn't actually send anything
    10     function Send() {
    11         $header = "";
    12         $body = "";
    13         $result = true;
     9    function Send() {
     10        if ( (count($this->to) + count($this->cc) + count($this->bcc)) < 1 ) {
     11            $this->SetError( 'You must provide at least one recipient email address.' );
     12            return false;
     13        }
    1414
    15         if((count($this->to) + count($this->cc) + count($this->bcc)) < 1)
    16         {
    17             $this->SetError($this->Lang("provide_address"));
    18             return false;
    19         }
     15        // Set whether the message is multipart/alternative
     16        if( ! empty($this->AltBody) )
     17            $this->ContentType = 'multipart/alternative';
    2018
    21         // Set whether the message is multipart/alternative
    22         if(!empty($this->AltBody))
    23             $this->ContentType = "multipart/alternative";
     19        $this->error_count = 0; // reset errors
     20        $this->SetMessageType();
     21        $header = $this->CreateHeader();
     22        $body = $this->CreateBody();
    2423
    25         $this->error_count = 0; // reset errors
    26         $this->SetMessageType();
    27         $header .= $this->CreateHeader();
    28         $body = $this->CreateBody();
     24        if ( $body == '' ) {
     25            $this->SetError( 'Message body empty' );
     26            return false;
     27        }
    2928
    30         if($body == "") { return false; }
     29        $this->mock_sent[] = array(
     30            'to' => $this->to,
     31            'cc' => $this->cc,
     32            'bcc' => $this->bcc,
     33            'header' => $header,
     34            'body' => $body,
     35        );
    3136
    32         $this->mock_sent[] = array(
    33             'to' => $this->to,
    34             'cc' => $this->cc,
    35             'bcc' => $this->bcc,
    36             'header' => $header,
    37             'body' => $body,
    38         );
    39 
    40         return $result;
     37        return true;
    4138    }
    42 
    4339}
    4440
    45 
    4641?>
Note: See TracChangeset for help on using the changeset viewer.