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


PHP PHPUnit_Framework_Constraint类代码示例

本文整理汇总了PHP中PHPUnit_Framework_Constraint的典型用法代码示例。如果您正苦于以下问题:PHP PHPUnit_Framework_Constraint类的具体用法?PHP PHPUnit_Framework_Constraint怎么用?PHP PHPUnit_Framework_Constraint使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: matches

 protected function matches($other)
 {
     if (!$other instanceof ResponseInterface) {
         return false;
     }
     return $this->status->evaluate($other->getStatusCode(), '', true);
 }
开发者ID:martin-helmich,项目名称:phpunit-psr7-assert,代码行数:7,代码来源:HasStatusConstraint.php

示例2: evaluate

 /**
  * Evaluates the constraint for parameter $other
  *
  * If $returnResult is set to false (the default), an exception is thrown
  * in case of a failure. null is returned otherwise.
  *
  * If $returnResult is true, the result of the evaluation is returned as
  * a boolean value instead: true in case of success, false in case of a
  * failure.
  *
  * @param mixed $other
  *        	Value or object to evaluate.
  * @param string $description
  *        	Additional information about the test
  * @param bool $returnResult
  *        	Whether to return a result or throw an exception
  *        	
  * @return mixed
  *
  * @throws PHPUnit_Framework_ExpectationFailedException
  */
 public function evaluate($other, $description = '', $returnResult = false)
 {
     try {
         return $this->innerConstraint->evaluate($other, $description, $returnResult);
     } catch (PHPUnit_Framework_ExpectationFailedException $e) {
         $this->fail($other, $description);
     }
 }
开发者ID:sapwoo,项目名称:portfolio,代码行数:29,代码来源:Composite.php

示例3: matches

 protected function matches($other)
 {
     if (!$other instanceof MessageInterface) {
         return false;
     }
     $other->getBody()->rewind();
     $body = $other->getBody()->getContents();
     return $this->constraint->evaluate($body, '', true);
 }
开发者ID:martin-helmich,项目名称:phpunit-psr7-assert,代码行数:9,代码来源:BodyMatchesConstraint.php

示例4: testDefaultSchema

    public function testDefaultSchema()
    {
        $this->constraint = new ResponseBodyConstraint($this->schemaManager, '/pets', 'get', 222);
        $response = <<<JSON
{
  "code": 123456789,
  "message": "foo"
}
JSON;
        $response = json_decode($response);
        self::assertTrue($this->constraint->evaluate($response, '', true), $this->constraint->evaluate($response));
    }
开发者ID:Beanhunter,项目名称:SwaggerAssertions,代码行数:12,代码来源:ResponseBodyConstraintTest.php

示例5: matches

 protected function matches($other)
 {
     if (!$other instanceof MessageInterface) {
         return false;
     }
     if (!$other->hasHeader($this->name)) {
         return false;
     }
     foreach ($other->getHeader($this->name) as $value) {
         if ($this->constraint->evaluate($value, '', true)) {
             return true;
         }
     }
     return false;
 }
开发者ID:martin-helmich,项目名称:phpunit-psr7-assert,代码行数:15,代码来源:HasHeaderConstraint.php

示例6: __construct

 public function __construct($expected, $mainProperty, $secondaryProperty)
 {
     parent::__construct();
     $this->expected = $expected;
     $this->mainProperty = $mainProperty;
     $this->secondaryProperty = $secondaryProperty;
 }
开发者ID:khaliqgant,项目名称:Deep,代码行数:7,代码来源:CollectionNestedCollectionPropertyHasAllValuesConstraint.php

示例7: evaluate

 /**
  * Evaluates the constraint for parameter $other
  *
  * If $returnResult is set to false (the default), an exception is thrown
  * in case of a failure. null is returned otherwise.
  *
  * If $returnResult is true, the result of the evaluation is returned as
  * a boolean value instead: true in case of success, false in case of a
  * failure.
  *
  * @param mixed  $other        Value or object to evaluate.
  * @param string $description  Additional information about the test
  * @param bool   $returnResult Whether to return a result or throw an exception
  *
  * @return mixed
  *
  * @throws PHPUnit_Framework_ExpectationFailedException
  */
 public function evaluate($other, $description = '', $returnResult = FALSE)
 {
     $success = TRUE;
     foreach ($other as $item) {
         if (!$this->constraint->evaluate($item, '', TRUE)) {
             $success = FALSE;
             break;
         }
     }
     if ($returnResult) {
         return $success;
     }
     if (!$success) {
         $this->fail($other, $description);
     }
 }
开发者ID:mrbadao,项目名称:api-official,代码行数:34,代码来源:TraversableContainsOnly.php

示例8: __construct

 /**
  * @param int|float $lowerBoundary
  * @param int|float $upperBoundary
  * @param bool      $onBoundary    pass if value is same as a boundary value, or false; value must be within the boundaries values
  */
 public function __construct($lowerBoundary, $upperBoundary, $onBoundary)
 {
     parent::__construct();
     $this->lowerBoundary = $lowerBoundary;
     $this->upperBoundary = $upperBoundary;
     $this->onBoundary = $onBoundary;
 }
开发者ID:GeckoPackages,项目名称:GeckoPHPUnit,代码行数:12,代码来源:NumberRangeConstraint.php

