Exemple #1
0
 public function testElements()
 {
     $e = new Form\Element\Button();
     $this->assertTrue($e->validate());
     $this->assertTrue(strpos($e->render(), 'button') !== false);
     $e = new Form\Element\Checkbox();
     $e->setCheckedValue('ten');
     $this->assertTrue($e->getCheckedValue() == 'ten');
     $this->assertTrue(strpos($e->render(), 'checkbox') !== false);
     $this->assertTrue(strpos($e->render(), 'checked') === false);
     $e->setValue(true);
     $this->assertTrue(strpos($e->render(), 'checked') !== false);
     $e->setValue('ten');
     $this->assertTrue(strpos($e->render(), 'checked') !== false);
     $e->setValue('fail');
     $this->assertTrue(strpos($e->render(), 'checked') === false);
     $e = new Form\Element\CheckboxGroup();
     $this->assertTrue(strpos($e->render(), 'group') !== false);
     $e = new Form\ControlGroup();
     $this->assertTrue(strpos($e->render(), 'group') !== false);
     $e = new Form\Element\Email();
     $this->assertTrue(strpos($e->render(), 'email') !== false);
     $e = new Form\Element\Select();
     $e->setOptions(array('key' => 'Val'));
     $html = $e->render();
     $this->assertTrue(strpos($html, 'select') !== false);
     $this->assertTrue(strpos($html, 'option') !== false);
     $this->assertTrue(strpos($html, 'key') !== false);
     $this->assertTrue(strpos($html, 'Val') !== false);
     $e = new Form\Element\Submit();
     $this->assertTrue($e->validate());
     $this->assertTrue(strpos($e->render(), 'submit') !== false);
     $e = new Form\Element\Text();
     $e->setValue('test');
     $this->assertTrue(strpos($e->render(), 'test') !== false);
     $e = new Form\Element\TextArea();
     $e->setRows(10);
     $this->assertTrue(strpos($e->render(), '10') !== false);
     $e = new Form\Element\Url();
     $this->assertTrue(strpos($e->render(), 'url') !== false);
 }