本文整理汇总了PHP中Symfony\Component\Validator\ValidatorInterface::expects方法的典型用法代码示例。如果您正苦于以下问题:PHP ValidatorInterface::expects方法的具体用法?PHP ValidatorInterface::expects怎么用?PHP ValidatorInterface::expects使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\Validator\ValidatorInterface
的用法示例。
在下文中一共展示了ValidatorInterface::expects方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUp
public function setUp()
{
parent::setUp();
$this->validator = $this->getMock('Symfony\\Component\\Validator\\ValidatorInterface');
$this->validator->expects($this->never())->method('validate')->will($this->returnValue(array()));
$this->listener = new ValidationListener($this->validator);
}
示例2: testValidationErrorsInStrictMode
/**
* @expectedException Symfony\Component\HttpKernel\Exception\BadRequestHttpException
* @expectedMessage expected exception.
*/
public function testValidationErrorsInStrictMode()
{
$param = $this->createMockedParam('foo', null, [], false, null, ['constraint']);
list($fetcher, $method) = $this->getFetcherToCheckValidation($param);
$errors = $this->getMock('Symfony\\Component\\Validator\\ConstraintViolationListInterface');
$errors->expects($this->once())->method('count')->willReturn(1);
$this->validator->expects($this->once())->method('validate')->with('value', array('constraint'))->willReturn($errors);
$this->violationFormatter->expects($this->once())->method('formatList')->with($param, $errors)->willReturn('expected exception.');
$method->invokeArgs($fetcher, array($param, 'value', true));
}
示例3: testProcessInvalidSegment
public function testProcessInvalidSegment()
{
$this->request->setMethod('POST');
$this->form->expects($this->once())->method('submit')->with($this->request);
$this->assertProcessSegment();
$this->form->expects($this->once())->method('isValid')->will($this->returnValue(false));
$violation = $this->getMockForAbstractClass('Symfony\\Component\\Validator\\ConstraintViolationInterface');
$violation->expects($this->once())->method('getMessage')->will($this->returnValue('message'));
$violation->expects($this->once())->method('getMessageTemplate')->will($this->returnValue('message template'));
$violation->expects($this->once())->method('getMessageParameters')->will($this->returnValue(['test']));
$violation->expects($this->once())->method('getMessagePluralization')->will($this->returnValue('message pluralization'));
$errors = new ConstraintViolationList([$violation]);
$this->validator->expects($this->once())->method('validate')->with($this->isInstanceOf('Oro\\Bundle\\SegmentBundle\\Entity\\Segment'), ['Default', 'marketing_list'])->will($this->returnValue($errors));
$this->translator->expects($this->once())->method('trans')->with($this->isType('string'), $this->isType('array'))->will($this->returnValue('Marketing List test segment'));
$this->form->expects($this->once())->method('addError')->with(new FormError('message', 'message template', ['test'], 'message pluralization'));
$this->manager->expects($this->never())->method('persist');
$this->manager->expects($this->never())->method('flush');
$this->assertFalse($this->handler->process($this->testEntity));
$this->assertSegmentData();
}