Changeset 10541 for trunk/tests/phpunit/testcases/core/class-bp-email.php
- Timestamp:
- 02/07/2016 12:01:24 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/testcases/core/class-bp-email.php
r10539 r10541 20 20 'user_email' => 'test2@example.com', 21 21 ) ); 22 23 remove_filter( 'bp_email_get_headers', 'bp_email_set_default_headers', 6, 4 );24 remove_filter( 'bp_email_get_tokens', 'bp_email_set_default_tokens', 6, 4 );25 }26 27 public function tearDown() {28 add_filter( 'bp_email_get_tokens', 'bp_email_set_default_tokens', 6, 4 );29 add_filter( 'bp_email_get_headers', 'bp_email_set_default_headers', 6, 4 );30 parent::tearDown();31 22 } 32 23 … … 68 59 69 60 public function test_tokens() { 70 $original = array( 'test1' => 'hello', 'test2' => 'world' ); 71 72 $email = new BP_Email( 'activity-at-message' ); 73 $email->set_tokens( $original ); 74 75 $this->assertSame( 76 array( 'test1', 'test2' ), 61 $email = new BP_Email( 'activity-at-message' ); 62 $default_tokens = $email->get_tokens(); 63 $tokens = array( 'test1' => 'hello', 'test2' => 'world' ); 64 65 $email->set_tokens( $tokens ); 66 67 $this->assertSame( 68 array_keys( $tokens + $default_tokens ), 77 69 array_keys( $email->get_tokens() ) 78 70 ); 79 71 80 72 $this->assertSame( 81 array ( 'hello', 'world'),73 array_values( $tokens + $default_tokens ), 82 74 array_values( $email->get_tokens() ) 83 75 ); … … 85 77 86 78 public function test_headers() { 87 $email = new BP_Email( 'activity-at-message' ); 88 89 $headers = array( 'custom_header' => 'custom_value' ); 79 $email = new BP_Email( 'activity-at-message' ); 80 $default_headers = $email->get_headers(); 81 $headers = array( 'custom_header' => 'custom_value' ); 82 90 83 $email->set_headers( $headers ); 91 $this->assertSame( $headers, $email->get_headers() ); 84 85 $this->assertSame( $headers + $default_headers, $email->get_headers() ); 92 86 } 93 87 … … 101 95 102 96 public function test_invalid_characters_are_stripped_from_tokens() { 103 $email = new BP_Email( 'activity-at-message' ); 97 $email = new BP_Email( 'activity-at-message' ); 98 $default_tokens = $email->get_tokens(); 99 104 100 $email->set_tokens( array( 'te{st}1' => 'hello world' ) ); 105 101 106 102 $this->assertSame( 107 array ( 'test1'),103 array_keys( array( 'test1' => 'hello world' ) + $default_tokens ), 108 104 array_keys( $email->get_tokens() ) 109 105 ); … … 133 129 134 130 public function test_invalid_headers() { 135 $email = new BP_Email( 'activity-at-message' ); 136 137 $headers = array( 'custom:header' => 'custom:value' ); 131 $email = new BP_Email( 'activity-at-message' ); 132 $default_headers = $email->get_headers(); 133 $headers = array( 'custom:header' => 'custom:value' ); 134 138 135 $email->set_headers( $headers ); 139 $this->assertNotSame( $headers, $email->get( 'headers' ) ); 140 $this->assertSame( array( 'customheader' => 'customvalue' ), $email->get_headers() ); 136 137 $this->assertNotSame( $headers + $default_headers, $email->get( 'headers' ) ); 138 $this->assertSame( array( 'customheader' => 'customvalue' ) + $default_headers, $email->get( 'headers' ) ); 141 139 } 142 140
Note: See TracChangeset
for help on using the changeset viewer.