Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
12/11/2016 04:16:02 PM (7 years ago)
Author:
djpaul
Message:

xprofile: add support for auto linking semicolon-separated field values.

Fixes #5872

Props jreeve, tw2113

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/testcases/xprofile/functions.php

    r10460 r11287  
    10431043        $profile_template = $reset_profile_template;
    10441044    }
     1045
     1046    /**
     1047     * @group xprofile_filter_link_profile_data
     1048     */
     1049    public function test_field_comma_seperated_values_are_autolinked() {
     1050        $field_group_id = $this->factory->xprofile_group->create();
     1051        $field_id = $this->factory->xprofile_field->create( array( 'field_group_id' => $this->field_group_id ) );
     1052        $GLOBALS['field'] = new BP_XProfile_Field( $this->field_id );
     1053        $GLOBALS['field']->do_autolink = true;
     1054
     1055        $output = xprofile_filter_link_profile_data( 'Hello world this is a test; with, some, words', 'textbox' );
     1056        $regex = '#^Hello world this is a test; with, <a href="([^"]+)" rel="nofollow">some</a>, <a href="([^"]+)" rel="nofollow">words</a>$#i';
     1057
     1058        $this->assertRegExp( $regex, $output );
     1059        unset( $GLOBALS['field'] );
     1060    }
     1061
     1062    /**
     1063     * @group xprofile_filter_link_profile_data
     1064     */
     1065    public function test_field_semicolon_seperated_values_are_autolinked() {
     1066        $field_group_id = $this->factory->xprofile_group->create();
     1067        $field_id = $this->factory->xprofile_field->create( array( 'field_group_id' => $this->field_group_id ) );
     1068        $GLOBALS['field'] = new BP_XProfile_Field( $this->field_id );
     1069        $GLOBALS['field']->do_autolink = true;
     1070
     1071        $output = xprofile_filter_link_profile_data( 'Hello world this is a test with; some; words', 'textbox' );
     1072        $regex = '#^Hello world this is a test with; <a href="([^"]+)" rel="nofollow">some</a>; <a href="([^"]+)" rel="nofollow">words</a>$#i';
     1073
     1074        $this->assertRegExp( $regex, $output );
     1075        unset( $GLOBALS['field'] );
     1076    }
    10451077}
Note: See TracChangeset for help on using the changeset viewer.