bug #27937 [HttpFoundation] reset callback on StreamedResponse when setNotModified() is called (rubencm)
This PR was merged into the 2.8 branch.
Discussion
----------
[HttpFoundation] reset callback on StreamedResponse when setNotModified() is called
| Q | A
| ------------- | ---
| Branch? | 2.8
| Bug fix? | yes
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | #27924
| License | MIT
| Doc PR | No
Commits
-------
51a49c7f78
[HttpFoundation] reset callback on StreamedResponse when setNotModified() is called
This commit is contained in:
commit
f80376217d
@ -134,4 +134,16 @@ class StreamedResponse extends Response
|
|||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setNotModified()
|
||||||
|
{
|
||||||
|
$this->setCallback(function () {});
|
||||||
|
|
||||||
|
return parent::setNotModified();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -126,7 +126,7 @@ class ResponseTest extends ResponseTestCase
|
|||||||
|
|
||||||
public function testSetNotModified()
|
public function testSetNotModified()
|
||||||
{
|
{
|
||||||
$response = new Response();
|
$response = new Response('foo');
|
||||||
$modified = $response->setNotModified();
|
$modified = $response->setNotModified();
|
||||||
$this->assertObjectHasAttribute('headers', $modified);
|
$this->assertObjectHasAttribute('headers', $modified);
|
||||||
$this->assertObjectHasAttribute('content', $modified);
|
$this->assertObjectHasAttribute('content', $modified);
|
||||||
@ -135,6 +135,11 @@ class ResponseTest extends ResponseTestCase
|
|||||||
$this->assertObjectHasAttribute('statusText', $modified);
|
$this->assertObjectHasAttribute('statusText', $modified);
|
||||||
$this->assertObjectHasAttribute('charset', $modified);
|
$this->assertObjectHasAttribute('charset', $modified);
|
||||||
$this->assertEquals(304, $modified->getStatusCode());
|
$this->assertEquals(304, $modified->getStatusCode());
|
||||||
|
|
||||||
|
ob_start();
|
||||||
|
$modified->sendContent();
|
||||||
|
$string = ob_get_clean();
|
||||||
|
$this->assertEmpty($string);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testIsSuccessful()
|
public function testIsSuccessful()
|
||||||
|
@ -132,4 +132,22 @@ class StreamedResponseTest extends TestCase
|
|||||||
$this->assertInstanceOf('Symfony\Component\HttpFoundation\StreamedResponse', $response->sendHeaders());
|
$this->assertInstanceOf('Symfony\Component\HttpFoundation\StreamedResponse', $response->sendHeaders());
|
||||||
$this->assertInstanceOf('Symfony\Component\HttpFoundation\StreamedResponse', $response->sendHeaders());
|
$this->assertInstanceOf('Symfony\Component\HttpFoundation\StreamedResponse', $response->sendHeaders());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testSetNotModified()
|
||||||
|
{
|
||||||
|
$response = new StreamedResponse(function () { echo 'foo'; });
|
||||||
|
$modified = $response->setNotModified();
|
||||||
|
$this->assertObjectHasAttribute('headers', $modified);
|
||||||
|
$this->assertObjectHasAttribute('content', $modified);
|
||||||
|
$this->assertObjectHasAttribute('version', $modified);
|
||||||
|
$this->assertObjectHasAttribute('statusCode', $modified);
|
||||||
|
$this->assertObjectHasAttribute('statusText', $modified);
|
||||||
|
$this->assertObjectHasAttribute('charset', $modified);
|
||||||
|
$this->assertEquals(304, $modified->getStatusCode());
|
||||||
|
|
||||||
|
ob_start();
|
||||||
|
$modified->sendContent();
|
||||||
|
$string = ob_get_clean();
|
||||||
|
$this->assertEmpty($string);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user