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


PHP ExecutionContextInterface::expects方法代码示例

本文整理汇总了PHP中Symfony\Component\Validator\Context\ExecutionContextInterface::expects方法的典型用法代码示例。如果您正苦于以下问题:PHP ExecutionContextInterface::expects方法的具体用法?PHP ExecutionContextInterface::expects怎么用?PHP ExecutionContextInterface::expects使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Symfony\Component\Validator\Context\ExecutionContextInterface的用法示例。


在下文中一共展示了ExecutionContextInterface::expects方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testInvalidFieldValueInMultipleValues

 public function testInvalidFieldValueInMultipleValues()
 {
     $constraint = new ConfigValue(['name' => 'fooz']);
     $values = [MultiFoo::FOOZ, MultiFoo::BARZ * 100, MultiFoo::BAZZ];
     $this->context->expects($this->once())->method('addViolation')->with($constraint->message);
     $this->validator->validate($values, $constraint);
 }
开发者ID:treehouselabs,项目名称:model-config,代码行数:7,代码来源:ConfigValueValidatorTest.php

示例2: testValidate

 /**
  * @param string $sku
  * @param Product|null $product
  * @dataProvider validateProvider
  */
 public function testValidate($sku, $product)
 {
     /** @var \PHPUnit_Framework_MockObject_MockObject|ProductRepository */
     $repository = $this->getMockBuilder('OroB2B\\Bundle\\ProductBundle\\Entity\\Repository\\ProductRepository')->disableOriginalConstructor()->getMock();
     $repository->expects($this->once())->method('findOneBySku')->with($sku)->will($this->returnValue($product));
     $this->registry->expects($this->once())->method('getRepository')->with(self::PRODUCT_CLASS)->will($this->returnValue($repository));
     $this->context->expects($product ? $this->never() : $this->once())->method('addViolation')->with($this->constraint->message);
     $this->validator->validate($sku, $this->constraint);
 }
开发者ID:adam-paterson,项目名称:orocommerce,代码行数:14,代码来源:ProductBySkuValidatorTest.php

示例3: testIsRegionValid

 public function testIsRegionValid()
 {
     /** @var \PHPUnit_Framework_MockObject_MockObject|Country $country */
     $country = $this->getMockBuilder('Oro\\Bundle\\AddressBundle\\Entity\\Country')->disableOriginalConstructor()->getMock();
     $country->expects($this->once())->method('hasRegions')->will($this->returnValue(true));
     $country->expects($this->once())->method('getName')->will($this->returnValue('Country'));
     $this->context->expects($this->once())->method('getPropertyPath')->will($this->returnValue('test'));
     $this->context->expects($this->once())->method('addViolationAt')->with('test.region', $this->constraint->message, ['{{ country }}' => 'Country']);
     $address = $this->createAddress();
     $address->setCountry($country);
     $this->validator->validate($address, $this->constraint);
 }
开发者ID:ramunasd,项目名称:platform,代码行数:12,代码来源:ValidRegionValidatorTest.php

示例4: expectValidateValueAt

 protected function expectValidateValueAt($i, $propertyPath, $value, $constraints, $group = null)
 {
     switch ($this->getApiVersion()) {
         case Validation::API_VERSION_2_4:
             $this->context->expects($this->at($i))->method('validateValue')->with($value, $constraints, $propertyPath, $group);
             break;
         case Validation::API_VERSION_2_5:
         case Validation::API_VERSION_2_5_BC:
             $contextualValidator = $this->context->getValidator()->inContext($this->context);
             $contextualValidator->expects($this->at(2 * $i))->method('atPath')->with($propertyPath)->will($this->returnValue($contextualValidator));
             $contextualValidator->expects($this->at(2 * $i + 1))->method('validate')->with($value, $constraints, $group);
             break;
     }
 }
开发者ID:alexbogo,项目名称:symfony,代码行数:14,代码来源:AbstractConstraintValidatorTest.php

示例5: expectValidateAt

 protected function expectValidateAt($i, $propertyPath, $value, $group)
 {
     switch ($this->getApiVersion()) {
         case Validation::API_VERSION_2_4:
             $this->context->expects($this->at($i))->method('validate')->with($value, $propertyPath, $group);
             break;
         case Validation::API_VERSION_2_5:
         case Validation::API_VERSION_2_5_BC:
             $validator = $this->context->getValidator()->inContext($this->context);
             $validator->expects($this->at(2 * $i))->method('atPath')->with($propertyPath)->will($this->returnValue($validator));
             $validator->expects($this->at(2 * $i + 1))->method('validate')->with($value, $this->logicalOr(null, array(), $this->isInstanceOf('\\Symfony\\Component\\Validator\\Constraints\\Valid')), $group);
             break;
     }
 }
开发者ID:fcontreras2,项目名称:Validator,代码行数:14,代码来源:AbstractConstraintValidatorTest.php

示例6: assertViolationCall

 /**
  * @param string $message
  * @param string $path
  */
 protected function assertViolationCall($message, $path)
 {
     $violation = $this->getMock('Symfony\\Component\\Validator\\Violation\\ConstraintViolationBuilderInterface');
     $violation->expects($this->any())->method('atPath')->with('[' . $path . ']')->will($this->returnSelf());
     $this->context->expects($this->once())->method('buildViolation')->with($message)->will($this->returnValue($violation));
 }
开发者ID:adam-paterson,项目名称:orocommerce,代码行数:10,代码来源:ConfigurableQuoteProductOfferTest.php

示例7: expectValidateValueAt

 protected function expectValidateValueAt($i, $propertyPath, $value, $constraints, $group)
 {
     $this->context->expects($this->at($i))->method('validateValue')->with($value, $constraints, $propertyPath, $group);
 }
开发者ID:rolfmadsen,项目名称:dummy_alma,代码行数:4,代码来源:AbstractConstraintValidatorTest.php


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