/**
  * @group 7121
  */
 public function test_normalized_value_int()
 {
     $form = new EE_Form_Section_Proper(array('name' => 'test', 'subsections' => array('use_captcha' => new EE_Radio_Button_Input(array(1 => __('Yes', 'event_espresso'), 0 => __('No', 'event_espresso')), array('html_label_text' => __('Use reCAPTCHA', 'event_espresso'), 'default' => isset(EE_Registry::instance()->CFG->registration->use_captcha) ? EE_Registry::instance()->CFG->registration->use_captcha : FALSE, 'normalization_strategy' => new EE_Int_Normalization())))));
     $form->receive_form_submission(array('test' => array('use_captcha' => '1')));
     $this->assertTrue($form->is_valid());
     $this->assertTrue(1 === $form->get_input('use_captcha')->normalized_value());
     $this->assertTrue('1' === $form->get_input('use_captcha')->raw_value());
     $form->receive_form_submission(array('test' => array('use_captcha' => '0')));
     $this->assertTrue($form->is_valid());
     $this->assertTrue(0 === $form->get_input('use_captcha')->normalized_value());
     $this->assertTrue('0' === $form->get_input('use_captcha')->raw_value());
 }
 function test_many_valued()
 {
     //create a form with radio button in it.
     $form = new EE_Form_Section_Proper(array('name' => 'test1', 'subsections' => array('checkbox1' => new EE_Checkbox_Multi_Input(array('option1' => 'Option 1', 'option2' => 'Option 2')))));
     $checkbox = $form->get_input('checkbox1');
     //that radio button's normalization strategy is correct
     $this->assertInstanceOf('EE_Checkbox_Multi_Input', $checkbox);
     $this->assertInstanceOf('EE_Many_Valued_Normalization', $checkbox->get_normalization_strategy());
     //and that when it receives input, it sets it correctly
     $form->receive_form_submission(array('checkbox1' => array('option1')));
     $this->assertTrue($form->is_valid());
     $form->receive_form_submission(array('checkbox1' => array('option_nonexistent')));
     $this->assertFalse($form->is_valid());
     $form->receive_form_submission(array('checkbox1' => 'option1'));
     $this->assertTrue($form->is_valid());
     $form->receive_form_submission(array('checkbox1' => 'option_nonexistent'));
     $this->assertFalse($form->is_valid());
 }
 /**
  * @group 6781
  */
 public function test_get_validation_errors_accumulated()
 {
     $form = new EE_Form_Section_Proper(array('name' => 'Form', 'subsections' => array('radio1' => new EE_Radio_Button_Input(array('one' => 'One', 'two' => 'Two', 'three' => 'Three'), array('html_class' => 'spco-payment-method', 'default' => 'three')), 'input2' => new EE_Text_Input(array('required' => TRUE)), 'subsubsection' => new EE_Form_Section_Proper(array('subsections' => array('input3' => new EE_Float_Input(), 'input4' => new EE_Text_Input()))))));
     $post_data = array('Form' => array('radio1' => 'four-invalid', 'input2' => '', 'subsubsection' => array('input3' => 'non-number', 'input4' => 'whatever-ok')));
     $form->receive_form_submission($post_data);
     //submit twice, which should be fine; it shoudl jsut reset before
     //2nd submission
     $form->receive_form_submission($post_data);
     $this->assertFalse($form->is_valid());
     $all_errors = $form->get_validation_errors_accumulated();
     $this->assertEquals(3, count($all_errors));
     $error1 = array_shift($all_errors);
     $error2 = array_shift($all_errors);
     $error3 = array_shift($all_errors);
     $this->assertInstanceOf('EE_Validation_Error', $error1);
     $this->assertInstanceOf('EE_Radio_Button_Input', $error1->get_form_section());
     $this->assertEquals('radio1', $error1->get_form_section()->name());
     $this->assertInstanceOf('EE_Validation_Error', $error2);
     $this->assertInstanceOf('EE_Text_Input', $error2->get_form_section());
     $this->assertEquals('input2', $error2->get_form_section()->name());
     $this->assertInstanceOf('EE_Validation_Error', $error3);
     $this->assertInstanceOf('EE_Float_Input', $error3->get_form_section());
     $this->assertEquals('input3', $error3->get_form_section()->name());
 }