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