8000 Shift responsibility for keeping Date header to ResponseHeaderBag by mpdude · Pull Request #22124 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

Shift responsibility for keeping Date header to ResponseHeaderBag #22124

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Fix tests
The headers returned now also include the "Date", but adding it to the expected outcome would add additional noise.

So instead I chose to test that only the given headers would remain present, preserving case.

The Cache-Control was not important here, we have other tests covering that aspect.
  • Loading branch information
mpdude committed Jun 16, 2017
commit 32154b14191658cdd32bdf1300ab10fe86c76ba6
Original file line number Diff line number Diff line change
Expand Up @@ -20,48 +20,24 @@
*/
class ResponseHeaderBagTest extends TestCase
{
/**
* @dataProvider provideAllPreserveCase
*/
public function testAllPreserveCase($headers, $expected)
public function testAllPreserveCase()
{
$bag = new ResponseHeaderBag($headers);
$headers = array(
'fOo' => 'BAR',
'ETag' => 'xyzzy',
'Content-MD5' => 'Q2hlY2sgSW50ZWdyaXR5IQ==',
'P3P' => 'CP="CAO PSA OUR"',
'WWW-Authenticate' => 'Basic realm="WallyWorld"',
'X-UA-Compatible' => 'IE=edge,chrome=1',
'X-XSS-Protection' => '1; mode=block',
);

$this->assertEquals($expected, $bag->allPreserveCase(), '->allPreserveCase() gets all input keys in original case');
}
$bag = new ResponseHeaderBag($headers);
$allPreservedCase = $bag->allPreserveCase();

public function provideAllPreserveCase()
{
return array(
array(
array('fOo' => 'BAR'),
array('fOo' => array('BAR'), 'Cache-Control' => array('no-cache, private')),
),
array(
array('ETag' => 'xyzzy'),
array('ETag' => array('xyzzy'), 'Cache-Control' => array('private, must-revalidate')),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Im not sure you can simply remove 8000 the cache-control expectations, perhaps re-add it in a separate test. Which is probably best in the long run.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I am not mistaken, there are other tests for them. In this test method that was only noise AFAICT, but please correct me if I'm wrong

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right 👍 same situation is covered in testCacheControlHeader

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

),
array(
array('Content-MD5' => 'Q2hlY2sgSW50ZWdyaXR5IQ=='),
array('Content-MD5' => array('Q2hlY2sgSW50ZWdyaXR5IQ=='), 'Cache-Control' => array('no-cache, private')),
),
array(
array('P3P' => 'CP="CAO PSA OUR"'),
array('P3P' => array('CP="CAO PSA OUR"'), 'Cache-Control' => array('no-cache, private')),
),
array(
array('WWW-Authenticate' => 'Basic realm="WallyWorld"'),
array('WWW-Authenticate' => array('Basic realm="WallyWorld"'), 'Cache-Control' => array('no-cache, private')),
),
array(
array('X-UA-Compatible' => 'IE=edge,chrome=1'),
array('X-UA-Compatible' => array('IE=edge,chrome=1'), 'Cache-Control' => array('no-cache, private')),
),
array(
array('X-XSS-Protection' => '1; mode=block'),
array('X-XSS-Protection' => array('1; mode=block'), 'Cache-Control' => array('no-cache, private')),
),
);
foreach (array_keys($headers) as $headerName) {
$this->assertArrayHasKey($headerName, $allPreservedCase, '->allPreserveCase() gets all input keys in original case');
}
}

public function testCacheControlHeader()
Expand Down
0