本文整理匯總了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();
}