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


PHP PHPUnit_Framework_Constraint::evaluate方法代码示例

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


在下文中一共展示了PHPUnit_Framework_Constraint::evaluate方法的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

 /**
  * {@inheritdoc}
  * @see PHPUnit_Framework_Constraint::evaluate()
  */
 public function evaluate($other, $description = '', $returnResult = false)
 {
     if (!array_key_exists($this->arrayKey, $other)) {
         return false;
     }
     $this->value = $other[$this->arrayKey];
     return $this->constraint->evaluate($other[$this->arrayKey]);
 }
开发者ID:rickb838,项目名称:scalr,代码行数:12,代码来源:ArrayHas.php

示例3: 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

示例4: 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

示例5: 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 = !$this->constraint->evaluate($other, $description, true);
     if ($returnResult) {
         return $success;
     }
     if (!$success) {
         $this->fail($other, $description);
     }
 }
开发者ID:TheTypoMaster,项目名称:SPHERE-Framework,代码行数:27,代码来源:Not.php

示例6: 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

示例7: matches

 /**
  * Executes the matcher on a given argument value.
  *
  * Forwards the call to PHPUnit's evaluate() method.
  *
  * @param mixed $argument
  * @throws Phake_Exception_MethodMatcherException
  */
 protected function matches(&$argument)
 {
     try {
         $this->constraint->evaluate($argument, '');
     } catch (PHPUnit_Framework_ExpectationFailedException $e) {
         $failure = $e->getComparisonFailure();
         if ($failure instanceof PHPUnit_Framework_ComparisonFailure) {
             $failure = $failure->getDiff();
         } else {
             $failure = '';
         }
         throw new Phake_Exception_MethodMatcherException($e->getMessage() . "\n" . $failure, $e);
     }
 }
开发者ID:eric-seekas,项目名称:Phake,代码行数:22,代码来源:PHPUnitConstraintAdapter.php

示例8: 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

示例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: testInvalidHeaderType

    public function testInvalidHeaderType()
    {
        $headers = ['Content-Type' => 'application/json'];
        self::assertFalse($this->constraint->evaluate($headers, '', true));
        try {
            $this->constraint->evaluate($headers);
            self::fail('Expected ExpectationFailedException to be thrown');
        } catch (ExpectationFailedException $e) {
            self::assertEquals(<<<EOF
Failed asserting that {"Content-Type":"application\\/json"} is valid.
[etag] The property etag is required

EOF
, TestFailure::exceptionToString($e));
        }
    }
开发者ID:Beanhunter,项目名称:SwaggerAssertions,代码行数:16,代码来源:ResponseHeadersConstraintTest.php

示例11: 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

示例12: evaluate

 /**
  * Evaluates the constraint for parameter $other. Returns TRUE if the
  * constraint is met, FALSE otherwise.
  *
  * @param mixed $other Value or object to evaluate.
  * @return bool
  */
 public function evaluate($other)
 {
     return $this->constraint->evaluate(
       PHPUnit_Framework_Assert::readAttribute(
         $other, $this->attributeName
       )
     );
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:15,代码来源:Attribute.php

示例13: evaluate

 /**
  * Overridden function to cover differences between PHPUnit 3.5 and 3.6.
  * Intentionally made final so people have to use match() from now on.
  * match() should be abstract really, but isn't, the usual PHPUnit quality...
  *
  * @param      mixed  The item to evaluate.
  * @param      string Additional information about the test (3.6+).
  * @param      bool   Whether to return a result or throw an exception (3.6+).
  *
  * @author     David Zülke <david.zuelke@bitextender.com>
  * @since      1.0.7
  */
 public function evaluate($other, $description = '', $returnResult = false)
 {
     if (version_compare(PHPUnit_Runner_Version::id(), '3.6', '<')) {
         return $this->matches($other);
     } else {
         return parent::evaluate($other, $description, $returnResult);
     }
 }
开发者ID:horros,项目名称:agavi,代码行数:20,代码来源:AgaviBaseConstraintBecausePhpunitSucksAtBackwardsCompatibility.class.php

示例14: evaluate

 /**
  * Evaluates the constraint for parameter $other. Returns TRUE if the
  * constraint is met, FALSE otherwise.
  *
  * @param mixed $other Value or object to evaluate.
  * @return bool
  */
 public function evaluate($other)
 {
     foreach ($other as $item) {
         if (!$this->constraint->evaluate($item)) {
             return FALSE;
         }
     }
     return TRUE;
 }
开发者ID:AroundPBT,项目名称:PHPBoost,代码行数:16,代码来源:TraversableContainsOnly.php

示例15: matches

 /**
  * @inheritdoc
  */
 protected function matches($other)
 {
     if (is_string($other)) {
         $other = json_decode($other);
     }
     $result = (new JSONPath($other))->find($this->jsonPath);
     if (!isset($result[0])) {
         return false;
     }
     $combineFunc = $this->buildCombinationFunction();
     $matches = null;
     foreach ($result as $v) {
         if ($v instanceof JSONPath) {
             $v = $v->data();
         }
         $singleMatchResult = $this->constraint->evaluate($v, '', true);
         $matches = $combineFunc($matches, $singleMatchResult);
     }
     return $matches;
 }
开发者ID:martin-helmich,项目名称:phpunit-json-assert,代码行数:23,代码来源:JsonValueMatches.php


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