public function testBug11138() { $options = array('2' => 'TwoWithoutZero', '02' => 'TwoWithZero'); $sel = new HTML_QuickForm2_Element_Select('bug11138'); $sel->loadOptions($options); $sel->setValue('02'); $selHtml = $sel->__toString(); $this->assertRegExp('!selected="selected"[^>]*>TwoWithZero!', $selHtml); $this->assertNotRegExp('!selected="selected"[^>]*>TwoWithoutZero!', $selHtml); $sel->toggleFrozen(true); $selFrozen = $sel->__toString(); $this->assertContains('TwoWithZero', $selFrozen); $this->assertContains('value="02"', $selFrozen); $this->assertNotContains('TwoWithoutZero', $selFrozen); $this->assertNotContains('value="2"', $selFrozen); }
/** * Disable possibleValues checks in getValue() * * For lazy people who add options to selects on client side and do not * want to add the same stuff server-side * * @link http://pear.php.net/bugs/bug.php?id=13088 * @link http://pear.php.net/bugs/bug.php?id=16974 */ public function testDisableIntrinsicValidation() { $selectSingle = new HTML_QuickForm2_Element_Select('foo', null, array('intrinsic_validation' => false)); $selectSingle->setValue('foo'); $this->assertEquals('foo', $selectSingle->getValue()); $selectSingle->loadOptions(array('one' => 'First', 'two' => 'Second')); $selectSingle->setValue('three'); $this->assertEquals('three', $selectSingle->getValue()); $selectMultiple = new HTML_QuickForm2_Element_Select('bar', array('multiple'), array('intrinsic_validation' => false)); $selectMultiple->loadOptions(array('one' => 'First', 'two' => 'Second')); $selectMultiple->setValue(array('two', 'three')); $this->assertEquals(array('two', 'three'), $selectMultiple->getValue()); }