@param Expectation $expectation

@return bool
320451
private function requestBodyOrUrlAreRegexp(Expectation $expectation)
    {
        return $expectation->getRequest()->getBody()
            && Matchers::MATCHES === $expectation->getRequest()->getBody()->getMatcher()
            || $expectation->getRequest()->getUrl()
            && Matchers::MATCHES === $expectation->getRequest()->getUrl()->getMatcher();
    }
194781
public static function match($actual, $expected)
    {
        $args = func_get_args();
        $expected = count($args) > 2 ? array_slice($args, 1) : $expected;
        $expected = (array) $expected;

        if (is_array($actual)) {
            foreach ($expected as $key) {
                if (!array_key_exists($key, $actual)) {
                    return false;
                }
            }
            return true;
        } elseif ($actual instanceof ArrayAccess) {
            foreach ($expected as $key) {
                if (!isset($actual[$key])) {
                    return false;
                }
            }
            return true;
        } elseif ($actual instanceof Traversable) {
            foreach ($expected as $key) {
                foreach ($actual as $k => $v) {
                    if ($key === $k) {
                        continue 2;
                    }
                }
                return false;
            }
            return true;
        }

        return false;
    }
244495
public function handleException( $e )
    {
        foreach( $this->handlers as $handler ){
            $ret = $handler->handleException( $e );
            if ( $ret ){
                return true;
            }
        }

        return false;
    }
526171
public function redefineUsingExpectation(Expectation $expectation)
    {
        $fqn = $this->function_name->fullyQualifiedName();

        $this->alias(function (...$args) use ($expectation, $fqn) {

            $mock = $expectation->mockeryExpectation()->getMock();
            $target = new ExpectationTarget(ExpectationTarget::TYPE_FUNCTION, $fqn);

            return $mock->{$target->mockMethodName()}(...$args);
        });
    }
146347
public function seeInEmailHtmlBody($expected)
    {
        $email = $this->fetchLastMessage();
        $this->assertContains($expected, $email->html_body, 'Email body contains HTML');
    }
983753
public static boolean conditionalExpression( String expectation )
    {
        String expression = expectation.replaceAll( CONDITIONAL_EXPRESSION_WITH_DOUBLE_QUOTES_PATTERN, "" );

        return Pattern.matches( CONDITIONAL_EXPRESSION_NO_DOUBLE_QUOTES_PATTERN, expression );
    }
175251
public function allServerAre($event, $expected)
    {
        $targets = $this->computeNumberOfTargets();
        $statuses = array_filter($this->statuses[$event], function ($server) use ($expected) {
            return $server === $expected;
        });

        return $targets === count($statuses);
    }
790046
public function shouldPrecede($first, $second) {
    $page = $this->getSession()->getPage()->getText();
    $pos1 = strpos($page, $first);
    if ($pos1 === FALSE) {
      throw new ExpectationException("Text not found: '$first'.", $this->getSession());
    }
    $pos2 = strpos($page, $second);
    if ($pos2 === FALSE) {
      throw new ExpectationException("Text not found: '$second'.", $this->getSession());
    }
    if ($pos2 < $pos1) {
      throw new \Exception("Text '$first' does not precede text '$second'.");
    }
  }
1236192
public function prefix($expected = null)
    {
        $current = null;

        if ($this->Controller->request->prefix !== null) {
            $current = $this->Controller->request->prefix;
        }

        if ($current == $expected) {
            return true;
        }

        return false;
    }
942202
protected function validateResponseOrThrowException(Expectation $expectation, LoggerInterface $logger)
    {
        if ($this->responseIsInvalid($expectation->getResponse())) {
            $logger->error('Invalid response specified in expectation');
            throw new \RuntimeException('Invalid response specified in expectation');
        }
    }
186921
private function fillWithBodyMatches(Expectation $expectation, ServerRequestInterface $httpRequest, $responseBody)
    {
        if ($this->bodyConditionIsRegex($expectation)) {
            return $this->replaceMatches(
                'body',
                $expectation->getRequest()->getBody()->getValue(),
                $httpRequest->getBody()->__toString(),
                $responseBody
            );
        }

        return $responseBody;
    }
1051740
public function shouldReceive($method)
    {
        $builder = new MutableExpectationBuilder($method);
        $expectation = $builder->getExpectation();
        $builder->withAnyArgs()->atLeast(1);
        $this->add($expectation);
        return $builder;
    }
401275
public function iShouldSeeAnUniqueElementWithXpath($xpath)
    {
        $result = $this->getSession()->getPage()->find('xpath', $xpath);

        if (is_null($result)) {
            // There must be exactly one element on the page, anything else is not correct
            throw new ExpectationException(
                sprintf(
                    'The xpath %s (on %s) returned no elements',
                    $xpath,
                    $this->getSession()->getCurrentUrl()
                ),
                $this->getSession()->getDriver()
            );
        }
    }
49404
public static function match($actual, $expected)
    {
        $length = static::actual($actual);
        static::_buildDescription($actual, $length, $expected);

        return $length === $expected;
    }
967739
public function yyerror( $message, $expected = null )
	{
		if ( ! is_null( $this->errorText ) && ! is_null( $expected ) && count( $expected ) > 0 )
		{
			$errorMsg = $message . ", expecting";
			for ( $n = 0; $n < count( $expected ); ++ $n )
				$errorMsg .= " " . $expected[ $n ];
			$this->errorText[] = "$errorMsg\n";
		} else
			$this->errorText[] = "$message\n";
	}
603869
public static function eq($val, $expected, $strict = true): bool
    {
        return $strict ? $val === $expected : $val == $expected;
    }
1064419
public function iShouldSeeRegex($regex)
    {
        $actual = $this->getSession()->getPage()->getText();
        $actual = preg_replace('/\s+/u', ' ', $actual);
        
        if (0 === preg_match(ReformatRegex::spaceTabsEqual(sprintf('/%s/', $regex)), $actual)) {
            // No matches meaning we haven't found what were looking for
            throw new ExpectationException(
                sprintf(
                    'The content %s can not be found on %s',
                    $regex,
                    $this->getSession()->getCurrentUrl()
                ),
                $this->getSession()->getDriver()
            );
        }
    }