/** * tests main attrs of <form> tag on simple configurations */ public function testFormTagAttrs() { $opt = array('attrs' => array('class' => 'test-form-class', 'data-test' => 'test')); $Form = new Form($opt); $f = $Form->render(); $xml = simplexml_load_string($f); $class = (string) $xml['class']; $data_test = (string) $xml['data-test']; $method = (string) $xml['method']; $id = (string) $xml['id']; $this->assertEquals($opt['attrs']['class'], $class); $this->assertEquals($opt['attrs']['data-test'], $data_test); $this->assertEquals('post', $method); // default method $this->assertEquals('form1', $id); // default id for 1st form $opt = array('id' => null, 'action' => '#', 'template' => null, 'type' => 'file', 'method' => 'get', 'vars' => array()); $Form = new Form($opt); $f = $Form->render(); $xml = simplexml_load_string($f); $enctype = (string) $xml['enctype']; $method = (string) $xml['method']; $id = (string) $xml['id']; $action = (string) $xml['action']; $this->assertEquals('multipart/form-data', $enctype); $this->assertEquals($opt['method'], $method); $this->assertEquals('form2', $id); // default id for 2nd form $this->assertEquals($opt['action'], $action); }