function ResourceResponseSubscriberTest::getFunctioningResourceResponseSubscriber

Same name in other branches
  1. 9 core/modules/rest/tests/src/Unit/EventSubscriber/ResourceResponseSubscriberTest.php \Drupal\Tests\rest\Unit\EventSubscriber\ResourceResponseSubscriberTest::getFunctioningResourceResponseSubscriber()
  2. 10 core/modules/rest/tests/src/Unit/EventSubscriber/ResourceResponseSubscriberTest.php \Drupal\Tests\rest\Unit\EventSubscriber\ResourceResponseSubscriberTest::getFunctioningResourceResponseSubscriber()
  3. 11.x core/modules/rest/tests/src/Unit/EventSubscriber/ResourceResponseSubscriberTest.php \Drupal\Tests\rest\Unit\EventSubscriber\ResourceResponseSubscriberTest::getFunctioningResourceResponseSubscriber()

Return value

\Drupal\rest\EventSubscriber\ResourceResponseSubscriber

3 calls to ResourceResponseSubscriberTest::getFunctioningResourceResponseSubscriber()
ResourceResponseSubscriberTest::testOnResponseWithCacheableResponse in core/modules/rest/tests/src/Unit/EventSubscriber/ResourceResponseSubscriberTest.php
@covers ::onResponse @covers ::getResponseFormat @covers ::renderResponseBody @covers ::flattenResponse
ResourceResponseSubscriberTest::testOnResponseWithUncacheableResponse in core/modules/rest/tests/src/Unit/EventSubscriber/ResourceResponseSubscriberTest.php
@covers ::onResponse @covers ::getResponseFormat @covers ::renderResponseBody @covers ::flattenResponse
ResourceResponseSubscriberTest::testSerialization in core/modules/rest/tests/src/Unit/EventSubscriber/ResourceResponseSubscriberTest.php
@covers ::onResponse @dataProvider providerTestSerialization

File

core/modules/rest/tests/src/Unit/EventSubscriber/ResourceResponseSubscriberTest.php, line 387

Class

ResourceResponseSubscriberTest
@coversDefaultClass \Drupal\rest\EventSubscriber\ResourceResponseSubscriber @group rest

Namespace

Drupal\Tests\rest\Unit\EventSubscriber

Code

protected function getFunctioningResourceResponseSubscriber(RouteMatchInterface $route_match) {
    // Create a dummy of the renderer service.
    $renderer = $this->prophesize(RendererInterface::class);
    $renderer->executeInRenderContext(Argument::type(RenderContext::class), Argument::type('callable'))
        ->will(function ($args) {
        $callable = $args[1];
        return $callable();
    });
    // Instantiate the ResourceResponseSubscriber we will test.
    $resource_response_subscriber = new ResourceResponseSubscriber(new Serializer([], [
        new JsonEncoder(),
        new XmlEncoder(),
    ]), $renderer->reveal(), $route_match);
    return $resource_response_subscriber;
}

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