You are here

protected function ShsTestTrait::drupalGetJson in Simple hierarchical select 2.0.x

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 ShsTestTrait::drupalGetJson()
ShsTermTest::testChildren in tests/src/Functional/ShsTermTest.php
Tests getting children of a specific term.
ShsTermTest::testFirstLevel in tests/src/Functional/ShsTermTest.php
Tests getting the first level of terms.

File

tests/src/Functional/ShsTestTrait.php, line 161

Class

ShsTestTrait
Base test class for SHS browser tests.

Namespace

Drupal\Tests\shs\Functional

Code

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