Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
02/14/2016 01:48:59 PM (9 years ago)
Author:
dcavins
Message:

Profile: Improve validation in is_valid().

When checking a submitted array of values,
ensure that the foreach breaks when an
invalid value is encountered. Previously,
the foreach returned the validity of the
last element in the array.

Also update unit tests so that invalid values
appear in various positions in the array of
values to check.

Fixes #6884.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/testcases/xprofile/class-bp-xprofile-field-type.php

    r9819 r10592  
    3939        $this->assertTrue( $field->is_valid( array( 'cheese', 'pepporoni' ) ) );
    4040        $this->assertTrue( $field->is_valid( array( 'cheese' ) ) );
    41         $this->assertFalse( $field->is_valid( array( 'cheese', 'pepporoni', 'pinapple' ) ) );
     41        $this->assertFalse( $field->is_valid( array( 'cheese', 'pinapple', 'pepporoni' ) ) );
    4242        $this->assertFalse( $field->is_valid( array( 'pinapple' ) ) );
    4343    }
     
    105105        $this->assertTrue( $field->is_valid( array( 123 ) ) );
    106106        $this->assertTrue( $field->is_valid( array( 456 ) ) );
    107         $this->assertFalse( $field->is_valid( array( 123, 456, 789 ) ) );
     107        $this->assertFalse( $field->is_valid( array( 789, 456, 123 ) ) );
    108108        $this->assertFalse( $field->is_valid( array( 789 ) ) );
    109109    }
     
    115115        $this->assertTrue( $field->is_valid( array( 'cheese', 'pepporoni' ) ) );
    116116        $this->assertTrue( $field->is_valid( array( 'cheese' ) ) );
    117         $this->assertFalse( $field->is_valid( array( 'cheese', 'pepporoni', 'pinapple' ) ) );
     117        $this->assertFalse( $field->is_valid( array(  'pinapple', 'cheese', 'pepporoni' ) ) );
    118118        $this->assertFalse( $field->is_valid( array( 'pinapple' ) ) );
    119119        $this->assertFalse( $field->is_valid( '' ) );
     
    133133        $this->assertTrue( $field->is_valid( array( 'cheese', 'pepporoni' ) ) );
    134134        $this->assertTrue( $field->is_valid( array( 'cheese' ) ) );
    135         $this->assertFalse( $field->is_valid( array( 'cheese', 'pepporoni', 'pinapple' ) ) );
     135        $this->assertFalse( $field->is_valid( array( 'pepporoni', 'cheese', 'pinapple' ) ) );
    136136        $this->assertFalse( $field->is_valid( array( 'pinapple' ) ) );
    137137        $this->assertFalse( $field->is_valid( '' ) );
Note: See TracChangeset for help on using the changeset viewer.