function PsrResponseSubscriberTest::testConvertsNonSeekableBodyWithStreaming
Same name and namespace in other branches
- main core/tests/Drupal/Tests/Core/EventSubscriber/PsrResponseSubscriberTest.php \Drupal\Tests\Core\EventSubscriber\PsrResponseSubscriberTest::testConvertsNonSeekableBodyWithStreaming()
Tests that a non-seekable body results in a streamed response.
@legacy-covers ::onKernelView
File
-
core/
tests/ Drupal/ Tests/ Core/ EventSubscriber/ PsrResponseSubscriberTest.php, line 104
Class
Namespace
Drupal\Tests\Core\EventSubscriberCode
public function testConvertsNonSeekableBodyWithStreaming() : void {
$body = $this->createStub(StreamInterface::class);
$body->method('isSeekable')
->willReturn(FALSE);
$psr_response = $this->createStub(ResponseInterface::class);
$psr_response->method('getBody')
->willReturn($body);
$factory = $this->createMock(HttpFoundationFactoryInterface::class);
$factory->expects($this->once())
->method('createResponse')
->with($psr_response, TRUE)
->willReturn($this->createStub(StreamedResponse::class));
$subscriber = new PsrResponseSubscriber($factory);
$event = $this->createEvent($psr_response);
$subscriber->onKernelView($event);
$this->assertInstanceOf(StreamedResponse::class, $event->getResponse());
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.