Skip to:
Content

BuddyPress.org

Ticket #6966: tests-in-progress.diff

File tests-in-progress.diff, 1.8 KB (added by DJPaul, 4 years ago)
  • src/bp-core/bp-core-filters.php

    diff --git a/src/bp-core/bp-core-filters.php b/src/bp-core/bp-core-filters.php
    index 8d0ac06..a60fa24 100644
    a b add_filter( 'bp_email_set_content_html', 'stripslashes', 8 ); 
    5959add_filter( 'bp_email_set_content_plaintext', 'wp_strip_all_tags', 6 );
    6060add_filter( 'bp_email_set_subject', 'sanitize_text_field', 6 );
    6161
    62 
    6362/**
    6463 * Template Compatibility.
    6564 *
  • tests/phpunit/testcases/core/class-bp-email.php

    diff --git a/tests/phpunit/testcases/core/class-bp-email.php b/tests/phpunit/testcases/core/class-bp-email.php
    index 45ab91a..3ae68d9 100644
    a b class BP_Tests_Email extends BP_UnitTestCase_Emails { 
    267267
    268268                $this->assertTrue( $result );
    269269        }
     270
     271        public function test_html_entities_are_decoded_in_email_subject() {
     272                $text = "It’s pretty <new & magical.";
     273                $html = wptexturize( $text );
     274
     275                $email = new BP_Email( 'activity-at-message' );
     276                $email->set_subject( $html )->set_tokens( array( 'poster.name' => 'example' ) );
     277
     278                $this->assertSame( $text, $email->get_subject() );
     279        }
     280
     281        public function test_html_entities_are_decoded_in_email_recipient_names() {
     282                $name = "Test o'Toole";
     283                xprofile_set_field_data( 1, $this->u1, $name );
     284
     285                global $field;
     286                $field = new BP_XProfile_ProfileData( 1, $this->u1 );
     287                $xprofile_name = apply_filters( 'bp_get_the_profile_field_value', $field->value, $field->type, 1 );
     288
     289                die(var_dump($xprofile_name, $field          ));
     290
     291                //$html = wptexturize( $text );
     292                $email = new BP_Email( 'activity-at-message' );
     293                $email->set_subject( $html )->set_tokens( array( 'poster.name' => 'example' ) );
     294                $html = html_entity_decode( $email->get_subject(), ENT_QUOTES );
     295
     296                $this->assertSame( $text, $html );
     297        }
     298
    270299}