本文整理汇总了PHP中Symfony\Component\Validator\Context\ExecutionContextInterface::expects方法的典型用法代码示例。如果您正苦于以下问题:PHP ExecutionContextInterface::expects方法的具体用法?PHP ExecutionContextInterface::expects怎么用?PHP ExecutionContextInterface::expects使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\Validator\Context\ExecutionContextInterface
的用法示例。
在下文中一共展示了ExecutionContextInterface::expects方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testInvalidFieldValueInMultipleValues
public function testInvalidFieldValueInMultipleValues()
{
$constraint = new ConfigValue(['name' => 'fooz']);
$values = [MultiFoo::FOOZ, MultiFoo::BARZ * 100, MultiFoo::BAZZ];
$this->context->expects($this->once())->method('addViolation')->with($constraint->message);
$this->validator->validate($values, $constraint);
}
示例2: testValidate
/**
* @param string $sku
* @param Product|null $product
* @dataProvider validateProvider
*/
public function testValidate($sku, $product)
{
/** @var \PHPUnit_Framework_MockObject_MockObject|ProductRepository */
$repository = $this->getMockBuilder('OroB2B\\Bundle\\ProductBundle\\Entity\\Repository\\ProductRepository')->disableOriginalConstructor()->getMock();
$repository->expects($this->once())->method('findOneBySku')->with($sku)->will($this->returnValue($product));
$this->registry->expects($this->once())->method('getRepository')->with(self::PRODUCT_CLASS)->will($this->returnValue($repository));
$this->context->expects($product ? $this->never() : $this->once())->method('addViolation')->with($this->constraint->message);
$this->validator->validate($sku, $this->constraint);
}
示例3: testIsRegionValid
public function testIsRegionValid()
{
/** @var \PHPUnit_Framework_MockObject_MockObject|Country $country */
$country = $this->getMockBuilder('Oro\\Bundle\\AddressBundle\\Entity\\Country')->disableOriginalConstructor()->getMock();
$country->expects($this->once())->method('hasRegions')->will($this->returnValue(true));
$country->expects($this->once())->method('getName')->will($this->returnValue('Country'));
$this->context->expects($this->once())->method('getPropertyPath')->will($this->returnValue('test'));
$this->context->expects($this->once())->method('addViolationAt')->with('test.region', $this->constraint->message, ['{{ country }}' => 'Country']);
$address = $this->createAddress();
$address->setCountry($country);
$this->validator->validate($address, $this->constraint);
}
示例4: expectValidateValueAt
protected function expectValidateValueAt($i, $propertyPath, $value, $constraints, $group = null)
{
switch ($this->getApiVersion()) {
case Validation::API_VERSION_2_4:
$this->context->expects($this->at($i))->method('validateValue')->with($value, $constraints, $propertyPath, $group);
break;
case Validation::API_VERSION_2_5:
case Validation::API_VERSION_2_5_BC:
$contextualValidator = $this->context->getValidator()->inContext($this->context);
$contextualValidator->expects($this->at(2 * $i))->method('atPath')->with($propertyPath)->will($this->returnValue($contextualValidator));
$contextualValidator->expects($this->at(2 * $i + 1))->method('validate')->with($value, $constraints, $group);
break;
}
}
示例5: expectValidateAt
protected function expectValidateAt($i, $propertyPath, $value, $group)
{
switch ($this->getApiVersion()) {
case Validation::API_VERSION_2_4:
$this->context->expects($this->at($i))->method('validate')->with($value, $propertyPath, $group);
break;
case Validation::API_VERSION_2_5:
case Validation::API_VERSION_2_5_BC:
$validator = $this->context->getValidator()->inContext($this->context);
$validator->expects($this->at(2 * $i))->method('atPath')->with($propertyPath)->will($this->returnValue($validator));
$validator->expects($this->at(2 * $i + 1))->method('validate')->with($value, $this->logicalOr(null, array(), $this->isInstanceOf('\\Symfony\\Component\\Validator\\Constraints\\Valid')), $group);
break;
}
}
示例6: assertViolationCall
/**
* @param string $message
* @param string $path
*/
protected function assertViolationCall($message, $path)
{
$violation = $this->getMock('Symfony\\Component\\Validator\\Violation\\ConstraintViolationBuilderInterface');
$violation->expects($this->any())->method('atPath')->with('[' . $path . ']')->will($this->returnSelf());
$this->context->expects($this->once())->method('buildViolation')->with($message)->will($this->returnValue($violation));
}
示例7: expectValidateValueAt
protected function expectValidateValueAt($i, $propertyPath, $value, $constraints, $group)
{
$this->context->expects($this->at($i))->method('validateValue')->with($value, $constraints, $propertyPath, $group);
}