diff --git a/tests/phpunit/base/frm_factory.php b/tests/phpunit/base/frm_factory.php index 80f4bc2946..7a5642ee73 100644 --- a/tests/phpunit/base/frm_factory.php +++ b/tests/phpunit/base/frm_factory.php @@ -142,6 +142,21 @@ public function get_fields_from_form( $form_id ) { * @return mixed */ public function set_field_value( $field ) { + if ( in_array( $field->type, array( 'checkbox', 'select', 'radio' ), true ) ) { + if ( ! $field->options ) { + return ''; + } + + // If checkbox, dropdown or radio field, return a random choice from the options. + $random_option = $field->options[ array_rand( $field->options ) ]; + + if ( FrmField::is_option_true( $field, 'separate_value' ) ) { + return $random_option['value']; + } + + return $random_option; + } + $value = rand_str(); $field_values = array( 'email' => 'admin@example.org', diff --git a/tests/phpunit/base/testdata.xml b/tests/phpunit/base/testdata.xml index dade1f006d..c54601d70e 100644 --- a/tests/phpunit/base/testdata.xml +++ b/tests/phpunit/base/testdata.xml @@ -791,7 +791,7 @@ 698 - \n