function TermAutocompleteTest::drupalGetJson

Same name in other branches
  1. 8.9.x core/modules/taxonomy/tests/src/Functional/TermAutocompleteTest.php \Drupal\Tests\taxonomy\Functional\TermAutocompleteTest::drupalGetJson()
  2. 10 core/modules/taxonomy/tests/src/Functional/TermAutocompleteTest.php \Drupal\Tests\taxonomy\Functional\TermAutocompleteTest::drupalGetJson()
  3. 11.x core/modules/taxonomy/tests/src/Functional/TermAutocompleteTest.php \Drupal\Tests\taxonomy\Functional\TermAutocompleteTest::drupalGetJson()

Helper function for JSON formatted requests.

Parameters

string|\Drupal\Core\Url $path: Drupal path or URL to load into Mink controlled browser.

array $options: (optional) Options to be forwarded to the URL generator.

string[] $headers: (optional) An array containing additional HTTP request headers.

Return value

string[] Array representing decoded JSON response.

2 calls to TermAutocompleteTest::drupalGetJson()
TermAutocompleteTest::testAutocompleteCountResults in core/modules/taxonomy/tests/src/Functional/TermAutocompleteTest.php
Tests that the autocomplete method returns the good number of results.
TermAutocompleteTest::testAutocompleteOrderedResults in core/modules/taxonomy/tests/src/Functional/TermAutocompleteTest.php
Tests that the autocomplete method returns properly ordered results.

File

core/modules/taxonomy/tests/src/Functional/TermAutocompleteTest.php, line 159

Class

TermAutocompleteTest
Tests the autocomplete implementation of the taxonomy class.

Namespace

Drupal\Tests\taxonomy\Functional

Code

protected function drupalGetJson($path, array $options = [], array $headers = []) {
    $options = array_merge_recursive([
        'query' => [
            '_format' => 'json',
        ],
    ], $options);
    return Json::decode($this->drupalGet($path, $options, $headers));
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.