當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。