public function test_form_start_tag()
 {
     $actual = FormTagHelper::start_form_tag('test');
     $matcher = array('tag' => 'form', 'attributes' => array('action' => 'test', 'method' => 'post'));
     $this->assertTag($matcher, $actual, 'Default attributes');
     $actual = FormTagHelper::start_form_tag(array('action' => 'test'));
     $this->assertTag($matcher, $actual, 'Default attributes in one parameter');
     $this->assertRegexp('/method="get"/', FormTagHelper::start_form_tag('test', array('method' => 'get')), 'Setting additional attributes');
     $this->assertRegexp('/enctype="multipart\\/form-data"/', FormTagHelper::start_form_tag('test', array('multipart' => true)), 'Setting multipart');
 }
Exemple #2
0
 /**
  * Obtain the string value of the form, depending on its
  * current output status.  This will either return the
  * starting or ending <form> tag if start() or end() were
  * previously called, respectively.  Otherwise, an empty
  * string is returned.
  *
  * @return string Start or end tag, or empty string
  */
 public function __toString()
 {
     switch ($this->status) {
         case 'start':
             $text = FormTagHelper::start_form_tag($this->start_tag_attributes);
             break;
         case 'end':
             $text = FormTagHelper::end_form_tag();
             break;
         default:
             $text = '';
             break;
     }
     $this->status = null;
     return $text;
 }