/**
  * @covers FrmFormsController::update
  * with ajax
  */
 function test_form_update_with_ajax()
 {
     $form_id = FrmForm::getIdByKey($this->contact_form_key);
     self::_setup_post_values($form_id);
     try {
         $this->_handleAjax('frm_save_form');
     } catch (WPAjaxDieStopException $e) {
         unset($e);
         // Expected to return form successfully updated message
     }
     self::_check_updated_values($form_id);
 }
 /**
  * @covers FrmField::get_all_for_form
  */
 function test_get_all_for_form()
 {
     $forms = array('basic_test' => array('form_key' => $this->contact_form_key, 'count' => 8), 'repeat' => array('form_key' => $this->all_fields_form_key, 'count' => 33 + 3), 'no_repeat_or_embed' => array('form_key' => $this->all_fields_form_key, 'count' => 33), 'repeat_and_embed' => array('form_key' => $this->all_fields_form_key, 'count' => 33 + 3 + 8));
     foreach ($forms as $test => $args) {
         $form_id = FrmForm::getIdByKey($args['form_key']);
         if ($test == 'no_repeat_or_embed') {
             $fields = FrmField::get_all_for_form($form_id, '', 'exclude', 'exclude');
         } else {
             if ($test == 'repeat_and_embed') {
                 $fields = FrmField::get_all_for_form($form_id, '', 'include', 'include');
             } else {
                 $fields = FrmField::get_all_for_form($form_id);
             }
         }
         $this->assertNotEmpty($fields);
         $this->assertEquals($args['count'], count($fields), 'An incorrect number of fields are retrieved with FrmField::get_all_for_form.');
     }
 }
 function get_id_by_key($form_key)
 {
     return FrmForm::getIdByKey($form_key);
 }
 /**
  * @covers FrmField::get_all_for_form
  */
 function test_get_all_for_form()
 {
     $form_id = FrmForm::getIdByKey($this->contact_form_key);
     $fields = $this->factory->field->get_fields_from_form($form_id);
     $this->assertNotEmpty($fields);
 }
 function _check_xml_updated_number_of_entries($args)
 {
     $parent_entries = FrmEntry::getAll(array('form_id' => $args['parent_form_id']));
     $this->assertEquals(count($args['parent_entries']), count($parent_entries), 'The number of entries in form ' . $args['parent_form_id'] . ' should be the same after an XML update.');
     $rep_sec_form_id = FrmForm::getIdByKey($this->repeat_sec_form_key);
     $child_entries = FrmEntry::getAll(array('form_id' => $rep_sec_form_id));
     $this->assertEquals(count($args['child_entries']), count($child_entries), 'The number of entries in form ' . $rep_sec_form_id . ' should be the same after an XML update.');
     $embed_form_id = FrmForm::getIdByKey($this->contact_form_key);
     $embedded_entries = FrmEntry::getAll(array('form_id' => $embed_form_id, 'parent_item_id !' => 0));
     $this->assertEquals(count($args['embedded_entries']), count($embedded_entries), 'The number of entries in the embedded form should be the same after an XML update.');
 }
 function _get_xml_update_args()
 {
     $parent_form_id = FrmForm::getIdByKey($this->all_fields_form_key);
     $repeating_section_id = FrmField::get_id_by_key('repeating-section');
     $all_fields = FrmField::get_all_for_form($parent_form_id, '', 'include', 'include');
     $repeating_section = FrmField::getOne($repeating_section_id);
     $rep_sec_form = FrmForm::getOne($repeating_section->field_options['form_select']);
     $repeating_fields = FrmField::get_all_for_form($repeating_section->field_options['form_select']);
     $args = array('parent_form_id' => $parent_form_id, 'repeating_section' => $repeating_section, 'all_fields' => $all_fields, 'rep_sec_form' => $rep_sec_form, 'repeating_fields' => $repeating_fields);
     return $args;
 }