Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
05/19/2015 04:52:49 PM (11 years ago)
Author:
johnjamesjacoby
Message:

XProfile: Add tests for "0" field names and field options. See #6443.

File:
1 edited

Legend:

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

    r9819 r9878  
    5555                unset( $_POST['checkbox_option'] );
    5656        }
     57
     58        /**
     59         * @group xprofile_field_admin_validate
     60         */
     61        public function test_admin_validate_zero_field_name() {
     62
     63                // Mock POST global values
     64                $_POST['title']     = '0';
     65                $_POST['required']  = false;
     66                $_POST['fieldtype'] = 'textbox';
     67
     68                // Validate the mocked POST radio button options
     69                $result = BP_XProfile_Field::admin_validate();
     70
     71                // Assert valid
     72                $this->assertEquals( $result, true );
     73
     74                // cleanup
     75                unset(
     76                        $_POST['title'],
     77                        $_POST['required'],
     78                        $_POST['fieldtype']
     79                );
     80        }
     81
     82        /**
     83         * @group xprofile_field_admin_validate
     84         */
     85        public function test_admin_validate_field_options() {
     86
     87                // Mock POST global values
     88                $_POST['title']        = 'Foo';
     89                $_POST['required']     = false;
     90                $_POST['fieldtype']    = 'radio';
     91                $_POST['radio_option'] = array(
     92                        1 => '0',
     93                        2 => '1',
     94                        3 => '4',
     95                );
     96
     97                // Validate the mocked POST radio button options
     98                $result = BP_XProfile_Field::admin_validate();
     99
     100                // Assert valid
     101                $this->assertEquals( $result, true );
     102
     103                // cleanup
     104                unset(
     105                        $_POST['title'],
     106                        $_POST['required'],
     107                        $_POST['fieldtype'],
     108                        $_POST['radio_option' ]
     109                );
     110        }
    57111}
Note: See TracChangeset for help on using the changeset viewer.