@param MockConfig $expectation

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

        return true;
    }
910849
public function equals(ServerRequestInterface $httpRequest, MockConfig $expectation)
    {
        $this->logger->debug('Checking if request matches an expectation');

        if (!$this->isExpectedScenarioState($expectation)) {
            return false;
        }

        $expectedRequest = $expectation->getRequest();

        $atLeastOneExecution = $this->compareRequestParts($httpRequest, $expectedRequest);

        if (null !== $atLeastOneExecution && $expectedRequest->getHeaders()) {
            $this->logger->debug('Checking headers against expectation');

            return $this->requestHeadersMatchExpectation($httpRequest, $expectedRequest);
        }

        return (bool) $atLeastOneExecution;
    }
307013
public function assertFields(TableNode $expected) {
    $fields = [];
    foreach ($this->getContentEntityTypes() as $entity_type) {
      $bundles = $this->entityTypeManager()
        ->getStorage($entity_type->getBundleEntityType())
        ->loadMultiple();
      foreach ($bundles as $bundle) {
        /** @var string[] $ids */
        $ids = \Drupal::entityQuery('field_config')
          ->condition('bundle', $bundle->id())
          ->condition('entity_type', $entity_type->id())
          ->execute();

        if (!$ids) {
          continue;
        }

        $display_id = "{$entity_type->id()}.{$bundle->id()}.default";
        $form_display = EntityFormDisplay::load($display_id);
        if (is_null($form_display)) {
          throw new \Exception(sprintf('No such form display: %s. Try saving the "Manage form display" form for the "%s" %s.', $display_id, $bundle->label(), strtolower($entity_type->getBundleLabel())));
        }
        $form_components = $form_display->getComponents();

        /** @var \Drupal\field\FieldConfigInterface $field_config */
        foreach (FieldConfig::loadMultiple($ids) as $id => $field_config) {
          $machine_name = $this->getFieldMachineNameFromConfigId($id);
          $field_storage = $field_config->getFieldStorageDefinition();
          $fields[] = [
            $bundle->label(),
            $field_config->getLabel(),
            $machine_name,
            (string) $this->fieldTypeManager->getDefinition($field_config->getType())['label'],
            $field_config->isRequired() ? 'Required' : '',
            $field_storage->getCardinality() === -1 ? 'Unlimited' : $field_storage->getCardinality(),
            isset($form_components[$machine_name]['type']) ? (string) $this->fieldWidgetManager->getDefinition($form_components[$machine_name]['type'])['label'] : '-- Disabled --',
            $field_config->isTranslatable() ? 'Translatable' : '',
            $field_config->getDescription(),
          ];
        }
      }
    }
    $actual = new TableNode($fields);

    (new TableEqualityAssertion($expected, $actual))
      ->expectHeader([
        'Bundle',
        'Field label',
        'Machine name',
        'Field type',
        'Required',
        'Cardinality',
        'Form widget',
        'Translatable',
        'Help text',
      ])
      ->ignoreRowOrder()
      ->setMissingRowsLabel(self::missingRowsLabelFor('fields'))
      ->setUnexpectedRowsLabel(self::unexpectedRowsLabelFor('fields'))
      ->assert();
  }
1307557
private function getResponseWithBody(
        Expectation $expectation,
        ResponseInterface $httpResponse,
        ServerRequestInterface $httpRequest
    ) {
        $responseBody = $expectation->getResponse()->getBody();

        if ($responseBody) {
            $responseBody = $this->fillWithUrlMatches($expectation, $httpRequest, $responseBody);
            $responseBody = $this->fillWithBodyMatches($expectation, $httpRequest, $responseBody);
            $httpResponse = $httpResponse->withBody(new StringStream($responseBody));
        }

        return $httpResponse;
    }
