Changeset 10586
- Timestamp:
- 02/12/2016 11:30:39 PM (9 years ago)
- Location:
- branches/2.4
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.4/src/bp-messages/bp-messages-functions.php
r10304 r10586 175 175 176 176 // Bail if message failed to send. 177 if ( ! $message->send() ) { 177 $send = $message->send(); 178 if ( false === is_int( $send ) ) { 179 if ( 'wp_error' === $r['error_type'] ) { 180 if ( is_wp_error( $send ) ) { 181 return $send; 182 } else { 183 return new WP_Error( 'message_generic_error', __( 'Message was not sent. Please try again.', 'buddypress' ) ); 184 } 185 } 186 178 187 return false; 179 188 } -
branches/2.4/tests/phpunit/testcases/messages/functions.php
r10286 r10586 59 59 $this->assertSame( 'Message could not be sent because you have entered an invalid username. Please try again.', $t1->get_error_message() ); 60 60 } 61 62 /** 63 * @group messages_new_message 64 */ 65 public function test_messages_new_message_wp_error_generic() { 66 $u1 = $this->factory->user->create(); 67 $u2 = $this->factory->user->create(); 68 69 // Emulate a plugin disabling messages. 70 add_action( 'messages_message_before_save', array( $this, 'remove_recipients_before_save' ) ); 71 72 // send a private message 73 $t1 = messages_new_message( array( 74 'sender_id' => $u1, 75 'recipients' => array( $u2 ), 76 'subject' => 'A new message', 77 'content' => 'Hey there!', 78 'error_type' => 'wp_error' 79 ) ); 80 81 $this->assertNotEmpty( $t1->get_error_code() ); 82 83 remove_action( 'messages_message_before_save', array( $this, 'remove_recipients_before_save' ) ); 84 } 85 86 /** 87 * Helper method for test_messages_new_message_wp_error_generic(). 88 */ 89 public function remove_recipients_before_save( $message ) { 90 $message->recipients = array(); 91 } 61 92 }
Note: See TracChangeset
for help on using the changeset viewer.