function StyleSerializerEntityTest::addRequestWithFormat

Same name and namespace in other branches
  1. 10 core/modules/rest/tests/src/Functional/Views/StyleSerializerEntityTest.php \Drupal\Tests\rest\Functional\Views\StyleSerializerEntityTest::addRequestWithFormat()

Sets up a request on the request stack with a specified format.

Parameters

string $format: The new request format.

1 call to StyleSerializerEntityTest::addRequestWithFormat()
StyleSerializerEntityTest::testRestRenderCaching in core/modules/rest/tests/src/Functional/Views/StyleSerializerEntityTest.php
Tests REST export with views render caching enabled.

File

core/modules/rest/tests/src/Functional/Views/StyleSerializerEntityTest.php, line 209

Class

StyleSerializerEntityTest
Tests the serializer style plugin.

Namespace

Drupal\Tests\rest\Functional\Views

Code

protected function addRequestWithFormat($format) {
    $request = \Drupal::request();
    $request = clone $request;
    $request->setRequestFormat($format);
    \Drupal::requestStack()->push($request);
}

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