本文整理汇总了PHP中Result::isValid方法的典型用法代码示例。如果您正苦于以下问题:PHP Result::isValid方法的具体用法?PHP Result::isValid怎么用?PHP Result::isValid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Result
的用法示例。
在下文中一共展示了Result::isValid方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testSetIsValid
/**
* @covers W3C\Validation\Result::setIsValid
* @covers W3C\Validation\Result::isValid
*/
public function testSetIsValid()
{
$this->result->setIsValid(false);
$this->assertFalse($this->result->isValid());
$this->result->setIsValid(true);
$this->assertTrue($this->result->isValid());
}
示例2: the_result_correctly_reports_whether_or_not_it_is_valid
/**
* @group response-validation
* @test
*/
public function the_result_correctly_reports_whether_or_not_it_is_valid()
{
$result = new Result();
$this->assertTrue($result->isValid());
$this->assertCount(0, $result->getErrors());
$result->addError('Oh noooos!');
$this->assertFalse($result->isValid());
$this->assertCount(1, $result->getErrors());
}
示例3: merge
/**
* Returns a result that represents the combination of the two given results.
* In particular, this means:
*
* If $a->getErrors() is empty and $a->isValid() is true, $b is returned.
* If $b->getErrors() is empty and $b->isValid() is true, $a is returned.
*
* Otherwise, a new Result is constructed that contains
* all errors from $a and $b, and is considered valid
* if both $a and $b were valid.
*
* @since 0.1
*
* @param Result $a
* @param Result $b
*
* @return Result
*/
public static function merge(Result $a, Result $b)
{
$aErrors = $a->getErrors();
$bErrors = $b->getErrors();
if ($a->isValid() && empty($aErrors)) {
return $b;
} elseif ($b->isValid() && empty($bErrors)) {
return $a;
} else {
$errors = array_merge($aErrors, $bErrors);
$valid = $a->isValid() && $b->isValid();
return new Result($valid, $errors);
}
}
示例4: mergeWithResult
/**
* @param Result $result
* @return $this
*/
public function mergeWithResult(Result $result)
{
if ($this->_isValid && !$result->isValid()) {
$this->_isValid = false;
}
$this->_errorMessages = array_merge($this->_errorMessages, $result->getErrorMessages());
return $this;
}