当前位置: 首页>>代码示例>>PHP>>正文


PHP ValidatorInterface::expects方法代码示例

本文整理汇总了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);
 }
开发者ID:davidbadura,项目名称:fixtures,代码行数:7,代码来源:ValidationListenerTest.php

示例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));
 }
开发者ID:acorbel,项目名称:FOSRestBundle,代码行数:14,代码来源:ParamFetcherTest.php

示例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();
 }
开发者ID:antrampa,项目名称:crm,代码行数:20,代码来源:MarketingListHandlerTest.php


注:本文中的Symfony\Component\Validator\ValidatorInterface::expects方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。