コード例 #1
0
 function testPost()
 {
     $form = new SimpleForm(new SimpleFormTag(array('method' => 'post')), $this->page('C:\\Users\\Garen\\Documents\\CS580\\Recipes\\RecipesInLaravel\\public\\testtt.html'));
     $select = new SimpleSelectionTag(array('name' => 'a'));
     $select->addTag(new SimpleOptionTag(array('value' => 'aaa', 'selected' => '')));
     $form->addWidget($select);
     $this->assertIdentical($form->submit(), new SimplePostEncoding(array('a' => 'aaa')));
 }
コード例 #2
0
ファイル: SimpleFormTest.php プロジェクト: ming-hai/XoopsCore
 /**
  * @covers Xoops\Form\SimpleForm::render
  * @todo   Implement testRender().
  */
 public function testRender()
 {
     $value = $this->object->render();
     $this->assertTrue(is_string($value));
     $this->assertTrue(false !== strpos($value, '<form'));
     $this->assertTrue(false !== strpos($value, 'name="name"'));
     $this->assertTrue(false !== strpos($value, 'id="name"'));
     $this->assertTrue(false !== strpos($value, 'action="action"'));
     $this->assertTrue(false !== strpos($value, 'method="post"'));
     $this->assertTrue(false !== strpos($value, '</form>'));
 }
コード例 #3
0
ファイル: FormTest.php プロジェクト: b4oshany/wtforms-php
 public function test_construct_check_fields()
 {
     try {
         $form = new SimpleForm();
         $fields = $form->getFields();
         $this->assertEquals(2, count($fields));
         //order matters
         $this->assertEquals("WTForms\\Fields\\StringField", get_class($fields['str_field']));
         $this->assertEquals("str_field", $fields['str_field']->name);
         $this->assertFalse($fields['str_field']->required);
         $this->assertEquals("WTForms\\Fields\\IntegerField", get_class($fields['int_field']));
         $this->assertEquals("int_field", $fields['int_field']->name);
         $this->assertTrue($fields['int_field']->required);
     } catch (WTForms\Exception $e) {
         $this->fail($e->getMessage());
     }
 }
コード例 #4
0
 function testMultipleFieldsWithSameKey()
 {
     $form = new SimpleForm(new SimpleFormTag(array()), new SimpleUrl('htp://host'));
     $form->addWidget(new SimpleCheckboxTag(array('name' => 'a', 'type' => 'checkbox', 'value' => 'me')));
     $form->addWidget(new SimpleCheckboxTag(array('name' => 'a', 'type' => 'checkbox', 'value' => 'you')));
     $this->assertIdentical($form->getValue(new SimpleByName('a')), false);
     $this->assertTrue($form->setField(new SimpleByName('a'), 'me'));
     $this->assertIdentical($form->getValue(new SimpleByName('a')), 'me');
 }
コード例 #5
0
ファイル: browser.php プロジェクト: BackupTheBerlios/limb-svn
 /**
  *    Replaces missing form action.
  *    @param SimpleForm $form    Form object to submit.
  *    @return string             URL to send results to.
  *    @access private
  */
 function _getAction(&$form) {
     $action = $form->getAction();
     if ($action === false) {
         return $this->_page->getRequestUrl();
     } elseif ($action === true) {
         return '';
     }
     return $action;
 }
コード例 #6
0
ファイル: tidy_parser.php プロジェクト: ngugijames/ThinkUp
 /**
  *  Adds the widget into the form container.
  *  @param object $node             Tidy XML node of widget.
  *  @param SimpleForm $form         Form to add it to.
  *  @param string $enclosing_label  The label of any label
  *                                  tag we might be in.
  */
 private function addWidgetToForm($node, $form, $enclosing_label)
 {
     $widget = $this->tags()->createTag($node->name, $this->attributes($node));
     if (!$widget) {
         return;
     }
     $widget->setLabel($enclosing_label)->addContent($this->innerHtml($node));
     if ($node->name == 'select') {
         $widget->addTags($this->collectSelectOptions($node));
     }
     $form->addWidget($widget);
     $this->indexWidgetById($widget);
 }
コード例 #7
0
ファイル: form_test.php プロジェクト: VasuLief/simpletest
 public function TODO_testRemoveGetParamsFromAction()
 {
     Mock::generatePartial('SimplePage', 'MockPartialSimplePage', array('getUrl'));
     $page = new MockPartialSimplePage();
     $page->returns('getUrl', new SimpleUrl('htp://host/'));
     # Keep GET params in "action", if the form has no widgets
     $form = new SimpleForm(new SimpleFormTag(array('action' => '?test=1')), $page);
     $this->assertEqual($form->getAction()->asString(), 'htp://host/');
     $form = new SimpleForm(new SimpleFormTag(array('action' => '?test=1')), $page);
     $form->addWidget(new SimpleTextTag(array('name' => 'me', 'type' => 'text', 'value' => 'a')));
     $this->assertEqual($form->getAction()->asString(), 'htp://host/');
     $form = new SimpleForm(new SimpleFormTag(array('action' => '')), $page);
     $this->assertEqual($form->getAction()->asString(), 'htp://host/');
     $form = new SimpleForm(new SimpleFormTag(array('action' => '?test=1', 'method' => 'post')), $page);
     $this->assertEqual($form->getAction()->asString(), 'htp://host/?test=1');
 }