function testCheckingTheFormIsCancelled() { $form = new SimpleForm_Form(); $form->parse($this->getFormHtml('inputform.html')); $this->assertFalse($form->isSubmitted()); $this->assertFalse($form->isCancelled()); // fake the submission of the form $_GET[SimpleForm_Form::SUBMIT_MARKER] = 'inputform'; // submission does not equal cancelled $this->assertTrue($form->isSubmitted()); $this->assertFalse($form->isCancelled()); // but it should after cancel has a value $_GET[SimpleForm_Form::CANCEL_MARKER] = 'Cancel'; $this->assertTrue($form->isSubmitted()); $this->assertTrue($form->isCancelled()); }
/** * Forms should infer unchecked radio and checkboxes when a full request is loaded */ function testFormsFillEmpties() { $_SERVER['REQUEST_METHOD'] = 'POST'; $_POST = array('simpleform_submit_marker' => 'myform'); $form = new SimpleForm_Form(); $form->setAutoLoad(false); $form->parse($this->getFormHtml('checkboxgroupform.html')); $this->assertTrue($form->isSubmitted()); $this->assertEqual($form->getRequestParams(), $_POST); $getValues = $form->getValues(); $this->assertEqual('value1', $getValues['checkbox']); $this->assertEqual('value1', $getValues['radio']); // because checkbox and radio weren't in the request, they get NULLed $form->loadRequest(); $getValues = $form->getValues(); $this->assertEqual(NULL, $getValues['checkbox']); $this->assertEqual(NULL, $getValues['radio']); }