示例9: evaluate

 /**
  * Evaluates the constraint for parameter $other
  *
  * If $returnResult is set to false (the default), an exception is thrown
  * in case of a failure. null is returned otherwise.
  *
  * If $returnResult is true, the result of the evaluation is returned as
  * a boolean value instead: true in case of success, false in case of a
  * failure.
  *
  * @param mixed  $other        Value or object to evaluate.
  * @param string $description  Additional information about the test
  * @param bool   $returnResult Whether to return a result or throw an exception
  *
  * @return mixed
  *
  * @throws PHPUnit_Framework_ExpectationFailedException
  */
 public function evaluate($other, $description = '', $returnResult = false)
 {
     $success = true;
     foreach ($other as $item) {
         if (!$this->constraint->evaluate($item, '', true)) {
             $success = false;
             break;
         }
     }
     if ($returnResult) {
         return $success;
     }
     if (!$success) {
         $this->fail($other, $description);
     }
 }
开发者ID:noikiy,项目名称:phpunit,代码行数:34,代码来源:TraversableContainsOnly.php

示例10: __construct

 public function __construct(string $className, string $methodName, int $paramIndex)
 {
     parent::__construct();
     $this->className = $className;
     $this->methodName = $methodName;
     $this->paramIndex = $paramIndex;
 }
开发者ID:cspray,项目名称:code-anvil,代码行数:7,代码来源:MethodParameterHasDefaultValue.php

示例11: __construct

 /**
  * @param int $type
  */
 public function __construct($type)
 {
     parent::__construct();
     switch ($type) {
         case self::TYPE_BOOL:
             $this->testFunction = 'is_bool';
             $this->type = 'bool';
             break;
         case self::TYPE_INT:
             $this->testFunction = 'is_int';
             $this->type = 'int';
             break;
         case self::TYPE_STRING:
             $this->testFunction = 'is_string';
             $this->type = 'string';
             break;
         case self::TYPE_FLOAT:
             $this->testFunction = 'is_float';
             $this->type = 'float';
             break;
         case self::TYPE_ARRAY:
             $this->testFunction = 'is_array';
             $this->type = 'array';
             break;
         case self::TYPE_SCALAR:
             $this->testFunction = 'is_scalar';
             $this->type = 'scalar';
             break;
         default:
             throw new \InvalidArgumentException(sprintf('Unknown ScalarConstraint type "%s" provided.', is_object($type) ? get_class($type) : (null === $type ? 'null' : gettype($type) . '#' . $type)));
     }
 }
开发者ID:GeckoPackages,项目名称:GeckoPHPUnit,代码行数:35,代码来源:ScalarConstraint.php

示例12: __construct

 /**
  * Constructor
  *
  * @param string $header Cache debug header; defaults to X-Cache-Debug
  */
 public function __construct($header = null)
 {
     if ($header) {
         $this->header = $header;
     }
     parent::__construct();
 }
开发者ID:stof,项目名称:FOSHttpCache,代码行数:12,代码来源:AbstractCacheConstraint.php

示例13: __construct

 /**
  * Construct the class.
  *
  * @since 0.1.0
  *
  * @param string $table
  * @param string $column
  * @param string $prefix
  */
 public function __construct($table, $column, $prefix)
 {
     parent::__construct();
     $this->table = esc_sql($table);
     $this->column = esc_sql($column);
     $this->prefix = $prefix;
 }
开发者ID:No3x,项目名称:wp-plugin-uninstall-tester,代码行数:16,代码来源:no-rows-with-prefix.php

示例14: __construct

 /**
  * @param int|string $permissions
  */
 public function __construct($permissions)
 {
     parent::__construct();
     if (is_string($permissions)) {
         if (!ctype_digit($permissions)) {
             if (1 !== preg_match(self::$permissionFormat, $permissions)) {
                 throw new \InvalidArgumentException(sprintf('Permission to match "%s" is not formatted correctly.', $permissions));
             }
             $this->permissions = $permissions;
             return;
         }
         if ('0' === $permissions[0]) {
             $permissions = intval($permissions, 8);
         } else {
             $permissions = (int) $permissions;
         }
     }
     if (!is_int($permissions)) {
         if (is_object($permissions)) {
             $type = sprintf('%s#%s', get_class($permissions), method_exists($permissions, '__toString') ? $permissions->__toString() : '');
         } elseif (null === $permissions) {
             $type = 'null';
         } else {
             $type = gettype($permissions) . '#' . $permissions;
         }
         throw new \InvalidArgumentException(sprintf('Invalid value for permission to match "%s", expected int >= 0 or string.', $type));
     }
     if ($permissions < 0) {
         throw new \InvalidArgumentException(sprintf('Invalid value for permission to match "%d", expected >= 0.', $permissions));
     }
     $this->permissions = $permissions;
 }
开发者ID:GeckoPackages,项目名称:GeckoPHPUnit,代码行数:35,代码来源:FilePermissionsIsIdenticalConstraint.php

示例15: __construct

 public function __construct($expected, $mainProperty, $secondaryProperty)
 {
     parent::__construct();
     $this->expected = is_array($expected) ? $expected : [$expected];
     $this->mainProperty = $mainProperty;
     $this->secondaryProperty = $secondaryProperty;
 }
开发者ID:khaliqgant,项目名称:Deep,代码行数:7,代码来源:CollectionNestedPropertyDoesNotHaveValueConstraint.php


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