Changeset 36594 for trunk/tests/phpunit/includes/mock-mailer.php
- Timestamp:
- 02/20/2016 03:40:49 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/includes/mock-mailer.php
r33124 r36594 15 15 function postSend() { 16 16 $this->mock_sent[] = array( 17 'to' => $this->to, 18 'cc' => $this->cc, 19 'bcc' => $this->bcc, 20 'header' => $this->MIMEHeader, 21 'body' => $this->MIMEBody, 17 'to' => $this->to, 18 'cc' => $this->cc, 19 'bcc' => $this->bcc, 20 'header' => $this->MIMEHeader, 21 'subject' => $this->Subject, 22 'body' => $this->MIMEBody, 22 23 ); 23 24 24 25 return true; 25 26 } 27 28 /** 29 * Decorator to return the information for a sent mock. 30 * 31 * @since 4.5.0 32 * 33 * @param int $index Optional. Array index of mock_sent value. 34 * @return object 35 */ 36 public function get_sent( $index = 0 ) { 37 $retval = false; 38 if ( isset( $this->mock_sent[ $index ] ) ) { 39 $retval = (object) $this->mock_sent[ $index ]; 40 } 41 return $retval; 42 } 43 44 /** 45 * Get a recipient for a sent mock. 46 * 47 * @since 4.5.0 48 * 49 * @param string $address_type The type of address for the email such as to, cc or bcc. 50 * @param int $mock_sent_index Optional. The sent_mock index we want to get the recipient for. 51 * @param int $recipient_index Optional. The recipient index in the array. 52 * @return bool|object Returns object on success, or false if any of the indices don't exist. 53 */ 54 public function get_recipient( $address_type, $mock_sent_index = 0, $recipient_index = 0 ) { 55 $retval = false; 56 $mock = $this->get_sent( $mock_sent_index ); 57 if ( $mock ) { 58 if ( isset( $mock->{$address_type}[ $recipient_index ] ) ) { 59 $address_index = $mock->{$address_type}[ $recipient_index ]; 60 $recipient_data = array( 61 'address' => ( isset( $address_index[0] ) && ! empty( $address_index[0] ) ) ? $address_index[0] : 'No address set', 62 'name' => ( isset( $address_index[1] ) && ! empty( $address_index[1] ) ) ? $address_index[1] : 'No name set', 63 ); 64 65 $retval = (object) $recipient_data; 66 } 67 } 68 69 return $retval; 70 } 26 71 } 72 73 /** 74 * Helper method to return the global phpmailer instance defined in the bootstrap 75 * 76 * @since 4.4.0 77 * 78 * @return object|bool 79 */ 80 function tests_retrieve_phpmailer_instance() { 81 $mailer = false; 82 if ( isset( $GLOBALS['phpmailer'] ) ) { 83 $mailer = $GLOBALS['phpmailer']; 84 } 85 return $mailer; 86 }
Note: See TracChangeset
for help on using the changeset viewer.