Exemplo n.º 1
0
 public function testEmptyFormNameShouldNotRenderEmptyFormId()
 {
     $form = new Form();
     $form->setMethod('post')->setAction('/foo/bar')->setView($this->getView());
     $html = $form->render();
     $this->assertNotContains('id=""', $html, $html);
 }
Exemplo n.º 2
0
 /**
  * @group ZF-4038
  */
 public function testCaptchaShouldRenderFullyQualifiedElementName()
 {
     $form = new Form();
     $form->addElement($this->element)->setElementsBelongTo('bar');
     $html = $form->render(new View());
     $this->assertContains('name="bar[foo', $html, $html);
     $this->assertContains('id="bar-foo-', $html, $html);
     $this->form = $form;
 }
Exemplo n.º 3
0
 /**
  * @group ZF-2828
  */
 public function testCanPopulateCheckboxOptionsFromPostedData()
 {
     $form = new Form(array('elements' => array('100_1' => array('MultiCheckbox', array('multiOptions' => array('100_1_1' => 'Agriculture', '100_1_2' => 'Automotive', '100_1_12' => 'Chemical', '100_1_13' => 'Communications'), 'required' => true)))));
     $data = array('100_1' => array('100_1_1', '100_1_2', '100_1_12', '100_1_13'));
     $form->populate($data);
     $html = $form->render($this->getView());
     foreach ($form->getElement('100_1')->getMultiOptions() as $key => $value) {
         if (!preg_match('#(<input[^>]*' . $key . '[^>]*>)#', $html, $m)) {
             $this->fail('Missing input for a given multi option: ' . $html);
         }
         $this->assertContains('checked="checked"', $m[1]);
     }
 }
Exemplo n.º 4
0
 /**
  * @group ZF-2950
  */
 public function testSubFormGetsUniqueIdWithName()
 {
     $form = new Form();
     $form->setView($this->getView())->setName('testform')->addSubForm(new \Zend\Form\SubForm(), 'testform');
     $html = $form->render();
     $this->assertContains('<dt id="testform-label">&#160;</dt>', $html);
     $this->assertContains('<dd id="testform-element">', $html);
 }
Exemplo n.º 5
0
 /**
  * @group ZF-3272
  */
 public function testRenderedSubFormDtShouldContainNoBreakSpace()
 {
     $subForm = new SubForm(array('elements' => array('foo' => 'text', 'bar' => 'text')));
     $form = new Form();
     $form->addSubForm($subForm, 'foobar')->setView(new View());
     $html = $form->render();
     $this->assertContains('>&#160;</dt>', $html);
 }