PageRenderTime 49ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/modules/jelix_tests/tests/jforms.htmllightbuilder2.html_cli.php

https://bitbucket.org/doubleface/jphpunit
PHP | 375 lines | 316 code | 49 blank | 10 comment | 0 complexity | ebccae16533dd4fe5886707fc8997d54 MD5 | raw file
  1. <?php
  2. /**
  3. * @package testapp
  4. * @subpackage unittest module
  5. * @author Jouanneau Laurent
  6. * @contributor Julien Issler
  7. * @copyright 2007-2008 Jouanneau laurent
  8. * @copyright 2008 Julien Issler
  9. * @link http://www.jelix.org
  10. * @licence GNU Lesser General Public Licence see LICENCE file or http://www.gnu.org/licenses/lgpl.html
  11. */
  12. require_once(JELIX_LIB_PATH.'forms/jFormsBase.class.php');
  13. require_once(JELIX_LIB_PATH.'forms/jFormsBuilderBase.class.php');
  14. require_once(JELIX_LIB_PATH.'forms/jFormsDataContainer.class.php');
  15. require_once(JELIX_LIB_PATH.'plugins/jforms/htmllight/htmllight.jformsbuilder.php');
  16. class testHTMLLightForm2 extends jFormsBase {
  17. }
  18. class testJFormsHtmlLightBuilder2 extends htmllightJformsBuilder {
  19. function getJsContent() { $js= $this->jsContent; $this->jsContent = '';return $js;}
  20. function clearJs() { $this->jsContent = ''; }
  21. }
  22. class UTjformsHTMLLightBuilder2 extends jUnitTestCaseDb {
  23. protected $form;
  24. protected $container;
  25. protected $builder;
  26. protected $formname;
  27. function testStart() {
  28. $this->container = new jFormsDataContainer('formtestlightB','');
  29. $this->form = new testHTMLLightForm2('formtestlightB', $this->container, true );
  30. $this->builder = new testJFormsHtmlLightBuilder2($this->form);
  31. $this->formname = $this->builder->getName();
  32. }
  33. function testOutputGroup(){
  34. $group= new jFormsControlgroup('identity');
  35. $group->label='Your identity';
  36. $ctrl= new jFormsControlinput('nom');
  37. $ctrl->required=true;
  38. $ctrl->label='Your name';
  39. $group->addChildControl($ctrl);
  40. $ctrl= new jFormsControlinput('prenom');
  41. $ctrl->defaultValue='robert';
  42. $ctrl->label='Your firstname';
  43. $group->addChildControl($ctrl);
  44. $ctrl= new jFormsControlradiobuttons('sexe');
  45. $ctrl->required=true;
  46. $ctrl->label='Vous êtes ';
  47. $ctrl->alertRequired='Vous devez indiquer le sexe, même si vous ne savez pas :-)';
  48. $ctrl->datasource= new jFormsStaticDatasource();
  49. $ctrl->datasource->data = array(
  50. 'h'=>'un homme',
  51. 'f'=>'une femme',
  52. 'no'=>'je ne sais pas',
  53. );
  54. $group->addChildControl($ctrl);
  55. $ctrl= new jFormsControlinput('mail');
  56. $ctrl->datatype= new jDatatypeemail();
  57. $ctrl->label='Votre mail';
  58. $group->addChildControl($ctrl);
  59. $this->form->addControl($group);
  60. ob_start();$this->builder->outputControlLabel($group);$out = ob_get_clean();
  61. $this->assertEqualOrDiff('', $out);
  62. $expected = '<fieldset><legend>Your identity</legend>'."\n";
  63. $expected .= '<table class="jforms-table-group" border="0">'."\n";
  64. $expected .= '<tr><th scope="row"><label class="jforms-label jforms-required" for="'.$this->formname.'_nom">Your name</label></th>'."\n";
  65. $expected .= '<td><input type="text" name="nom" id="'.$this->formname.'_nom" class=" jforms-required" value=""/></td></tr>'."\n";
  66. $expected .= '<tr><th scope="row"><label class="jforms-label" for="'.$this->formname.'_prenom">Your firstname</label></th>'."\n";
  67. $expected .= '<td><input type="text" name="prenom" id="'.$this->formname.'_prenom" value="robert"/></td></tr>'."\n";
  68. $expected .= '<tr><th scope="row"><span class="jforms-label jforms-required">Vous êtes </span></th>'."\n";
  69. $expected .= '<td><span class="jforms-radio jforms-ctl-sexe"><input type="radio" name="sexe" id="'.$this->formname.'_sexe_0" value="h" class=" jforms-required"/><label for="'.$this->formname.'_sexe_0">un homme</label></span>';
  70. $expected .= '<span class="jforms-radio jforms-ctl-sexe"><input type="radio" name="sexe" id="'.$this->formname.'_sexe_1" value="f" class=" jforms-required"/><label for="'.$this->formname.'_sexe_1">une femme</label></span>';
  71. $expected .= '<span class="jforms-radio jforms-ctl-sexe"><input type="radio" name="sexe" id="'.$this->formname.'_sexe_2" value="no" class=" jforms-required"/><label for="'.$this->formname.'_sexe_2">je ne sais pas</label></span></td></tr>'."\n";
  72. $expected .= '<tr><th scope="row"><label class="jforms-label" for="'.$this->formname.'_mail">Votre mail</label></th>'."\n";
  73. $expected .= '<td><input type="text" name="mail" id="'.$this->formname.'_mail" value=""/></td></tr>'."\n</table></fieldset>";
  74. ob_start();$this->builder->outputControl($group);$out = ob_get_clean();
  75. $this->assertEqualOrDiff($expected, $out);
  76. $this->assertEqualOrDiff('c = new jFormsControlString(\'nom\', \'Your name\');
  77. c.required = true;
  78. c.errRequired=\'"Your name" field is required\';
  79. c.errInvalid=\'"Your name" field is invalid\';
  80. jForms.tForm.addControl(c);
  81. c = new jFormsControlString(\'prenom\', \'Your firstname\');
  82. c.errInvalid=\'"Your firstname" field is invalid\';
  83. jForms.tForm.addControl(c);
  84. c = new jFormsControlString(\'sexe\', \'Vous êtes \');
  85. c.required = true;
  86. c.errRequired=\'Vous devez indiquer le sexe, même si vous ne savez pas :-)\';
  87. c.errInvalid=\'"Vous êtes " field is invalid\';
  88. jForms.tForm.addControl(c);
  89. c = new jFormsControlEmail(\'mail\', \'Votre mail\');
  90. c.errInvalid=\'"Votre mail" field is invalid\';
  91. jForms.tForm.addControl(c);
  92. ', $this->builder->getJsContent());
  93. $group->setReadOnly(true);
  94. $expected = '<fieldset><legend>Your identity</legend>'."\n";
  95. $expected .= '<table class="jforms-table-group" border="0">'."\n";
  96. $expected .= '<tr><th scope="row"><label class="jforms-label" for="'.$this->formname.'_nom">Your name</label></th>'."\n";
  97. $expected .= '<td><input type="text" name="nom" id="'.$this->formname.'_nom" readonly="readonly" class=" jforms-readonly" value=""/></td></tr>'."\n";
  98. $expected .= '<tr><th scope="row"><label class="jforms-label" for="'.$this->formname.'_prenom">Your firstname</label></th>'."\n";
  99. $expected .= '<td><input type="text" name="prenom" id="'.$this->formname.'_prenom" readonly="readonly" class=" jforms-readonly" value="robert"/></td></tr>'."\n";
  100. $expected .= '<tr><th scope="row"><span class="jforms-label">Vous êtes </span></th>'."\n";
  101. $expected .= '<td><span class="jforms-radio jforms-ctl-sexe"><input type="radio" name="sexe" id="'.$this->formname.'_sexe_0" value="h" readonly="readonly" class=" jforms-readonly"/><label for="'.$this->formname.'_sexe_0">un homme</label></span>';
  102. $expected .= '<span class="jforms-radio jforms-ctl-sexe"><input type="radio" name="sexe" id="'.$this->formname.'_sexe_1" value="f" readonly="readonly" class=" jforms-readonly"/><label for="'.$this->formname.'_sexe_1">une femme</label></span>';
  103. $expected .= '<span class="jforms-radio jforms-ctl-sexe"><input type="radio" name="sexe" id="'.$this->formname.'_sexe_2" value="no" readonly="readonly" class=" jforms-readonly"/><label for="'.$this->formname.'_sexe_2">je ne sais pas</label></span></td></tr>'."\n";
  104. $expected .= '<tr><th scope="row"><label class="jforms-label" for="'.$this->formname.'_mail">Votre mail</label></th>'."\n";
  105. $expected .= '<td><input type="text" name="mail" id="'.$this->formname.'_mail" readonly="readonly" class=" jforms-readonly" value=""/></td></tr>'."\n</table></fieldset>";
  106. ob_start();$this->builder->outputControl($group);$out = ob_get_clean();
  107. $this->assertEqualOrDiff($expected, $out);
  108. $this->assertEqualOrDiff('c = new jFormsControlString(\'nom\', \'Your name\');
  109. c.required = true;
  110. c.errRequired=\'"Your name" field is required\';
  111. c.errInvalid=\'"Your name" field is invalid\';
  112. jForms.tForm.addControl(c);
  113. c = new jFormsControlString(\'prenom\', \'Your firstname\');
  114. c.errInvalid=\'"Your firstname" field is invalid\';
  115. jForms.tForm.addControl(c);
  116. c = new jFormsControlString(\'sexe\', \'Vous êtes \');
  117. c.required = true;
  118. c.errRequired=\'Vous devez indiquer le sexe, même si vous ne savez pas :-)\';
  119. c.errInvalid=\'"Vous êtes " field is invalid\';
  120. jForms.tForm.addControl(c);
  121. c = new jFormsControlEmail(\'mail\', \'Votre mail\');
  122. c.errInvalid=\'"Votre mail" field is invalid\';
  123. jForms.tForm.addControl(c);
  124. ', $this->builder->getJsContent());
  125. }
  126. function testOutputChoice(){
  127. $choice= new jFormsControlChoice('status');
  128. $choice->label='Task Status';
  129. $choice->createItem('new','New');
  130. $choice->createItem('assigned','Assigned');
  131. $choice->createItem('closed','Closed');
  132. $ctrl= new jFormsControlinput('nom');
  133. $ctrl->required=true;
  134. $ctrl->label='Name';
  135. $choice->addChildControl($ctrl,'assigned');
  136. $ctrl= new jFormsControlinput('prenom');
  137. $ctrl->defaultValue='robert';
  138. $ctrl->label='Firstname';
  139. $choice->addChildControl($ctrl,'assigned');
  140. $ctrl= new jFormsControlMenulist('reason');
  141. $ctrl->required=true;
  142. $ctrl->label='Reason ';
  143. $ctrl->alertRequired='Hey, specify a reason !';
  144. $ctrl->datasource= new jFormsStaticDatasource();
  145. $ctrl->datasource->data = array(
  146. 'aa'=>'fixed',
  147. 'bb'=>'won t fixed',
  148. 'cc'=>'later',
  149. );
  150. $choice->addChildControl($ctrl,'closed');
  151. $this->form->addControl($choice);
  152. ob_start();$this->builder->outputControlLabel($choice);$out = ob_get_clean();
  153. $this->assertEqualOrDiff('<label class="jforms-label" for="'.$this->formname.'_status">Task Status</label>', $out);
  154. $expected = '<ul class="jforms-choice jforms-ctl-status" >'."\n";
  155. $expected .= '<li><label><input type="radio" name="status" id="'.$this->formname.'_status_0" value="new" onclick="jForms.getForm(\'\').getControl(\'status\').activate(\'new\')"/>New</label> </li>'."\n";
  156. $expected .= '<li><label><input type="radio" name="status" id="'.$this->formname.'_status_1" value="assigned" onclick="jForms.getForm(\'\').getControl(\'status\').activate(\'assigned\')"/>Assigned</label> <span class="jforms-item-controls"><label class="jforms-label" for="'.$this->formname.'_nom">Name</label> <input type="text" name="nom" id="'.$this->formname.'_nom" readonly="readonly" class=" jforms-readonly" value=""/></span>'."\n";
  157. $expected .= ' <span class="jforms-item-controls"><label class="jforms-label" for="'.$this->formname.'_prenom">Firstname</label> <input type="text" name="prenom" id="'.$this->formname.'_prenom" readonly="readonly" class=" jforms-readonly" value="robert"/></span>'."\n";
  158. $expected .= '</li>'."\n";
  159. $expected .= '<li><label><input type="radio" name="status" id="'.$this->formname.'_status_2" value="closed" onclick="jForms.getForm(\'\').getControl(\'status\').activate(\'closed\')"/>Closed</label> <span class="jforms-item-controls"><label class="jforms-label jforms-required" for="'.$this->formname.'_reason">Reason </label> <select name="reason" id="'.$this->formname.'_reason" class=" jforms-required" size="1"><option value="aa">fixed</option><option value="bb">won t fixed</option><option value="cc">later</option></select></span>'."\n";
  160. $expected .= '</li>'."\n";
  161. $expected .= '</ul>'."\n";
  162. ob_start();$this->builder->outputControl($choice);$out = ob_get_clean();
  163. $this->assertEqualOrDiff($expected, $out);
  164. $this->assertEqualOrDiff('c = new jFormsControlChoice(\'status\', \'Task Status\');
  165. c.errInvalid=\'"Task Status" field is invalid\';
  166. jForms.tForm.addControl(c);
  167. c2 = c;
  168. c2.items[\'new\']=[];
  169. c = new jFormsControlString(\'nom\', \'Name\');
  170. c.required = true;
  171. c.errRequired=\'"Name" field is required\';
  172. c.errInvalid=\'"Name" field is invalid\';
  173. c2.addControl(c, \'assigned\');
  174. c = new jFormsControlString(\'prenom\', \'Firstname\');
  175. c.errInvalid=\'"Firstname" field is invalid\';
  176. c2.addControl(c, \'assigned\');
  177. c = new jFormsControlString(\'reason\', \'Reason \');
  178. c.required = true;
  179. c.errRequired=\'Hey, specify a reason !\';
  180. c.errInvalid=\'"Reason " field is invalid\';
  181. c2.addControl(c, \'closed\');
  182. c2.activate(\'\');
  183. ', $this->builder->getJsContent());
  184. $this->form->getContainer()->data['status']='assigned';
  185. $expected = '<ul class="jforms-choice jforms-ctl-status" >'."\n";
  186. $expected .= '<li><label><input type="radio" name="status" id="'.$this->formname.'_status_0" value="new" onclick="jForms.getForm(\'\').getControl(\'status\').activate(\'new\')"/>New</label> </li>'."\n";
  187. $expected .= '<li><label><input type="radio" name="status" id="'.$this->formname.'_status_1" value="assigned" checked="checked" onclick="jForms.getForm(\'\').getControl(\'status\').activate(\'assigned\')"/>Assigned</label> <span class="jforms-item-controls"><label class="jforms-label" for="'.$this->formname.'_nom">Name</label> <input type="text" name="nom" id="'.$this->formname.'_nom" readonly="readonly" class=" jforms-readonly" value=""/></span>'."\n";
  188. $expected .= ' <span class="jforms-item-controls"><label class="jforms-label" for="'.$this->formname.'_prenom">Firstname</label> <input type="text" name="prenom" id="'.$this->formname.'_prenom" readonly="readonly" class=" jforms-readonly" value="robert"/></span>'."\n";
  189. $expected .= '</li>'."\n";
  190. $expected .= '<li><label><input type="radio" name="status" id="'.$this->formname.'_status_2" value="closed" onclick="jForms.getForm(\'\').getControl(\'status\').activate(\'closed\')"/>Closed</label> <span class="jforms-item-controls"><label class="jforms-label jforms-required" for="'.$this->formname.'_reason">Reason </label> <select name="reason" id="'.$this->formname.'_reason" class=" jforms-required" size="1"><option value="aa">fixed</option><option value="bb">won t fixed</option><option value="cc">later</option></select></span>'."\n";
  191. $expected .= '</li>'."\n";
  192. $expected .= '</ul>'."\n";
  193. ob_start();$this->builder->outputControl($choice);$out = ob_get_clean();
  194. $this->assertEqualOrDiff($expected, $out);
  195. $this->assertEqualOrDiff('c = new jFormsControlChoice(\'status\', \'Task Status\');
  196. c.errInvalid=\'"Task Status" field is invalid\';
  197. jForms.tForm.addControl(c);
  198. c2 = c;
  199. c2.items[\'new\']=[];
  200. c = new jFormsControlString(\'nom\', \'Name\');
  201. c.required = true;
  202. c.errRequired=\'"Name" field is required\';
  203. c.errInvalid=\'"Name" field is invalid\';
  204. c2.addControl(c, \'assigned\');
  205. c = new jFormsControlString(\'prenom\', \'Firstname\');
  206. c.errInvalid=\'"Firstname" field is invalid\';
  207. c2.addControl(c, \'assigned\');
  208. c = new jFormsControlString(\'reason\', \'Reason \');
  209. c.required = true;
  210. c.errRequired=\'Hey, specify a reason !\';
  211. c.errInvalid=\'"Reason " field is invalid\';
  212. c2.addControl(c, \'closed\');
  213. c2.activate(\'assigned\');
  214. ', $this->builder->getJsContent());
  215. $this->form->getContainer()->data['status']='new';
  216. $expected = '<ul class="jforms-choice jforms-ctl-status" >'."\n";
  217. $expected .= '<li><label><input type="radio" name="status" id="'.$this->formname.'_status_0" value="new" checked="checked" onclick="jForms.getForm(\'\').getControl(\'status\').activate(\'new\')"/>New</label> </li>'."\n";
  218. $expected .= '<li><label><input type="radio" name="status" id="'.$this->formname.'_status_1" value="assigned" onclick="jForms.getForm(\'\').getControl(\'status\').activate(\'assigned\')"/>Assigned</label> <span class="jforms-item-controls"><label class="jforms-label" for="'.$this->formname.'_nom">Name</label> <input type="text" name="nom" id="'.$this->formname.'_nom" readonly="readonly" class=" jforms-readonly" value=""/></span>'."\n";
  219. $expected .= ' <span class="jforms-item-controls"><label class="jforms-label" for="'.$this->formname.'_prenom">Firstname</label> <input type="text" name="prenom" id="'.$this->formname.'_prenom" readonly="readonly" class=" jforms-readonly" value="robert"/></span>'."\n";
  220. $expected .= '</li>'."\n";
  221. $expected .= '<li><label><input type="radio" name="status" id="'.$this->formname.'_status_2" value="closed" onclick="jForms.getForm(\'\').getControl(\'status\').activate(\'closed\')"/>Closed</label> <span class="jforms-item-controls"><label class="jforms-label jforms-required" for="'.$this->formname.'_reason">Reason </label> <select name="reason" id="'.$this->formname.'_reason" class=" jforms-required" size="1"><option value="aa">fixed</option><option value="bb">won t fixed</option><option value="cc">later</option></select></span>'."\n";
  222. $expected .= '</li>'."\n";
  223. $expected .= '</ul>'."\n";
  224. ob_start();$this->builder->outputControl($choice);$out = ob_get_clean();
  225. $this->assertEqualOrDiff($expected, $out);
  226. $this->assertEqualOrDiff('c = new jFormsControlChoice(\'status\', \'Task Status\');
  227. c.errInvalid=\'"Task Status" field is invalid\';
  228. jForms.tForm.addControl(c);
  229. c2 = c;
  230. c2.items[\'new\']=[];
  231. c = new jFormsControlString(\'nom\', \'Name\');
  232. c.required = true;
  233. c.errRequired=\'"Name" field is required\';
  234. c.errInvalid=\'"Name" field is invalid\';
  235. c2.addControl(c, \'assigned\');
  236. c = new jFormsControlString(\'prenom\', \'Firstname\');
  237. c.errInvalid=\'"Firstname" field is invalid\';
  238. c2.addControl(c, \'assigned\');
  239. c = new jFormsControlString(\'reason\', \'Reason \');
  240. c.required = true;
  241. c.errRequired=\'Hey, specify a reason !\';
  242. c.errInvalid=\'"Reason " field is invalid\';
  243. c2.addControl(c, \'closed\');
  244. c2.activate(\'new\');
  245. ', $this->builder->getJsContent());
  246. $this->form->getContainer()->data['status']='closed';
  247. $expected = '<ul class="jforms-choice jforms-ctl-status" >'."\n";
  248. $expected .= '<li><label><input type="radio" name="status" id="'.$this->formname.'_status_0" value="new" onclick="jForms.getForm(\'\').getControl(\'status\').activate(\'new\')"/>New</label> </li>'."\n";
  249. $expected .= '<li><label><input type="radio" name="status" id="'.$this->formname.'_status_1" value="assigned" onclick="jForms.getForm(\'\').getControl(\'status\').activate(\'assigned\')"/>Assigned</label> <span class="jforms-item-controls"><label class="jforms-label" for="'.$this->formname.'_nom">Name</label> <input type="text" name="nom" id="'.$this->formname.'_nom" readonly="readonly" class=" jforms-readonly" value=""/></span>'."\n";
  250. $expected .= ' <span class="jforms-item-controls"><label class="jforms-label" for="'.$this->formname.'_prenom">Firstname</label> <input type="text" name="prenom" id="'.$this->formname.'_prenom" readonly="readonly" class=" jforms-readonly" value="robert"/></span>'."\n";
  251. $expected .= '</li>'."\n";
  252. $expected .= '<li><label><input type="radio" name="status" id="'.$this->formname.'_status_2" value="closed" checked="checked" onclick="jForms.getForm(\'\').getControl(\'status\').activate(\'closed\')"/>Closed</label> <span class="jforms-item-controls"><label class="jforms-label jforms-required" for="'.$this->formname.'_reason">Reason </label> <select name="reason" id="'.$this->formname.'_reason" class=" jforms-required" size="1"><option value="aa">fixed</option><option value="bb">won t fixed</option><option value="cc">later</option></select></span>'."\n";
  253. $expected .= '</li>'."\n";
  254. $expected .= '</ul>'."\n";
  255. ob_start();$this->builder->outputControl($choice);$out = ob_get_clean();
  256. $this->assertEqualOrDiff($expected, $out);
  257. $this->assertEqualOrDiff('c = new jFormsControlChoice(\'status\', \'Task Status\');
  258. c.errInvalid=\'"Task Status" field is invalid\';
  259. jForms.tForm.addControl(c);
  260. c2 = c;
  261. c2.items[\'new\']=[];
  262. c = new jFormsControlString(\'nom\', \'Name\');
  263. c.required = true;
  264. c.errRequired=\'"Name" field is required\';
  265. c.errInvalid=\'"Name" field is invalid\';
  266. c2.addControl(c, \'assigned\');
  267. c = new jFormsControlString(\'prenom\', \'Firstname\');
  268. c.errInvalid=\'"Firstname" field is invalid\';
  269. c2.addControl(c, \'assigned\');
  270. c = new jFormsControlString(\'reason\', \'Reason \');
  271. c.required = true;
  272. c.errRequired=\'Hey, specify a reason !\';
  273. c.errInvalid=\'"Reason " field is invalid\';
  274. c2.addControl(c, \'closed\');
  275. c2.activate(\'closed\');
  276. ', $this->builder->getJsContent());
  277. }
  278. public function testFormWithExternalUrlAsAction(){
  279. $this->builder->setAction('http://www.jelix.org/dummy.php',array());
  280. ob_start();
  281. $this->builder->outputHeader(array('method'=>'post'));
  282. $out = ob_get_clean();
  283. $result ='<form action="http://www.jelix.org/dummy.php" method="post" id="'.$this->builder->getName().'"><script type="text/javascript">
  284. //<![CDATA[
  285. jForms.tForm = new jFormsForm(\'jforms_formtestlightB\');
  286. jForms.tForm.setErrorDecorator(new jFormsErrorDecoratorAlert());
  287. jForms.tForm.setHelpDecorator(new jFormsHelpDecoratorAlert());
  288. jForms.declareForm(jForms.tForm);
  289. //]]>
  290. </script><div class="jforms-hiddens"><input type="hidden" name="__JFORMS_TOKEN__" value="'.$this->container->token.'"/>
  291. </div>';
  292. $this->assertEqualOrDiff($result, $out);
  293. $this->assertEqualOrDiff('', $this->builder->getJsContent());
  294. $this->builder->setAction('http://www.jelix.org/dummy.php',array('foo'=>'bar'));
  295. ob_start();
  296. $this->builder->outputHeader(array('method'=>'post'));
  297. $out = ob_get_clean();
  298. $result ='<form action="http://www.jelix.org/dummy.php" method="post" id="'.$this->builder->getName().'"><script type="text/javascript">
  299. //<![CDATA[
  300. jForms.tForm = new jFormsForm(\'jforms_formtestlightB1\');
  301. jForms.tForm.setErrorDecorator(new jFormsErrorDecoratorAlert());
  302. jForms.tForm.setHelpDecorator(new jFormsHelpDecoratorAlert());
  303. jForms.declareForm(jForms.tForm);
  304. //]]>
  305. </script><div class="jforms-hiddens"><input type="hidden" name="foo" value="bar"/>
  306. <input type="hidden" name="__JFORMS_TOKEN__" value="'.$this->container->token.'"/>
  307. </div>';
  308. $this->assertEqualOrDiff($result, $out);
  309. $this->assertEqualOrDiff('', $this->builder->getJsContent());
  310. $this->builder->setAction('https://www.jelix.org/dummy.php',array());
  311. ob_start();
  312. $this->builder->outputHeader(array('method'=>'get'));
  313. $out = ob_get_clean();
  314. $result ='<form action="https://www.jelix.org/dummy.php" method="get" id="'.$this->builder->getName().'"><script type="text/javascript">
  315. //<![CDATA[
  316. jForms.tForm = new jFormsForm(\'jforms_formtestlightB2\');
  317. jForms.tForm.setErrorDecorator(new jFormsErrorDecoratorAlert());
  318. jForms.tForm.setHelpDecorator(new jFormsHelpDecoratorAlert());
  319. jForms.declareForm(jForms.tForm);
  320. //]]>
  321. </script><div class="jforms-hiddens"><input type="hidden" name="__JFORMS_TOKEN__" value="'.$this->container->token.'"/>
  322. </div>';
  323. $this->assertEqualOrDiff($result, $out);
  324. $this->assertEqualOrDiff('', $this->builder->getJsContent());
  325. }
  326. }