Skip to:
Content

BuddyPress.org

Changeset 11849


Ignore:
Timestamp:
02/07/2018 03:29:25 PM (8 years ago)
Author:
djpaul
Message:

xprofile: add telephone number field type.

Fixes #6549

Props danbp, boonebgorges

Location:
trunk
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-xprofile/bp-xprofile-functions.php

    r11817 r11849  
    159159                'textarea'       => 'BP_XProfile_Field_Type_Textarea',
    160160                'textbox'        => 'BP_XProfile_Field_Type_Textbox',
     161                'telephone'      => 'BP_XProfile_Field_Type_Telephone',
    161162        );
    162163
     
    869870 */
    870871function xprofile_sync_wp_profile_on_single_field_set( $data ) {
    871        
     872
    872873        if ( bp_xprofile_fullname_field_id() !== $data->field_id ) {
    873874                return;
  • trunk/tests/phpunit/testcases/xprofile/class-bp-xprofile-field-type.php

    r10592 r11849  
    7676        public function test_number_do_not_validate_string() {
    7777                $field = bp_xprofile_create_field_type( 'number' );
    78                 $this->assertFalse( $field->is_valid( 'telephone fields only accept integers' ) );
     78                $this->assertFalse( $field->is_valid( 'number fields only accept integers' ) );
    7979                $this->assertFalse( $field->is_valid( '' ) );
    8080        }
     
    177177                $this->assertTrue( $field->is_valid( array( 'bar' ) ) );
    178178        }
     179
     180        public function test_telephone_validate_number_formats() {
     181                $field = bp_xprofile_create_field_type( 'telephone' );
     182                $this->assertTrue( $field->is_valid( '07700 900461' ) );
     183                $this->assertTrue( $field->is_valid( '555-2368' ) );
     184                $this->assertTrue( $field->is_valid( '(212) 664-7665' ) );
     185        }
    179186}
Note: See TracChangeset for help on using the changeset viewer.