public function testValidateUntilErrorMessage()
 {
     $preError = new HTML_QuickForm2_NodeImpl();
     $preError->setError('some message');
     $ruleIrrelevant = $this->getMock('HTML_QuickForm2_Rule', array('validate', 'checkValue'), array($preError));
     $ruleIrrelevant->expects($this->never())->method('validate');
     $preError->addRule($ruleIrrelevant);
     $this->assertFalse($preError->validate());
     $manyRules = new HTML_QuickForm2_NodeImpl();
     $ruleTrue = $this->getMock('HTML_QuickForm2_Rule', array('checkValue'), array($manyRules, 'irrelevant message'));
     $ruleTrue->expects($this->once())->method('checkValue')->will($this->returnValue(true));
     $ruleFalseNoMessage = $this->getMock('HTML_QuickForm2_Rule', array('checkValue'), array($manyRules, ''));
     $ruleFalseNoMessage->expects($this->once())->method('checkValue')->will($this->returnValue(false));
     $ruleFalseWithMessage = $this->getMock('HTML_QuickForm2_Rule', array('checkValue'), array($manyRules, 'some error'));
     $ruleFalseWithMessage->expects($this->once())->method('checkValue')->will($this->returnValue(false));
     $ruleStillIrrelevant = $this->getMock('HTML_QuickForm2_Rule', array('checkValue'), array($manyRules, '...'));
     $ruleStillIrrelevant->expects($this->never())->method('checkValue');
     $manyRules->addRule($ruleTrue);
     $manyRules->addRule($ruleFalseNoMessage);
     $manyRules->addRule($ruleFalseWithMessage);
     $manyRules->addRule($ruleStillIrrelevant);
     $this->assertFalse($manyRules->validate());
     $this->assertEquals('some error', $manyRules->getError());
 }
 public function testRemoveRuleOnChangingOwner()
 {
     $nodeOne = new HTML_QuickForm2_NodeImpl();
     $nodeTwo = new HTML_QuickForm2_NodeImpl();
     $mockRule = $nodeOne->addRule($this->getMock('HTML_QuickForm2_Rule', array('validateOwner'), array($nodeOne, '...')));
     $mockRule->expects($this->once())->method('validateOwner')->will($this->returnValue(false));
     $nodeTwo->addRule($mockRule);
     $this->assertTrue($nodeOne->validate());
     $this->assertFalse($nodeTwo->validate());
 }