118609
final protected function checkMockType($mock)
    {
        $this->verifyMockType();

        if (!is_a($mock, $this->mockType)) {
            throw new InvalidArgumentException(
                sprintf(
                    'Mock object must be an instance of "%s", "%s" given',
                    $this->mockType,
                    \gettype($mock)
                )
            );
        }
    }
472878
protected function assertGreaterThan($expected, $actual, $message = '')
    {
        \PHPUnit\Framework\Assert::assertGreaterThan($expected, $actual, $message);
    }
708930
protected function addExpectedMock($key, \PHPUnit_Framework_MockObject_MockObject $mock)
    {
        if (isset($this->expectedMocks[$key]) || isset($this->expectedMocksCollections[$key]) || isset($this->expectedValues[$key])) {
            throw new \LogicException(
                sprintf('The expected mock "%s" you are trying to add is already set as mock, mock collection or value.', $key)
            );
        }

        $this->expectedMocks[$key] = $mock;

        return $this;
    }
696415
public function it_should_call_listeners_for_their_events_when_event_is_triggered(
        MockListener $listener,
        Event $event
    ) {
        $event->hasBeenHandled()
              ->willReturn(\false);
        $listener->method1($event, 'test1', $this)
                 ->willReturn($event);
        $this->addListener('test1', [$listener, 'method1']);
        $this->getListeners()
             ->shouldHaveKey('test1');
        $listener->method1($event, 'test1', $this)
                 ->shouldBeCalled();
        $this->trigger('test1', $event);
    }
108090
protected function _verifyResponse($expected)
	{
		$parts = null;

		// Wait for a response from the server, but timeout after the set time limit
		$endTime = time() + $this->timeout;
		$this->response = '';

		do
		{
			$this->response .= fgets($this->conn, 4096);
		}

		while (!preg_match("/^([0-9]{3})(-(.*" . CRLF . ")+\\1)? [^" . CRLF . "]+" . CRLF . "$/", $this->response, $parts) && time() < $endTime);

		// Catch a timeout or bad response
		if (!isset($parts[1]))
		{
			Log::add(
				sprintf(
					'%1$s: Timeout or unrecognised response while waiting for a response from the server. Server response: %2$s',
					__METHOD__, $this->response
				),
				Log::WARNING, 'jerror'
			);

			return false;
		}

		// Separate the code from the message
		$this->_responseCode = $parts[1];
		$this->_responseMsg = $parts[0];

		// Did the server respond with the code we wanted?
		if (is_array($expected))
		{
			if (in_array($this->_responseCode, $expected))
			{
				$retval = true;
			}
			else
			{
				$retval = false;
			}
		}
		else
		{
			if ($this->_responseCode == $expected)
			{
				$retval = true;
			}
			else
			{
				$retval = false;
			}
		}

		return $retval;
	}
1249952
public function equalTo($expected): Expect {
            $this->testsTheEqualityAgainstAValue = true;
            $this->expected = $expected;

            return $this;
        }
83008
public function seeQueueHasTotalCount($queue, $expected)
    {
        $this->assertEquals($expected, $this->queueDriver->getMessagesTotalCountOnQueue($queue));
    }
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;
    }
378758
public function notStrictEqual($actual, $expected, $message = '')
    {
        $this->assertion->setActual($actual);

        return $this->assertion->to->not->equal($expected, $message);
    }
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));
    }
343267
public function assertParameters($name, $expected) {
    $value = \Drupal::getContainer()->getParameter($name);
    Assert::eq($value, $this->castParameter($expected));
  }
739767
protected function assertNotSame($expected, $actual, $message = '')
    {
        \PHPUnit\Framework\Assert::assertNotSame($expected, $actual, $message);
    }
1213032
protected function doGet($mock)
    {
        try {
            return $mock->reveal();
        } catch (ObjectProphecyException $exception) {
            throw new MockNotCreatedException(
                sprintf(
                    'Cannot create mock object: %s',
                    $exception->getMessage()
                )
            );
        }
    }