@param Expectation $expectation

@return bool
762762
private function urlConditionIsRegex(Expectation $expectation)
    {
        return $expectation->getRequest()->getUrl() && Matchers::MATCHES === $expectation->getRequest()->getUrl()->getMatcher();
    }
886620
public function hashEquals($expected, $generated)
    {
        $expectedLength = strlen($expected);

        if ($expectedLength !== strlen($generated)) {
            return false;
        }

        $res = 0;

        for ($i = 0; $i < $expectedLength; ++$i) {
            $res |= ord($expected[$i]) ^ ord($generated[$i]);
        }

        return $res === 0;
    }
171760
public function assertHasHeader(string $expected)
    {
        $actual = $this->getHeaderText();
        if ($expected === $actual) {
            return;
        }

        throw new ExpectationException(
            sprintf(
                '[W402] Expected screen header "%1$s", found "%2$s".',
                $expected,
                $actual
            ),
            $this->getDriver()
        );
    }
880636
public function assert(callable $callback, bool $expected): bool
    {
        $index = 0;
        foreach ($this->items as $key => $value) {
            if ($callback($value, $key, $index++) !== $expected) {
                return false;
            }
        }

        return true;
    }
733757
private function fillWithUrlMatches(Expectation $expectation, ServerRequestInterface $httpRequest, $responseBody)
    {
        if ($this->urlConditionIsRegex($expectation)) {
            return $this->replaceMatches(
                'url',
                $expectation->getRequest()->getUrl()->getValue(),
                $this->getUri($httpRequest),
                $responseBody
            );
        }

        return $responseBody;
    }
1271001
public function bailUnexpectedToken($expected = false)
    {
        if (is_array($this->token)) {
            if ($expected) {
                throw new \Exception(
                    sprintf(
                        'Unexpected token %s detected at position %d - value: %s, expected %s',
                        token_name($this->token[0]),
                        $this->token[2],
                        $this->token[1],
                        token_name($expected)
                    )
                );
            }

            throw new \Exception(
                sprintf(
                    'Unexpected token %s detected at position %d - value: %s',
                    token_name($this->token[0]),
                    $this->token[2],
                    $this->token[1]
                )
            );
        }

        throw new \Exception(sprintf('Unexpected token %s detected.', $this->token));
    }
1066143
public static function match($actual, $expected = null)
    {
        if (! is_callable($actual)) {
            throw new InvalidArgumentException('actual must be callable');
        }

        $a = static::actual($actual);
        static::_buildDescription($a, $expected);

        if (is_callable($expected)) {
            return $expected($a);
        }

        return !!preg_match($expected, $a);
    }
779656
public function verifyServiceExpectations($service)
    {
        try {
            $service->mockery_verify();
        } catch (CountValidatorException $exception) {
            throw new ExpectationException('One of the expected services was not called', $this->mink->getSession(), $exception);
        }
    }
1051740
public function shouldReceive($method)
    {
        $builder = new MutableExpectationBuilder($method);
        $expectation = $builder->getExpectation();
        $builder->withAnyArgs()->atLeast(1);
        $this->add($expectation);
        return $builder;
    }
960557
protected function createError(string $expectation, $value = null): Error
    {
        if ($value !== null) {
            $error = new Error('expected: %s found: %s', 1328557141, [$expectation, $this->renderValue($value)],
                'Validation Error');
        } else {
            $error = new Error($expectation, 1328557141, [], 'Validation Error');
        }
        return $error;
    }
1220002
public static function _sameMessage($actual, $expected)
    {
        if (preg_match('~^(?P<char>\~|/|@|#).*?(?P=char)$~', (string) $expected)) {
            $same = preg_match($expected, $actual);
        } else {
            $same = $actual === $expected;
        }
        return $same || !$expected;
    }
156440
public function assertElementType(NodeElement $element, $type) {
    if ($element->getTagName() !== $type) {
      throw new ExpectationException("The element is not a '$type'' field.", $this->getSession());
    }
  }
410682
protected function validateScenarioStateOrThrowException(
        Expectation $expectation,
        LoggerInterface $logger
    ) {
        if ($expectation->getNewScenarioState() && !$expectation->getScenarioStateIs()) {
            $logger->error('Scenario states misconfiguration');
            throw new \RuntimeException(
                'Trying to set scenario state without specifying scenario previous state'
            );
        }
    }
93560
public function createExpectation(Expectation $expectation)
    {
        $uri = $this->createBaseUri()->withPath(self::API_EXPECTATIONS_URL);
        $body = @json_encode($expectation);
        if (false === $body) {
            throw new \RuntimeException('Error generating json body for request: ' . json_last_error_msg());
        }
        $request = (new PsrRequest())
            ->withUri($uri)
            ->withMethod('post')
            ->withHeader('Content-Type', 'application/json')
            ->withBody(new StringStream($body));
        $this->checkResponse($this->connection->send($request));
    }
36197
function( expectation ){
        var expr;
        var match;
        var name;
        
        for( var j = 0; j < exprs.length; j++ ){
          var e = exprs[j];
          var n = e.name;

          // ignore this expression if it doesn't meet the expectation function
          if( $$.is.fn( expectation ) && !expectation(n, e) ){ continue }

          var m = remaining.match(new RegExp( '^' + e.regex ));
          
          if( m != null ){
            match = m;
            expr = e;
            name = n;
            
            var consumed = m[0];
            remaining = remaining.substring( consumed.length );                
            
            break; // we've consumed one expr, so we can return now
          }
        }
        
        return {
          expr: expr,
          match: match,
          name: name
        };
      }
693114
public function getStrategyForExpectation(MockConfig $expectation)
    {
        if ($expectation->getResponse()->isProxyResponse()) {
            return $this->factory->createProxyResponseStrategy();
        }
        if ($this->requestBodyOrUrlAreRegexp($expectation)) {
            return $this->factory->createRegexResponseStrategy();
        }

        return $this->factory->createHttpResponseStrategy();
    }
421542
public function dontSeeQueueHasCurrentCount($queue, $expected)
    {
        $this->assertNotEquals($expected, $this->queueDriver->getMessagesCurrentCountOnQueue($queue));
    }