/** * Default values for checkboxes and multiselects were ignored when validating an unseen page * * Unlikely that this bug will resurface, but just in case. * * @see http://pear.php.net/bugs/bug.php?id=8687 */ public function testBug8687() { $mockForm = $this->getMock('HTML_QuickForm2', array('validate'), array('invalid')); $mockForm->expects($this->once())->method('validate')->will($this->returnValue(false)); $select = $mockForm->addElement('select', 'foo', array('multiple'))->loadOptions(array('one' => 'First label', 'two' => 'Second label')); $box = $mockForm->addElement('checkbox', 'bar'); $mockPage = $this->getMock('HTML_QuickForm2_Controller_Page', array('populateForm'), array($mockForm)); $controller = new HTML_QuickForm2_Controller('bug8687', false); $controller->addPage($mockPage); $controller->addDataSource(new HTML_QuickForm2_DataSource_Array(array('foo' => array('two'), 'bar' => '1'))); $this->assertFalse($controller->isValid()); $this->assertEquals(array('two'), $select->getValue()); $this->assertEquals('1', $box->getValue()); }