/testapp/modules/jelix_tests/tests/jforms.htmlbuilder.html_cli.php
PHP | 1441 lines | 1402 code | 22 blank | 17 comment | 22 complexity | c76bae4f28f1d2ef855496ecae1c9e98 MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.1
Large files files are truncated, but you can click here to view the full file
- <?php
- /**
- * @package testapp
- * @subpackage unittest module
- * @author Jouanneau Laurent
- * @contributor Dominique Papin, Julien Issler
- * @copyright 2007-2008 Jouanneau laurent
- * @copyright 2008 Dominique Papin
- * @copyright 2008 Julien Issler
- * @link http://www.jelix.org
- * @licence GNU Lesser General Public Licence see LICENCE file or http://www.gnu.org/licenses/lgpl.html
- */
- require_once(JELIX_LIB_PATH.'forms/jFormsBase.class.php');
- require_once(JELIX_LIB_PATH.'forms/jFormsBuilderBase.class.php');
- require_once(JELIX_LIB_PATH.'forms/jFormsDataContainer.class.php');
- require_once(JELIX_LIB_PATH.'plugins/jforms/html/html.jformsbuilder.php');
- class testHMLForm extends jFormsBase {
- }
- class testJFormsHtmlBuilder extends htmlJformsBuilder {
- function getJsContent() { $js= $this->jsContent; $this->jsContent = '';return $js;}
- function clearJs() { $this->jsContent = ''; }
- }
- class UTjformsHTMLBuilder extends jUnitTestCaseDb {
- protected static $mysharedfixture;
- function testStart() {
- self::$mysharedfixture = new stdClass;
- $GLOBALS['gJConfig']->locale = 'en_EN';
- self::$mysharedfixture->container = new jFormsDataContainer('formtest','');
- self::$mysharedfixture->form = new testHMLForm('formtest', self::$mysharedfixture->container, true );
- self::$mysharedfixture->form->securityLevel = 0;
- self::$mysharedfixture->builder = new testJFormsHtmlBuilder(self::$mysharedfixture->form);
- }
- function testOutputHeader(){
- self::$mysharedfixture->builder->setAction('jelix_tests~urlsig:url1',array());
- ob_start();
- self::$mysharedfixture->builder->outputHeader(array('method'=>'post'));
- $out = ob_get_clean();
- $result ='<form action="'.$GLOBALS['gJConfig']->urlengine['basePath'].'index.php" method="post" id="'.self::$mysharedfixture->builder->getName().'"><script type="text/javascript">
- //<![CDATA[
- jFormsJQ.tForm = new jFormsJQForm(\'jforms_formtest\');
- jFormsJQ.tForm.setErrorDecorator(new jFormsJQErrorDecoratorAlert());
- jFormsJQ.tForm.setHelpDecorator(new jFormsJQHelpDecoratorAlert());
- jFormsJQ.declareForm(jFormsJQ.tForm);
- //]]>
- </script><div class="jforms-hiddens"><input type="hidden" name="module" value="jelix_tests"/>
- <input type="hidden" name="action" value="urlsig:url1"/>
- </div>';
- $this->assertEqualOrDiff($result, $out);
- $this->assertEqualOrDiff('', self::$mysharedfixture->builder->getJsContent());
- self::$mysharedfixture->form->securityLevel = 1;
- self::$mysharedfixture->builder->setAction('jelix_tests~urlsig:url1',array('foo'=>'b>ar'));
- ob_start();
- self::$mysharedfixture->builder->outputHeader(array('method'=>'get'));
- $out = ob_get_clean();
- $result ='<form action="'.$GLOBALS['gJConfig']->urlengine['basePath'].'index.php" method="get" id="'.self::$mysharedfixture->builder->getName().'"><script type="text/javascript">
- //<![CDATA[
- jFormsJQ.tForm = new jFormsJQForm(\'jforms_formtest1\');
- jFormsJQ.tForm.setErrorDecorator(new jFormsJQErrorDecoratorAlert());
- jFormsJQ.tForm.setHelpDecorator(new jFormsJQHelpDecoratorAlert());
- jFormsJQ.declareForm(jFormsJQ.tForm);
- //]]>
- </script><div class="jforms-hiddens"><input type="hidden" name="foo" value="b>ar"/>
- <input type="hidden" name="module" value="jelix_tests"/>
- <input type="hidden" name="action" value="urlsig:url1"/>
- <input type="hidden" name="__JFORMS_TOKEN__" value="'.self::$mysharedfixture->container->token.'"/>
- </div>';
- $this->assertEqualOrDiff($result, $out);
- self::$mysharedfixture->formname = self::$mysharedfixture->builder->getName();
- $this->assertEqualOrDiff('', self::$mysharedfixture->builder->getJsContent());
- self::$mysharedfixture->form->securityLevel = 0;
- }
- function testOutputFooter(){
- ob_start();
- self::$mysharedfixture->builder->outputFooter();
- $out = ob_get_clean();
- $this->assertEqualOrDiff('<script type="text/javascript">
- //<![CDATA[
- (function(){var c, c2;
- })();
- //]]>
- </script></form>', $out);
- }
- function testOutputInput(){
- $ctrl= new jFormsControlinput('input1');
- $ctrl->datatype= new jDatatypeString();
- $ctrl->label='Votre nom';
- self::$mysharedfixture->form->addControl($ctrl);
- ob_start();self::$mysharedfixture->builder->outputControlLabel($ctrl);$out = ob_get_clean();
- $this->assertEqualOrDiff('<label class="jforms-label" for="'.self::$mysharedfixture->formname.'_input1">Votre nom</label>', $out);
- ob_start();self::$mysharedfixture->builder->outputControl($ctrl);$out = ob_get_clean();
- $this->assertEqualOrDiff('<input type="text" name="input1" id="'.self::$mysharedfixture->formname.'_input1" value=""/>', $out);
- $this->assertEqualOrDiff('c = new jFormsJQControlString(\'input1\', \'Votre nom\');
- c.errInvalid=\'"Votre nom" field is invalid\';
- jFormsJQ.tForm.addControl(c);
- ', self::$mysharedfixture->builder->getJsContent());
- self::$mysharedfixture->form->setData('input1','toto');
- ob_start();self::$mysharedfixture->builder->outputControl($ctrl);$out = ob_get_clean();
- $this->assertEqualOrDiff('<input type="text" name="input1" id="'.self::$mysharedfixture->formname.'_input1" value="toto"/>', $out);
- $this->assertEqualOrDiff('c = new jFormsJQControlString(\'input1\', \'Votre nom\');
- c.errInvalid=\'"Votre nom" field is invalid\';
- jFormsJQ.tForm.addControl(c);
- ', self::$mysharedfixture->builder->getJsContent());
- $ctrl->defaultValue='laurent';
- ob_start();self::$mysharedfixture->builder->outputControl($ctrl);$out = ob_get_clean();
- $this->assertEqualOrDiff('<input type="text" name="input1" id="'.self::$mysharedfixture->formname.'_input1" value="toto"/>', $out);
- $this->assertEqualOrDiff('c = new jFormsJQControlString(\'input1\', \'Votre nom\');
- c.errInvalid=\'"Votre nom" field is invalid\';
- jFormsJQ.tForm.addControl(c);
- ', self::$mysharedfixture->builder->getJsContent());
- self::$mysharedfixture->form->removeControl($ctrl->ref);
- self::$mysharedfixture->form->addControl($ctrl);
- ob_start();self::$mysharedfixture->builder->outputControl($ctrl);$out = ob_get_clean();
- $this->assertEqualOrDiff('<input type="text" name="input1" id="'.self::$mysharedfixture->formname.'_input1" value="laurent"/>', $out);
- $this->assertEqualOrDiff('c = new jFormsJQControlString(\'input1\', \'Votre nom\');
- c.errInvalid=\'"Votre nom" field is invalid\';
- jFormsJQ.tForm.addControl(c);
- ', self::$mysharedfixture->builder->getJsContent());
- $ctrl->required=true;
- ob_start();self::$mysharedfixture->builder->outputControl($ctrl);$out = ob_get_clean();
- $this->assertEqualOrDiff('<input type="text" name="input1" id="'.self::$mysharedfixture->formname.'_input1" class=" jforms-required" value="laurent"/>', $out);
- $this->assertEqualOrDiff('c = new jFormsJQControlString(\'input1\', \'Votre nom\');
- c.required = true;
- c.errRequired=\'"Votre nom" field is required\';
- c.errInvalid=\'"Votre nom" field is invalid\';
- jFormsJQ.tForm.addControl(c);
- ', self::$mysharedfixture->builder->getJsContent());
- $ctrl->setReadOnly(true);
- $ctrl->required=false;
- ob_start();self::$mysharedfixture->builder->outputControl($ctrl);$out = ob_get_clean();
- $this->assertEqualOrDiff('<input type="text" name="input1" id="'.self::$mysharedfixture->formname.'_input1" readonly="readonly" class=" jforms-readonly" value="laurent"/>', $out);
- $this->assertEqualOrDiff('c = new jFormsJQControlString(\'input1\', \'Votre nom\');
- c.errInvalid=\'"Votre nom" field is invalid\';
- jFormsJQ.tForm.addControl(c);
- ', self::$mysharedfixture->builder->getJsContent());
- $ctrl->setReadOnly(false);
- $ctrl->help='some help';
- ob_start();self::$mysharedfixture->builder->outputControl($ctrl);$out = ob_get_clean();
- $this->assertEqualOrDiff('<input type="text" name="input1" id="'.self::$mysharedfixture->formname.'_input1" value="laurent"/><span class="jforms-help"><a href="javascript:jFormsJQ.showHelp(\''. self::$mysharedfixture->formname.'\',\'input1\')">?</a></span>', $out);
- $this->assertEqualOrDiff('c = new jFormsJQControlString(\'input1\', \'Votre nom\');
- c.help=\'some help\';
- c.errInvalid=\'"Votre nom" field is invalid\';
- jFormsJQ.tForm.addControl(c);
- ', self::$mysharedfixture->builder->getJsContent());
- $ctrl->help="some \nhelp with ' and\nline break.";
- ob_start();self::$mysharedfixture->builder->outputControl($ctrl);$out = ob_get_clean();
- $this->assertEqualOrDiff('<input type="text" name="input1" id="'.self::$mysharedfixture->formname.'_input1" value="laurent"/><span class="jforms-help"><a href="javascript:jFormsJQ.showHelp(\''. self::$mysharedfixture->formname.'\',\'input1\')">?</a></span>', $out);
- $this->assertEqualOrDiff('c = new jFormsJQControlString(\'input1\', \'Votre nom\');
- c.help=\'some \nhelp with \\\' and\nline break.\';
- c.errInvalid=\'"Votre nom" field is invalid\';
- jFormsJQ.tForm.addControl(c);
- ', self::$mysharedfixture->builder->getJsContent());
- $ctrl->hint='ceci est un tooltip';
- $ctrl->help='some help';
- ob_start();self::$mysharedfixture->builder->outputControlLabel($ctrl);$out = ob_get_clean();
- $this->assertEqualOrDiff('<label class="jforms-label" for="'.self::$mysharedfixture->formname.'_input1" title="ceci est un tooltip">Votre nom</label>', $out);
- ob_start();self::$mysharedfixture->builder->outputControl($ctrl);$out = ob_get_clean();
- $this->assertEqualOrDiff('<input type="text" name="input1" id="'.self::$mysharedfixture->formname.'_input1" title="ceci est un tooltip" value="laurent"/><span class="jforms-help"><a href="javascript:jFormsJQ.showHelp(\''. self::$mysharedfixture->formname.'\',\'input1\')">?</a></span>', $out);
- $this->assertEqualOrDiff('c = new jFormsJQControlString(\'input1\', \'Votre nom\');
- c.help=\'some help\';
- c.errInvalid=\'"Votre nom" field is invalid\';
- jFormsJQ.tForm.addControl(c);
- ', self::$mysharedfixture->builder->getJsContent());
- $ctrl->help='';
- $ctrl->hint='';
- $ctrl->datatype->addFacet('maxLength',5);
- ob_start();self::$mysharedfixture->builder->outputControl($ctrl);$out = ob_get_clean();
- $this->assertEqualOrDiff('<input type="text" name="input1" id="'.self::$mysharedfixture->formname.'_input1" maxlength="5" value="laurent"/>', $out);
- $this->assertEqualOrDiff('c = new jFormsJQControlString(\'input1\', \'Votre nom\');
- c.maxLength = \'5\';
- c.errInvalid=\'"Votre nom" field is invalid\';
- jFormsJQ.tForm.addControl(c);
- ', self::$mysharedfixture->builder->getJsContent());
- }
- function testOutputCheckbox(){
- $ctrl= new jFormsControlCheckbox('chk1');
- $ctrl->datatype= new jDatatypeString();
- $ctrl->label='Une option';
- self::$mysharedfixture->form->addControl($ctrl);
- ob_start();self::$mysharedfixture->builder->outputControlLabel($ctrl);$out = ob_get_clean();
- $this->assertEqualOrDiff('<label class="jforms-label" for="'.self::$mysharedfixture->formname.'_chk1">Une option</label>', $out);
- ob_start();self::$mysharedfixture->builder->outputControl($ctrl);$out = ob_get_clean();
- $this->assertEqualOrDiff('<input type="checkbox" name="chk1" id="'.self::$mysharedfixture->formname.'_chk1" value="1"/>', $out);
- $this->assertEqualOrDiff('c = new jFormsJQControlBoolean(\'chk1\', \'Une option\');
- c.errInvalid=\'"Une option" field is invalid\';
- jFormsJQ.tForm.addControl(c);
- ', self::$mysharedfixture->builder->getJsContent());
- self::$mysharedfixture->form->setData('chk1','1');
- ob_start();self::$mysharedfixture->builder->outputControl($ctrl);$out = ob_get_clean();
- $this->assertEqualOrDiff('<input type="checkbox" name="chk1" id="'.self::$mysharedfixture->formname.'_chk1" checked="checked" value="1"/>', $out);
- $this->assertEqualOrDiff('c = new jFormsJQControlBoolean(\'chk1\', \'Une option\');
- c.errInvalid=\'"Une option" field is invalid\';
- jFormsJQ.tForm.addControl(c);
- ', self::$mysharedfixture->builder->getJsContent());
- $ctrl= new jFormsControlCheckbox('chk2');
- $ctrl->datatype= new jDatatypeString();
- $ctrl->label='Une option';
- self::$mysharedfixture->form->addControl($ctrl);
- ob_start();self::$mysharedfixture->builder->outputControlLabel($ctrl);$out = ob_get_clean();
- $this->assertEqualOrDiff('<label class="jforms-label" for="'.self::$mysharedfixture->formname.'_chk2">Une option</label>', $out);
- ob_start();self::$mysharedfixture->builder->outputControl($ctrl);$out = ob_get_clean();
- $this->assertEqualOrDiff('<input type="checkbox" name="chk2" id="'.self::$mysharedfixture->formname.'_chk2" value="1"/>', $out);
- $this->assertEqualOrDiff('c = new jFormsJQControlBoolean(\'chk2\', \'Une option\');
- c.errInvalid=\'"Une option" field is invalid\';
- jFormsJQ.tForm.addControl(c);
- ', self::$mysharedfixture->builder->getJsContent());
- $ctrl->defaultValue='1';
- self::$mysharedfixture->form->removeControl($ctrl->ref);
- self::$mysharedfixture->form->addControl($ctrl);
- ob_start();self::$mysharedfixture->builder->outputControl($ctrl);$out = ob_get_clean();
- $this->assertEqualOrDiff('<input type="checkbox" name="chk2" id="'.self::$mysharedfixture->formname.'_chk2" checked="checked" value="1"/>', $out);
- $this->assertEqualOrDiff('c = new jFormsJQControlBoolean(\'chk2\', \'Une option\');
- c.errInvalid=\'"Une option" field is invalid\';
- jFormsJQ.tForm.addControl(c);
- ', self::$mysharedfixture->builder->getJsContent());
- self::$mysharedfixture->form->setData('chk2', '0');
- ob_start();self::$mysharedfixture->builder->outputControl($ctrl);$out = ob_get_clean();
- $this->assertEqualOrDiff('<input type="checkbox" name="chk2" id="'.self::$mysharedfixture->formname.'_chk2" value="1"/>', $out);
- $this->assertEqualOrDiff('c = new jFormsJQControlBoolean(\'chk2\', \'Une option\');
- c.errInvalid=\'"Une option" field is invalid\';
- jFormsJQ.tForm.addControl(c);
- ', self::$mysharedfixture->builder->getJsContent());
- $ctrl->setReadOnly(true);
- ob_start();self::$mysharedfixture->builder->outputControl($ctrl);$out = ob_get_clean();
- $this->assertEqualOrDiff('<input type="checkbox" name="chk2" id="'.self::$mysharedfixture->formname.'_chk2" readonly="readonly" class=" jforms-readonly" value="1"/>', $out);
- $this->assertEqualOrDiff('c = new jFormsJQControlBoolean(\'chk2\', \'Une option\');
- c.errInvalid=\'"Une option" field is invalid\';
- jFormsJQ.tForm.addControl(c);
- ', self::$mysharedfixture->builder->getJsContent());
- self::$mysharedfixture->form->setData('chk2', '1');
- ob_start();self::$mysharedfixture->builder->outputControl($ctrl);$out = ob_get_clean();
- $this->assertEqualOrDiff('<input type="checkbox" name="chk2" id="'.self::$mysharedfixture->formname.'_chk2" readonly="readonly" class=" jforms-readonly" checked="checked" value="1"/>', $out);
- $this->assertEqualOrDiff('c = new jFormsJQControlBoolean(\'chk2\', \'Une option\');
- c.errInvalid=\'"Une option" field is invalid\';
- jFormsJQ.tForm.addControl(c);
- ', self::$mysharedfixture->builder->getJsContent());
- $ctrl->hint='ceci est un tooltip';
- ob_start();self::$mysharedfixture->builder->outputControlLabel($ctrl);$out = ob_get_clean();
- $this->assertEqualOrDiff('<label class="jforms-label" for="'.self::$mysharedfixture->formname.'_chk2" title="ceci est un tooltip">Une option</label>', $out);
- ob_start();self::$mysharedfixture->builder->outputControl($ctrl);$out = ob_get_clean();
- $this->assertEqualOrDiff('<input type="checkbox" name="chk2" id="'.self::$mysharedfixture->formname.'_chk2" readonly="readonly" title="ceci est un tooltip" class=" jforms-readonly" checked="checked" value="1"/>', $out);
- $this->assertEqualOrDiff('c = new jFormsJQControlBoolean(\'chk2\', \'Une option\');
- c.errInvalid=\'"Une option" field is invalid\';
- jFormsJQ.tForm.addControl(c);
- ', self::$mysharedfixture->builder->getJsContent());
- }
- function testOutputCheckboxes(){
- $ctrl= new jFormsControlcheckboxes('choixsimple');
- $ctrl->datatype= new jDatatypeString();
- $ctrl->label='Vos choix';
- $ctrl->datasource = new jFormsDaoDatasource('jelix_tests~products','findAll','name','id');
- self::$mysharedfixture->form->addControl($ctrl);
- $records = array(
- array('id'=>'10', 'name'=>'foo', 'price'=>'12'),
- array('id'=>'11', 'name'=>'bar', 'price'=>'54'),
- array('id'=>'23', 'name'=>'baz', 'price'=>'97'),
- );
- $this->insertRecordsIntoTable('product_test', array('id','name','price'), $records, true);
- ob_start();self::$mysharedfixture->builder->outputControlLabel($ctrl);$out = ob_get_clean();
- $this->assertEqualOrDiff('<span class="jforms-label">Vos choix</span>', $out);
- ob_start();self::$mysharedfixture->builder->outputControl($ctrl);$out = ob_get_clean();
- $result='<span class="jforms-chkbox jforms-ctl-choixsimple"><input type="checkbox" name="choixsimple[]" id="'.self::$mysharedfixture->formname.'_choixsimple_0" value="10"/><label for="'.self::$mysharedfixture->formname.'_choixsimple_0">foo</label></span>';
- $result.='<span class="jforms-chkbox jforms-ctl-choixsimple"><input type="checkbox" name="choixsimple[]" id="'.self::$mysharedfixture->formname.'_choixsimple_1" value="11"/><label for="'.self::$mysharedfixture->formname.'_choixsimple_1">bar</label></span>';
- $result.='<span class="jforms-chkbox jforms-ctl-choixsimple"><input type="checkbox" name="choixsimple[]" id="'.self::$mysharedfixture->formname.'_choixsimple_2" value="23"/><label for="'.self::$mysharedfixture->formname.'_choixsimple_2">baz</label></span>';
- $this->assertEqualOrDiff($result, $out);
- $this->assertEqualOrDiff('c = new jFormsJQControlString(\'choixsimple[]\', \'Vos choix\');
- c.errInvalid=\'"Vos choix" field is invalid\';
- jFormsJQ.tForm.addControl(c);
- ', self::$mysharedfixture->builder->getJsContent());
- self::$mysharedfixture->form->setData('choixsimple',11);
- ob_start();self::$mysharedfixture->builder->outputControl($ctrl);$out = ob_get_clean();
- $result='<span class="jforms-chkbox jforms-ctl-choixsimple"><input type="checkbox" name="choixsimple[]" id="'.self::$mysharedfixture->formname.'_choixsimple_0" value="10"/><label for="'.self::$mysharedfixture->formname.'_choixsimple_0">foo</label></span>';
- $result.='<span class="jforms-chkbox jforms-ctl-choixsimple"><input type="checkbox" name="choixsimple[]" id="'.self::$mysharedfixture->formname.'_choixsimple_1" value="11" checked="checked"/><label for="'.self::$mysharedfixture->formname.'_choixsimple_1">bar</label></span>';
- $result.='<span class="jforms-chkbox jforms-ctl-choixsimple"><input type="checkbox" name="choixsimple[]" id="'.self::$mysharedfixture->formname.'_choixsimple_2" value="23"/><label for="'.self::$mysharedfixture->formname.'_choixsimple_2">baz</label></span>';
- $this->assertEqualOrDiff($result, $out);
- $this->assertEqualOrDiff('c = new jFormsJQControlString(\'choixsimple[]\', \'Vos choix\');
- c.errInvalid=\'"Vos choix" field is invalid\';
- jFormsJQ.tForm.addControl(c);
- ', self::$mysharedfixture->builder->getJsContent());
- $ctrl= new jFormsControlcheckboxes('choixmultiple');
- $ctrl->datatype= new jDatatypeString();
- $ctrl->label='Vos choix';
- $ctrl->datasource= new jFormsStaticDatasource();
- $ctrl->datasource->data = array(
- '10'=>'foo',
- '11'=>'bar',
- '23'=>'baz',
- );
- self::$mysharedfixture->form->addControl($ctrl);
- ob_start();self::$mysharedfixture->builder->outputControlLabel($ctrl);$out = ob_get_clean();
- $this->assertEqualOrDiff('<span class="jforms-label">Vos choix</span>', $out);
- ob_start();self::$mysharedfixture->builder->outputControl($ctrl);$out = ob_get_clean();
- $result='<span class="jforms-chkbox jforms-ctl-choixmultiple"><input type="checkbox" name="choixmultiple[]" id="'.self::$mysharedfixture->formname.'_choixmultiple_0" value="10"/><label for="'.self::$mysharedfixture->formname.'_choixmultiple_0">foo</label></span>';
- $result.='<span class="jforms-chkbox jforms-ctl-choixmultiple"><input type="checkbox" name="choixmultiple[]" id="'.self::$mysharedfixture->formname.'_choixmultiple_1" value="11"/><label for="'.self::$mysharedfixture->formname.'_choixmultiple_1">bar</label></span>';
- $result.='<span class="jforms-chkbox jforms-ctl-choixmultiple"><input type="checkbox" name="choixmultiple[]" id="'.self::$mysharedfixture->formname.'_choixmultiple_2" value="23"/><label for="'.self::$mysharedfixture->formname.'_choixmultiple_2">baz</label></span>';
- $this->assertEqualOrDiff($result, $out);
- $this->assertEqualOrDiff('c = new jFormsJQControlString(\'choixmultiple[]\', \'Vos choix\');
- c.errInvalid=\'"Vos choix" field is invalid\';
- jFormsJQ.tForm.addControl(c);
- ', self::$mysharedfixture->builder->getJsContent());
- self::$mysharedfixture->form->setData('choixmultiple',11);
- ob_start();self::$mysharedfixture->builder->outputControl($ctrl);$out = ob_get_clean();
- $result='<span class="jforms-chkbox jforms-ctl-choixmultiple"><input type="checkbox" name="choixmultiple[]" id="'.self::$mysharedfixture->formname.'_choixmultiple_0" value="10"/><label for="'.self::$mysharedfixture->formname.'_choixmultiple_0">foo</label></span>';
- $result.='<span class="jforms-chkbox jforms-ctl-choixmultiple"><input type="checkbox" name="choixmultiple[]" id="'.self::$mysharedfixture->formname.'_choixmultiple_1" value="11" checked="checked"/><label for="'.self::$mysharedfixture->formname.'_choixmultiple_1">bar</label></span>';
- $result.='<span class="jforms-chkbox jforms-ctl-choixmultiple"><input type="checkbox" name="choixmultiple[]" id="'.self::$mysharedfixture->formname.'_choixmultiple_2" value="23"/><label for="'.self::$mysharedfixture->formname.'_choixmultiple_2">baz</label></span>';
- $this->assertEqualOrDiff($result, $out);
- $this->assertEqualOrDiff('c = new jFormsJQControlString(\'choixmultiple[]\', \'Vos choix\');
- c.errInvalid=\'"Vos choix" field is invalid\';
- jFormsJQ.tForm.addControl(c);
- ', self::$mysharedfixture->builder->getJsContent());
- self::$mysharedfixture->form->setData('choixmultiple',array(10,23));
- ob_start();self::$mysharedfixture->builder->outputControl($ctrl);$out = ob_get_clean();
- $result='<span class="jforms-chkbox jforms-ctl-choixmultiple"><input type="checkbox" name="choixmultiple[]" id="'.self::$mysharedfixture->formname.'_choixmultiple_0" value="10" checked="checked"/><label for="'.self::$mysharedfixture->formname.'_choixmultiple_0">foo</label></span>';
- $result.='<span class="jforms-chkbox jforms-ctl-choixmultiple"><input type="checkbox" name="choixmultiple[]" id="'.self::$mysharedfixture->formname.'_choixmultiple_1" value="11"/><label for="'.self::$mysharedfixture->formname.'_choixmultiple_1">bar</label></span>';
- $result.='<span class="jforms-chkbox jforms-ctl-choixmultiple"><input type="checkbox" name="choixmultiple[]" id="'.self::$mysharedfixture->formname.'_choixmultiple_2" value="23" checked="checked"/><label for="'.self::$mysharedfixture->formname.'_choixmultiple_2">baz</label></span>';
- $this->assertEqualOrDiff($result, $out);
- $this->assertEqualOrDiff('c = new jFormsJQControlString(\'choixmultiple[]\', \'Vos choix\');
- c.errInvalid=\'"Vos choix" field is invalid\';
- jFormsJQ.tForm.addControl(c);
- ', self::$mysharedfixture->builder->getJsContent());
- $ctrl->setReadOnly(true);
- $ctrl->hint='ceci est un tooltip';
- ob_start();self::$mysharedfixture->builder->outputControlLabel($ctrl);$out = ob_get_clean();
- $this->assertEqualOrDiff('<span class="jforms-label" title="ceci est un tooltip">Vos choix</span>', $out);
- ob_start();self::$mysharedfixture->builder->outputControl($ctrl);$out = ob_get_clean();
- $result='<span class="jforms-chkbox jforms-ctl-choixmultiple"><input type="checkbox" name="choixmultiple[]" id="'.self::$mysharedfixture->formname.'_choixmultiple_0" value="10" checked="checked" readonly="readonly" class=" jforms-readonly"/><label for="'.self::$mysharedfixture->formname.'_choixmultiple_0">foo</label></span>';
- $result.='<span class="jforms-chkbox jforms-ctl-choixmultiple"><input type="checkbox" name="choixmultiple[]" id="'.self::$mysharedfixture->formname.'_choixmultiple_1" value="11" readonly="readonly" class=" jforms-readonly"/><label for="'.self::$mysharedfixture->formname.'_choixmultiple_1">bar</label></span>';
- $result.='<span class="jforms-chkbox jforms-ctl-choixmultiple"><input type="checkbox" name="choixmultiple[]" id="'.self::$mysharedfixture->formname.'_choixmultiple_2" value="23" checked="checked" readonly="readonly" class=" jforms-readonly"/><label for="'.self::$mysharedfixture->formname.'_choixmultiple_2">baz</label></span>';
- $this->assertEqualOrDiff($result, $out);
- $this->assertEqualOrDiff('c = new jFormsJQControlString(\'choixmultiple[]\', \'Vos choix\');
- c.errInvalid=\'"Vos choix" field is invalid\';
- jFormsJQ.tForm.addControl(c);
- ', self::$mysharedfixture->builder->getJsContent());
- }
- function testOutputRadiobuttons(){
- $ctrl= new jFormsControlradiobuttons('rbchoixsimple');
- $ctrl->datatype= new jDatatypeString();
- $ctrl->label='Votre choix';
- $ctrl->datasource = new jFormsDaoDatasource('jelix_tests~products','findAll','name','id');
- self::$mysharedfixture->form->addControl($ctrl);
- ob_start();self::$mysharedfixture->builder->outputControlLabel($ctrl);$out = ob_get_clean();
- $this->assertEqualOrDiff('<span class="jforms-label">Votre choix</span>', $out);
- ob_start();self::$mysharedfixture->builder->outputControl($ctrl);$out = ob_get_clean();
- $result='<span class="jforms-radio jforms-ctl-rbchoixsimple"><input type="radio" name="rbchoixsimple" id="'.self::$mysharedfixture->formname.'_rbchoixsimple_0" value="10"/><label for="'.self::$mysharedfixture->formname.'_rbchoixsimple_0">foo</label></span>';
- $result.='<span class="jforms-radio jforms-ctl-rbchoixsimple"><input type="radio" name="rbchoixsimple" id="'.self::$mysharedfixture->formname.'_rbchoixsimple_1" value="11"/><label for="'.self::$mysharedfixture->formname.'_rbchoixsimple_1">bar</label></span>';
- $result.='<span class="jforms-radio jforms-ctl-rbchoixsimple"><input type="radio" name="rbchoixsimple" id="'.self::$mysharedfixture->formname.'_rbchoixsimple_2" value="23"/><label for="'.self::$mysharedfixture->formname.'_rbchoixsimple_2">baz</label></span>';
- $this->assertEqualOrDiff($result, $out);
- $this->assertEqualOrDiff('c = new jFormsJQControlString(\'rbchoixsimple\', \'Votre choix\');
- c.errInvalid=\'"Votre choix" field is invalid\';
- jFormsJQ.tForm.addControl(c);
- ', self::$mysharedfixture->builder->getJsContent());
- self::$mysharedfixture->form->setData('rbchoixsimple',11);
- ob_start();self::$mysharedfixture->builder->outputControl($ctrl);$out = ob_get_clean();
- $result='<span class="jforms-radio jforms-ctl-rbchoixsimple"><input type="radio" name="rbchoixsimple" id="'.self::$mysharedfixture->formname.'_rbchoixsimple_0" value="10"/><label for="'.self::$mysharedfixture->formname.'_rbchoixsimple_0">foo</label></span>';
- $result.='<span class="jforms-radio jforms-ctl-rbchoixsimple"><input type="radio" name="rbchoixsimple" id="'.self::$mysharedfixture->formname.'_rbchoixsimple_1" value="11" checked="checked"/><label for="'.self::$mysharedfixture->formname.'_rbchoixsimple_1">bar</label></span>';
- $result.='<span class="jforms-radio jforms-ctl-rbchoixsimple"><input type="radio" name="rbchoixsimple" id="'.self::$mysharedfixture->formname.'_rbchoixsimple_2" value="23"/><label for="'.self::$mysharedfixture->formname.'_rbchoixsimple_2">baz</label></span>';
- $this->assertEqualOrDiff($result, $out);
- $this->assertEqualOrDiff('c = new jFormsJQControlString(\'rbchoixsimple\', \'Votre choix\');
- c.errInvalid=\'"Votre choix" field is invalid\';
- jFormsJQ.tForm.addControl(c);
- ', self::$mysharedfixture->builder->getJsContent());
- $ctrl->datasource= new jFormsStaticDatasource();
- $ctrl->datasource->data = array(
- '10'=>'foo',
- '11'=>'bar',
- '23'=>'baz',
- );
- ob_start();self::$mysharedfixture->builder->outputControl($ctrl);$out = ob_get_clean();
- $result='<span class="jforms-radio jforms-ctl-rbchoixsimple"><input type="radio" name="rbchoixsimple" id="'.self::$mysharedfixture->formname.'_rbchoixsimple_0" value="10"/><label for="'.self::$mysharedfixture->formname.'_rbchoixsimple_0">foo</label></span>';
- $result.='<span class="jforms-radio jforms-ctl-rbchoixsimple"><input type="radio" name="rbchoixsimple" id="'.self::$mysharedfixture->formname.'_rbchoixsimple_1" value="11" checked="checked"/><label for="'.self::$mysharedfixture->formname.'_rbchoixsimple_1">bar</label></span>';
- $result.='<span class="jforms-radio jforms-ctl-rbchoixsimple"><input type="radio" name="rbchoixsimple" id="'.self::$mysharedfixture->formname.'_rbchoixsimple_2" value="23"/><label for="'.self::$mysharedfixture->formname.'_rbchoixsimple_2">baz</label></span>';
- $this->assertEqualOrDiff($result, $out);
- $this->assertEqualOrDiff('c = new jFormsJQControlString(\'rbchoixsimple\', \'Votre choix\');
- c.errInvalid=\'"Votre choix" field is invalid\';
- jFormsJQ.tForm.addControl(c);
- ', self::$mysharedfixture->builder->getJsContent());
- self::$mysharedfixture->form->setData('rbchoixsimple',23);
- ob_start();self::$mysharedfixture->builder->outputControl($ctrl);$out = ob_get_clean();
- $result='<span class="jforms-radio jforms-ctl-rbchoixsimple"><input type="radio" name="rbchoixsimple" id="'.self::$mysharedfixture->formname.'_rbchoixsimple_0" value="10"/><label for="'.self::$mysharedfixture->formname.'_rbchoixsimple_0">foo</label></span>';
- $result.='<span class="jforms-radio jforms-ctl-rbchoixsimple"><input type="radio" name="rbchoixsimple" id="'.self::$mysharedfixture->formname.'_rbchoixsimple_1" value="11"/><label for="'.self::$mysharedfixture->formname.'_rbchoixsimple_1">bar</label></span>';
- $result.='<span class="jforms-radio jforms-ctl-rbchoixsimple"><input type="radio" name="rbchoixsimple" id="'.self::$mysharedfixture->formname.'_rbchoixsimple_2" value="23" checked="checked"/><label for="'.self::$mysharedfixture->formname.'_rbchoixsimple_2">baz</label></span>';
- $this->assertEqualOrDiff($result, $out);
- $this->assertEqualOrDiff('c = new jFormsJQControlString(\'rbchoixsimple\', \'Votre choix\');
- c.errInvalid=\'"Votre choix" field is invalid\';
- jFormsJQ.tForm.addControl(c);
- ', self::$mysharedfixture->builder->getJsContent());
- $ctrl->setReadOnly(true);
- $ctrl->hint='ceci est un tooltip';
- ob_start();self::$mysharedfixture->builder->outputControlLabel($ctrl);$out = ob_get_clean();
- $this->assertEqualOrDiff('<span class="jforms-label" title="ceci est un tooltip">Votre choix</span>', $out);
- ob_start();self::$mysharedfixture->builder->outputControl($ctrl);$out = ob_get_clean();
- $result='<span class="jforms-radio jforms-ctl-rbchoixsimple"><input type="radio" name="rbchoixsimple" id="'.self::$mysharedfixture->formname.'_rbchoixsimple_0" value="10" readonly="readonly" class=" jforms-readonly"/><label for="'.self::$mysharedfixture->formname.'_rbchoixsimple_0">foo</label></span>';
- $result.='<span class="jforms-radio jforms-ctl-rbchoixsimple"><input type="radio" name="rbchoixsimple" id="'.self::$mysharedfixture->formname.'_rbchoixsimple_1" value="11" readonly="readonly" class=" jforms-readonly"/><label for="'.self::$mysharedfixture->formname.'_rbchoixsimple_1">bar</label></span>';
- $result.='<span class="jforms-radio jforms-ctl-rbchoixsimple"><input type="radio" name="rbchoixsimple" id="'.self::$mysharedfixture->formname.'_rbchoixsimple_2" value="23" checked="checked" readonly="readonly" class=" jforms-readonly"/><label for="'.self::$mysharedfixture->formname.'_rbchoixsimple_2">baz</label></span>';
- $this->assertEqualOrDiff($result, $out);
- $this->assertEqualOrDiff('c = new jFormsJQControlString(\'rbchoixsimple\', \'Votre choix\');
- c.errInvalid=\'"Votre choix" field is invalid\';
- jFormsJQ.tForm.addControl(c);
- ', self::$mysharedfixture->builder->getJsContent());
- self::$mysharedfixture->builder->clearJs();
- $ctrl->datasource = new jFormsStaticDatasource();
- $ctrl->datasource->data = array('1'=>'Yes','0'=>'No');
- self::$mysharedfixture->form->setReadOnly('rbchoixsimple',false);
- self::$mysharedfixture->form->setData('rbchoixsimple',null);
- ob_start();self::$mysharedfixture->builder->outputControl($ctrl);$out = ob_get_clean();
- $result='<span class="jforms-radio jforms-ctl-rbchoixsimple"><input type="radio" name="rbchoixsimple" id="'.self::$mysharedfixture->formname.'_rbchoixsimple_0" value="1"/><label for="'.self::$mysharedfixture->formname.'_rbchoixsimple_0">Yes</label></span>';
- $result.='<span class="jforms-radio jforms-ctl-rbchoixsimple"><input type="radio" name="rbchoixsimple" id="'.self::$mysharedfixture->formname.'_rbchoixsimple_1" value="0"/><label for="'.self::$mysharedfixture->formname.'_rbchoixsimple_1">No</label></span>';
- $this->assertEqualOrDiff($result, $out);
- self::$mysharedfixture->form->setData('rbchoixsimple',0);
- ob_start();self::$mysharedfixture->builder->outputControl($ctrl);$out = ob_get_clean();
- $result='<span class="jforms-radio jforms-ctl-rbchoixsimple"><input type="radio" name="rbchoixsimple" id="'.self::$mysharedfixture->formname.'_rbchoixsimple_0" value="1"/><label for="'.self::$mysharedfixture->formname.'_rbchoixsimple_0">Yes</label></span>';
- $result.='<span class="jforms-radio jforms-ctl-rbchoixsimple"><input type="radio" name="rbchoixsimple" id="'.self::$mysharedfixture->formname.'_rbchoixsimple_1" value="0" checked="checked"/><label for="'.self::$mysharedfixture->formname.'_rbchoixsimple_1">No</label></span>';
- $this->assertEqualOrDiff($result, $out);
- self::$mysharedfixture->builder->clearJs();
- }
- function testOutputMenulist(){
- $ctrl= new jFormsControlmenulist('menulist1');
- $ctrl->datatype= new jDatatypeString();
- $ctrl->label='Votre choix';
- $ctrl->datasource = new jFormsDaoDatasource('jelix_tests~products','findAll','name','id');
- self::$mysharedfixture->form->addControl($ctrl);
- ob_start();self::$mysharedfixture->builder->outputControlLabel($ctrl);$out = ob_get_clean();
- $this->assertEqualOrDiff('<label class="jforms-label" for="'.self::$mysharedfixture->formname.'_menulist1">Votre choix</label>', $out);
- ob_start();self::$mysharedfixture->builder->outputControl($ctrl);$out = ob_get_clean();
- $result='<select name="menulist1" id="'.self::$mysharedfixture->formname.'_menulist1" size="1">';
- $result.='<option value="" selected="selected"></option>';
- $result.='<option value="10">foo</option>';
- $result.='<option value="11">bar</option>';
- $result.='<option value="23">baz</option>';
- $result.='</select>';
- $this->assertEqualOrDiff($result, $out);
- $this->assertEqualOrDiff('c = new jFormsJQControlString(\'menulist1\', \'Votre choix\');
- c.errInvalid=\'"Votre choix" field is invalid\';
- jFormsJQ.tForm.addControl(c);
- ', self::$mysharedfixture->builder->getJsContent());
- self::$mysharedfixture->form->setData('menulist1',11);
- ob_start();self::$mysharedfixture->builder->outputControl($ctrl);$out = ob_get_clean();
- $result='<select name="menulist1" id="'.self::$mysharedfixture->formname.'_menulist1" size="1">';
- $result.='<option value=""></option>';
- $result.='<option value="10">foo</option>';
- $result.='<option value="11" selected="selected">bar</option>';
- $result.='<option value="23">baz</option>';
- $result.='</select>';
- $this->assertEqualOrDiff($result, $out);
- $this->assertEqualOrDiff('c = new jFormsJQControlString(\'menulist1\', \'Votre choix\');
- c.errInvalid=\'"Votre choix" field is invalid\';
- jFormsJQ.tForm.addControl(c);
- ', self::$mysharedfixture->builder->getJsContent());
- $ctrl->datasource= new jFormsStaticDatasource();
- $ctrl->datasource->data = array(
- '10'=>'foo',
- '11'=>'bar',
- '23'=>'baz',
- );
- ob_start();self::$mysharedfixture->builder->outputControl($ctrl);$out = ob_get_clean();
- $this->assertEqualOrDiff($result, $out);
- $this->assertEqualOrDiff('c = new jFormsJQControlString(\'menulist1\', \'Votre choix\');
- c.errInvalid=\'"Votre choix" field is invalid\';
- jFormsJQ.tForm.addControl(c);
- ', self::$mysharedfixture->builder->getJsContent());
- $ctrl->setReadOnly(true);
- $ctrl->hint='ceci est un tooltip';
- ob_start();self::$mysharedfixture->builder->outputControlLabel($ctrl);$out = ob_get_clean();
- $this->assertEqualOrDiff('<label class="jforms-label" for="'.self::$mysharedfixture->formname.'_menulist1" title="ceci est un tooltip">Votre choix</label>', $out);
- ob_start();self::$mysharedfixture->builder->outputControl($ctrl);$out = ob_get_clean();
- $result='<select name="menulist1" id="'.self::$mysharedfixture->formname.'_menulist1" title="ceci est un tooltip" class=" jforms-readonly" size="1">';
- $result.='<option value=""></option>';
- $result.='<option value="10">foo</option>';
- $result.='<option value="11" selected="selected">bar</option>';
- $result.='<option value="23">baz</option>';
- $result.='</select>';
- $this->assertEqualOrDiff($result, $out);
- $this->assertEqualOrDiff('c = new jFormsJQControlString(\'menulist1\', \'Votre choix\');
- c.errInvalid=\'"Votre choix" field is invalid\';
- jFormsJQ.tForm.addControl(c);
- ', self::$mysharedfixture->builder->getJsContent());
- $ctrl->required = true;
- self::$mysharedfixture->form->setData('menulist1',"23");
- ob_start();self::$mysharedfixture->builder->outputControl($ctrl);$out = ob_get_clean();
- $result='<select name="menulist1" id="'.self::$mysharedfixture->formname.'_menulist1" title="ceci est un tooltip" class=" jforms-readonly" size="1">';
- $result.='<option value="10">foo</option>';
- $result.='<option value="11">bar</option>';
- $result.='<option value="23" selected="selected">baz</option>';
- $result.='</select>';
- $this->assertEqualOrDiff($result, $out);
- $this->assertEqualOrDiff('c = new jFormsJQControlString(\'menulist1\', \'Votre choix\');
- c.required = true;
- c.errRequired=\'"Votre choix" field is required\';
- c.errInvalid=\'"Votre choix" field is invalid\';
- jFormsJQ.tForm.addControl(c);
- ', self::$mysharedfixture->builder->getJsContent());
- $ctrl->required = false;
- self::$mysharedfixture->form->setData('menulist1',"");
- ob_start();self::$mysharedfixture->builder->outputControl($ctrl);$out = ob_get_clean();
- $result='<select name="menulist1" id="'.self::$mysharedfixture->formname.'_menulist1" title="ceci est un tooltip" class=" jforms-readonly" size="1">';
- $result.='<option value="" selected="selected"></option>';
- $result.='<option value="10">foo</option>';
- $result.='<option value="11">bar</option>';
- $result.='<option value="23">baz</option>';
- $result.='</select>';
- $this->assertEqualOrDiff($result, $out);
- $this->assertEqualOrDiff('c = new jFormsJQControlString(\'menulist1\', \'Votre choix\');
- c.errInvalid=\'"Votre choix" field is invalid\';
- jFormsJQ.tForm.addControl(c);
- ', self::$mysharedfixture->builder->getJsContent());
- $ctrl->setReadOnly(false);
- $ctrl->hint='';
- $ctrl->datasource = new jFormsDaoDatasource('jelix_tests~products','findByMaxId','name','id','','15');
- ob_start();self::$mysharedfixture->builder->outputControl($ctrl);$out = ob_get_clean();
- $result='<select name="menulist1" id="'.self::$mysharedfixture->formname.'_menulist1" size="1">';
- $result.='<option value="" selected="selected"></option>';
- $result.='<option value="10">foo</option>';
- $result.='<option value="11">bar</option>';
- $result.='</select>';
- $this->assertEqualOrDiff($result, $out);
- $this->assertEqualOrDiff('c = new jFormsJQControlString(\'menulist1\', \'Votre choix\');
- c.errInvalid=\'"Votre choix" field is invalid\';
- jFormsJQ.tForm.addControl(c);
- ', self::$mysharedfixture->builder->getJsContent());
- $ctrl->datasource = new jFormsDaoDatasource('jelix_tests~products','findByMaxId','name','id','','11');
- ob_start();self::$mysharedfixture->builder->outputControl($ctrl);$out = ob_get_clean();
- $result='<select name="menulist1" id="'.self::$mysharedfixture->formname.'_menulist1" size="1">';
- $result.='<option value="" selected="selected"></option>';
- $result.='<option value="10">foo</option>';
- $result.='</select>';
- $this->assertEqualOrDiff($result, $out);
- $this->assertEqualOrDiff('c = new jFormsJQControlString(\'menulist1\', \'Votre choix\');
- c.errInvalid=\'"Votre choix" field is invalid\';
- jFormsJQ.tForm.addControl(c);
- ', self::$mysharedfixture->builder->getJsContent());
- self::$mysharedfixture->form->setData('menulist1',"10");
- ob_start();self::$mysharedfixture->builder->outputControl($ctrl);$out = ob_get_clean();
- $result='<select name="menulist1" id="'.self::$mysharedfixture->formname.'_menulist1" size="1">';
- $result.='<option value=""></option>';
- $result.='<option value="10" selected="selected">foo</option>';
- $result.='</select>';
- $this->assertEqualOrDiff($result, $out);
- $this->assertEqualOrDiff('c = new jFormsJQControlString(\'menulist1\', \'Votre choix\');
- c.errInvalid=\'"Votre choix" field is invalid\';
- jFormsJQ.tForm.addControl(c);
- ', self::$mysharedfixture->builder->getJsContent());
- self::$mysharedfixture->form->setData('menulist1',"");
- self::$mysharedfixture->form->addControl(new jFormsControlHidden('hidden1'));
- self::$mysharedfixture->form->setData('hidden1',"25");
- $ctrl->datasource = new jFormsDaoDatasource('jelix_tests~products','findByMaxId','name','id','',null, 'hidden1');
- ob_start();self::$mysharedfixture->builder->outputControl($ctrl);$out = ob_get_clean();
- $result='<select name="menulist1" id="'.self::$mysharedfixture->formname.'_menulist1" size="1">';
- $result.='<option value="" selected="selected"></option>';
- $result.='<option value="10">foo</option>';
- $result.='<option value="11">bar</option>';
- $result.='<option value="23">baz</option>';
- $result.='</select>';
- $this->assertEqualOrDiff($result, $out);
- $this->assertEqualOrDiff('c = new jFormsJQControlString(\'menulist1\', \'Votre choix\');
- c.errInvalid=\'"Votre choix" field is invalid\';
- jFormsJQ.tForm.addControl(c);
- ', self::$mysharedfixture->builder->getJsContent());
- self::$mysharedfixture->form->setData('hidden1',"15");
- ob_start();self::$mysharedfixture->builder->outputControl($ctrl);$out = ob_get_clean();
- $result='<select name="menulist1" id="'.self::$mysharedfixture->formname.'_menulist1" size="1">';
- $result.='<option value="" selected="selected"></option>';
- $result.='<option value="10">foo</option>';
- $result.='<option value="11">bar</option>';
- $result.='</select>';
- $this->assertEqualOrDiff($result, $out);
- self::$mysharedfixture->form->setData('menulist1',"10");
- self::$mysharedfixture->form->setData('hidden1',"11");
- ob_start();self::$mysharedfixture->builder->outputControl($ctrl);$out = ob_get_clean();
- $result='<select name="menulist1" id="'.self::$mysharedfixture->formname.'_menulist1" size="1">';
- $result.='<option value=""></option>';
- $result.='<option value="10" selected="selected">foo</option>';
- $result.='</select>';
- $this->assertEqualOrDiff($result, $out);
- self::$mysharedfixture->form->setData('menulist1',"");
- $ctrl->datasource = new jFormsDaoDatasource('jelix_tests~products','findByMaxId','name,price','id','','25',null);
- ob_start();self::$mysharedfixture->builder->outputControl($ctrl);$out = ob_get_clean();
- $result='<select name="menulist1" id="'.self::$mysharedfixture->formname.'_menulist1" size="1">';
- $result.='<option value="" selected="selected"></option>';
- $result.='<option value="10">foo12</option>';
- $result.='<option value="11">bar54</option>';
- $result.='<option value="23">baz97</option>';
- $result.='</select>';
- $this->assertEqualOrDiff($result, $out);
- $ctrl->datasource = new jFormsDaoDatasource('jelix_tests~products','findByMaxId','name,price','id','','25',null,' - ');
- ob_start();self::$mysharedfixture->builder->outputControl($ctrl);$out = ob_get_clean();
- $result='<select name="menulist1" id="'.self::$mysharedfixture->formname.'_menulist1" size="1">';
- $result.='<option value="" selected="selected"></option>';
- $result.='<option value="10">foo - 12</option>';
- $result.='<option value="11">bar - 54</option>';
- $result.='<option value="23">baz - 97</option>';
- $result.='</select>';
- $this->assertEqualOrDiff($result, $out);
- $ctrl->datasource = new jFormsDaoDatasource('jelix_tests~products','findBetweenId','name,price','id','','9,25',null,' - ');
- ob_start();self::$mysharedfixture->builder->outputControl($ctrl);$out = ob_get_clean();
- $result='<select name="menulist1" id="'.self::$mysharedfixture->formname.'_menulist1" size="1">';
- $result.='<option value="" selected="selected"></option>';
- $result.='<option value="10">foo - 12</option>';
- $result.='<option value="11">bar - 54</option>';
- $result.='<option value="23">baz - 97</option>';
- $result.='</select>';
- $this->assertEqualOrDiff($result, $out);
- $ctrl->datasource = new jFormsDaoDatasource('jelix_tests~products','findBetweenId','name,price','id','','10,25',null,' - ');
- ob_start();self::$mysharedfixture->builder->outputControl($ctrl);$out = ob_get_clean();
- $result='<select name="menulist1" id="'.self::$mysharedfixture->formname.'_menulist1" size="1">';
- $result.='<option value="" selected="selected"></option>';
- $result.='<option value="11">bar - 54</option>';
- $result.='<option value="23">baz - 97</option>';
- $result.='</select>';
- $this->assertEqualOrDiff($result, $out);
- self::$mysharedfixture->form->addControl(new jFormsControlHidden('hidden2'));
- self::$mysharedfixture->form->setData('hidden1',"9");
- self::$mysharedfixture->form->setData('hidden2',"25");
- $ctrl->datasource = new jFormsDaoDatasource('jelix_tests~products','findBetweenId','name,price','id','',null,'hidden1,hidden2',' - ');
- ob_start();self::$mysharedfixture->builder->outputControl($ctrl);$out = ob_get_clean();
- $result='<select name="menulist1" id="'.self::$mysharedfixture->formname.'_menulist1" size="1">';
- $result.='<option value="" selected="selected"></option>';
- $result.='<option value="10">foo - 12</option>';
- $result.='<option value="11">bar - 54</option>';
- $result.='<option value="23">baz - 97</option>';
- $result.='</select>';
- $this->assertEqualOrDiff($result, $out);
- self::$mysharedfixture->form->setData('hidden1',"10");
- self::$mysharedfixture->form->setData('hidden2',"25");
- $ctrl->datasource = new jFormsDaoDatasource('jelix_tests~products','findBetweenId','name,price','id','',null,'hidden1,hidden2',' - ');
- ob_start();self::$mysharedfixture->builder->outputControl($ctrl);$out = ob_get_clean();
- $result='<select name="menulist1" id="'.self::$mysharedfixture->formname.'_menulist1" size="1">';
- $result.='<option value="" selected="selected"></option>';
- $result.='<option value="11">bar - 54</option>';
- $result.='<option value="23">baz - 97</option>';
- $result.='</select>';
- $this->assertEqualOrDiff($result, $out);
- self::$mysharedfixture->form->removeControl('hidden2');
- self::$mysharedfixture->form->setData('hidden1',"11");
- self::$mysharedfixture->builder->clearJs();
- }
- function testOutputListbox(){
- $ctrl= new jFormsControllistbox('listbox1');
- $ctrl->datatype= new jDatatypeString();
- $ctrl->label='Votre choix';
- $ctrl->datasource = new jFormsDaoDatasource('jelix_tests~products','findAll','name','id');
- self::$mysharedfixture->form->addControl($ctrl);
- ob_start();self::$mysharedfixture->builder->outputControlLabel($ctrl);$out = ob_get_clean();
- $this->assertEqualOrDiff('<label class="jforms-label" for="'.self::$mysharedfixture->formname.'_listbox1">Votre choix</label>', $out);
- ob_start();self::$mysharedfixture->builder->outputControl($ctrl);$out = ob_get_clean();
- $result='<select name="listbox1" id="'.self::$mysharedfixture->formname.'_listbox1" size="4">';
- $result.='<option value="10">foo</option>';
- $result.='<option value="11">bar</option>';
- $result.='<option value="23">baz</option>';
- $result.='</select>';
- $this->assertEqualOrDiff($result…
Large files files are truncated, but you can click here to view the full file