You are here

protected function EntityAutocompleteTest::getAutocompleteResult in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/system/src/Tests/Entity/EntityAutocompleteTest.php \Drupal\system\Tests\Entity\EntityAutocompleteTest::getAutocompleteResult()

Returns the result of an Entity reference autocomplete request.

Parameters

string $input: The label of the entity to query by.

Return value

mixed The JSON value encoded in its appropriate PHP type.

1 call to EntityAutocompleteTest::getAutocompleteResult()
EntityAutocompleteTest::testEntityReferenceAutocompletion in core/modules/system/src/Tests/Entity/EntityAutocompleteTest.php
Tests autocompletion edge cases with slashes in the names.

File

core/modules/system/src/Tests/Entity/EntityAutocompleteTest.php, line 150
Contains \Drupal\system\Tests\Entity\EntityAutocompleteTest.

Class

EntityAutocompleteTest
Tests the autocomplete functionality.

Namespace

Drupal\system\Tests\Entity

Code

protected function getAutocompleteResult($input) {
  $request = Request::create('entity_reference_autocomplete/' . $this->entityType . '/default');
  $request->query
    ->set('q', $input);
  $selection_settings = [];
  $selection_settings_key = Crypt::hmacBase64(serialize($selection_settings) . $this->entityType . 'default', Settings::getHashSalt());
  \Drupal::keyValue('entity_autocomplete')
    ->set($selection_settings_key, $selection_settings);
  $entity_reference_controller = EntityAutocompleteController::create($this->container);
  $result = $entity_reference_controller
    ->handleAutocomplete($request, $this->entityType, 'default', $selection_settings_key)
    ->getContent();
  return Json::decode($result);
}