@param Expectation $expectation

@return bool
540879
private function isExpectedScenarioState(Expectation $expectation)
    {
        if ($expectation->getScenarioStateIs()) {
            $this->checkScenarioNameOrThrowException($expectation);
            $this->logger->debug('Checking scenario state again expectation');
            $scenarioState = $this->scenarioStorage->getScenarioState(
                $expectation->getScenarioName()
            );
            if ($expectation->getScenarioStateIs() !== $scenarioState) {
                return false;
            }
        }

        return true;
    }
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()
            );
        }
    }
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;
    }
348422
public function createMockConfig(MockConfig $expectation)
    {
        $uri = $this->createBaseUri()->withPath(self::API_EXPECTATIONS_URL);
        // TODO: Add converter from expectation to array
        $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->ensureIsNotErrorResponse($this->connection->send($request));
    }
365756
public static function match($actual, $expected, $precision = 2)
    {
        static::_buildDescription($actual, $expected, $precision);

        if (!is_numeric($actual) || !is_numeric($expected)) {
            return false;
        }
        return abs($expected - $actual) < (pow(10, -$precision) / 2);
    }
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);
    }
349008
protected function validateScenarioNameOrThrowException(
        Expectation $expectation,
        LoggerInterface $logger
    ) {
        if (!$expectation->getScenarioName()
            && ($expectation->getScenarioStateIs() || $expectation->getNewScenarioState())
        ) {
            $logger->error('Scenario name related misconfiguration');
            throw new \RuntimeException(
                'Expecting or trying to set scenario state without specifying scenario name'
            );
        }
    }
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()
            );
        }
    }
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'.");
    }
  }
707747
public function cd($dir)
    {
        $this->workingDir[] = $dir;
        if (!is_dir($this->currentDir())) {
            throw new ExpectationException($this->currentDir() . " is not a directory");
        }
    }
1249952
public function equalTo($expected): Expect {
            $this->testsTheEqualityAgainstAValue = true;
            $this->expected = $expected;

            return $this;
        }
513839
public function dontSeeQueueHasTotalCount($queue, $expected)
    {
        $this->assertNotEquals($expected, $this->queueDriver->getMessagesTotalCountOnQueue($queue));
    }
365613
public static function assertEquals($actual, $expected, Throwable $exception)
    {
        static::makeAssertion($actual === $expected, $exception);
        return $actual;
    }
531134
protected synchronized boolean unsetExpectation(final AbstractExpectation<C, P> expectation) {
        if (this.expectations.containsKey(expectation)) {
            this.expectations.remove(expectation);
            AbstractExpectationManager.LOGGER.info("Unregistered expectation {}.", expectation);
            return true;
        }
        return false;
    }
421542
public function dontSeeQueueHasCurrentCount($queue, $expected)
    {
        $this->assertNotEquals($expected, $this->queueDriver->getMessagesCurrentCountOnQueue($queue));
    }
21539
protected function validateExpectationOrThrowException(MockConfig $expectation, LoggerInterface $logger)
    {
        $this->logger->debug('Adding Expectation->validateExpectationOrThrowException');
        $this->validateRequestOrThrowException($expectation, $logger);
        $this->validateResponseOrThrowException($expectation, $logger);
        $this->validateScenarioConfigOrThrowException($expectation, $logger);
    }
7532
public function assertGreaterThanOrEqual($expected, $message = '')
    {
        Assert::assertGreaterThanOrEqual($expected, $this->getData(), $message);

        return $this;
    }