本文整理汇总了PHP中Symfony\Component\Validator\ExecutionContextInterface::expects方法的典型用法代码示例。如果您正苦于以下问题:PHP ExecutionContextInterface::expects方法的具体用法?PHP ExecutionContextInterface::expects怎么用?PHP ExecutionContextInterface::expects使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\Validator\ExecutionContextInterface
的用法示例。
在下文中一共展示了ExecutionContextInterface::expects方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testValidate
public function testValidate()
{
$this->repository->expects($this->once())->method('findDuplicate')->with($this->lineItem)->will($this->returnValue(true));
$this->registry->expects($this->once())->method('getRepository')->with(self::LINE_ITEM_SHORTCUT)->will($this->returnValue($this->repository));
$this->context->expects($this->once())->method('addViolation')->with($this->constraint->message);
$validator = new LineItemValidator($this->registry);
$validator->initialize($this->context);
$validator->validate($this->lineItem, $this->constraint);
}
示例2: testValidate
/**
* @dataProvider validateDataProvider
* @param mixed $data
* @param boolean $correct
*/
public function testValidate($data, $correct)
{
if (!$correct) {
$this->context->expects($this->once())->method('addViolation')->with($this->constraint->message);
} else {
$this->context->expects($this->never())->method('addViolation');
}
$this->validator->validate($data, $this->constraint);
}
示例3: testValidate
/**
* @param mixed $data
* @param bool $expected
*
* @dataProvider validateDataProvider
*/
public function testValidate($data, $expected)
{
$constraint = new ExtensionLoaded();
$this->context = $this->getMock('Symfony\\Component\\Validator\\ExecutionContextInterface');
if ($expected) {
$this->validator->initialize($this->context);
$this->context->expects($this->once())->method('addViolation')->with($this->isType('string'));
}
$this->validator->validate($data, $constraint);
}
示例4: testValidateNotExistingProduct
public function testValidateNotExistingProduct()
{
$price = $this->getProductPrice();
// Set null to product and productSku
$class = new \ReflectionClass($price);
$product = $class->getProperty('product');
$product->setAccessible(true);
$product->setValue($price, null);
$productSku = $class->getProperty('productSku');
$productSku->setAccessible(true);
$productSku->setValue($price, null);
$this->context->expects($this->once())->method('addViolationAt')->with('product', $this->constraint->notExistingProductMessage);
$this->validator->validate($price, $this->constraint);
}
示例5: testNoViolationsOnUniqueUserProperty
public function testNoViolationsOnUniqueUserProperty()
{
$this->ldapManagerMock->expects($this->once())->method('findUserByUsername')->will($this->returnValue(null))->with($this->equalTo($this->user->getUsername()));
$this->validatorContext->expects($this->never())->method('addViolation');
$this->validator->validate($this->user, $this->constraint);
}
示例6: expectValidateValueAt
protected function expectValidateValueAt($i, $propertyPath, $value, $constraints, $group)
{
$this->context->expects($this->at($i))->method('validateValue')->with($value, $constraints, $propertyPath, $group);
}
示例7: testValidate
/**
* @param mixed $data
* @param boolean $valid
* @dataProvider validateProvider
*/
public function testValidate($data, $valid)
{
$this->context->expects($valid ? $this->never() : $this->once())->method('addViolationAt')->with('productUnit', $this->constraint->message);
$this->validator->validate($data, $this->constraint);
}
示例8: testWithoutPrice
public function testWithoutPrice()
{
$productPrice = new ProductPrice();
$this->context->expects($this->never())->method('addViolationAt');
$this->validator->validate($productPrice, $this->constraint);
}
示例9: testValidateWithDuplications
public function testValidateWithDuplications()
{
$this->context->expects($this->once())->method('addViolation')->with($this->constraint->message);
$data = new ArrayCollection([$this->createPriceList(1, 10, 'kg', 'USD'), $this->createPriceList(1, 10, 'kg', 'USD')]);
$this->validator->validate($data, $this->constraint);
}
示例10: testValidate
/**
* @param $options
* @param $value
* @param $violation
*
* @dataProvider validateDataProvider
*/
public function testValidate($options, $value, $violation)
{
$this->context->expects($violation ? $this->once() : $this->never())->method('addViolation');
$constraint = new Decimal($options);
$this->validator->validate($value, $constraint);
}
示例11: testValidate
/**
* @param boolean $isValid
* @param mixed $inputData
* @dataProvider validateProvider
*/
public function testValidate($isValid, $inputData)
{
$this->context->expects($isValid ? $this->never() : $this->once())->method('addViolationAt')->with('currency', $this->constraint->message);
$this->validator->validate($inputData, $this->constraint);
}