public function testGetValueBrackets() { $c = new HTML_QuickForm2_ContainerImpl('withBrackets'); $el1 = $c->appendChild(new HTML_QuickForm2_ElementImpl2('foo[]')); $el2 = $c->appendChild(new HTML_QuickForm2_ElementImpl2('foo[]')); $el1->setValue('first'); $el2->setValue('second'); $this->assertEquals(array('foo' => array('first', 'second')), $c->getValue()); }
public function testValidate() { $cValidate = new HTML_QuickForm2_ContainerImpl('validate'); $el1 = $cValidate->appendChild(new HTML_QuickForm2_ElementImpl2('foo')); $el2 = $cValidate->appendChild(new HTML_QuickForm2_ElementImpl2('bar')); $ruleTrue1 = $this->getMock('HTML_QuickForm2_Rule', array('checkValue'), array($cValidate, 'irrelevant message')); $ruleTrue1->expects($this->once())->method('checkValue')->will($this->returnValue(true)); $ruleFalse = $this->getMock('HTML_QuickForm2_Rule', array('checkValue'), array($el1, 'some error')); $ruleFalse->expects($this->once())->method('checkValue')->will($this->returnValue(false)); $ruleTrue2 = $this->getMock('HTML_QuickForm2_Rule', array('checkValue'), array($el2, 'irrelevant message')); $ruleTrue2->expects($this->once())->method('checkValue')->will($this->returnValue(true)); $cValidate->addRule($ruleTrue1); $el1->addRule($ruleFalse); $el2->addRule($ruleTrue2); $this->assertFalse($cValidate->validate()); $this->assertEquals('', $cValidate->getError()); }