8000 [HttpFoundation] fixed some volatile tests by fabpot · Pull Request #11966 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[HttpFoundation] fixed some volatile tests #11966

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

Merged
merged 3 commits into from
Sep 21, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
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
11 changes: 6 additions & 5 deletions src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,9 @@ public function testIsValidateable()

public function testGetDate()
{
$response = new Response('', 200, array('Date' => $this->createDateTimeOneHourAgo()->format(DATE_RFC2822)));
$this->assertEquals(0, $this->createDateTimeOneHourAgo()->diff($response->getDate())->format('%s'), '->getDate() returns the Date header if present');
$oneHourAgo = $this->createDateTimeOneHourAgo();
$response = new Response('', 200, array('Date' => $oneHourAgo->format(DATE_RFC2822)));
$this->assertEquals(0, $oneHourAgo->diff($response->getDate())->format('%s'), '->getDate() returns the Date header if present');

$response = new Response();
$date = $response->getDate();
Expand All @@ -142,7 +143,7 @@ public function testGetDate()
$response = new Response('', 200, array('Date' => $this->createDateTimeOneHourAgo()->format(DATE_RFC2822)));
$now = $this->createDateTimeNow();
$response->headers->set('Date', $now->format(DATE_RFC2822));
$this->assertEquals(0, $now->diff($response->getDate())->format('%s'), '->getDate() returns the date when the header has been modified');
$th 8000 is->assertLessThanOrEqual(1, $now->diff($response->getDate())->format('%s'), '->getDate() returns the date when the header has been modified');

$response = new Response('', 200);
$response->headers->remove('Date');
Expand All @@ -162,7 +163,7 @@ public function testGetMaxAge()
$response = new Response();
$response->headers->set('Cache-Control', 'must-revalidate');
$response->headers->set('Expires', $this->createDateTimeOneHourLater()->format(DATE_RFC2822));
$this->assertEquals(3600, $response->getMaxAge(), '->getMaxAge() falls back to Expires when no max-age or s-maxage directive present');
$this->assertLessThanOrEqual(1, $response->getMaxAge() - 3600, '->getMaxAge() falls back to Expires when no max-age or s-maxage directive present');

$response = new Response();
$response->headers->set('Cache-Control', 'must-revalidate');
Expand Down Expand Up @@ -233,7 +234,7 @@ public function testGetTtl()

$response = new Response();
$response->headers->set('Expires', $this->createDateTimeOneHourLater()->format(DATE_RFC2822));
$this->assertLessThan(1, 3600 - $response->getTtl(), '->getTtl() uses the Expires header when no max-age is present');
$this->assertLessThanOrEqual(1, 3600 - $response->getTtl(), '->getTtl() uses the Expires header when no max-age is present');

$response = new Response();
$response->headers->set('Expires', $this->createDateTimeOneHourAgo()->format(DATE_RFC2822));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,7 @@ public function testAssignsDefaultTtlWhenResponseHasNoFreshnessInformationAndAft
$this->assertTraceContains('miss');
$this->assertTraceContains('store');
$this->assertEquals('Hello World', $this->response->getContent());
$this->assertRegExp('/s-maxage=2/', $this->response->headers->get('Cache-Control'));
$this->assertRegExp('/s-maxage=(?:2|3)/', $this->response->headers->get('Cache-Control'));

$this->request('GET', '/');
$this->assertHttpKernelIsNotCalled();
Expand Down
5 changes: 2 additions & 3 deletions src/Symfony/Component/Process/Tests/AbstractProcessTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,8 @@ public function testStopWithTimeoutIsActuallyWorking()
while ($p->isRunning()) {
usleep(1000);
}
$duration = microtime(true) - $start;

$this->assertLessThan(1.8, $duration);
$this->assertLessThan(4, microtime(true) - $start);
}

public function testAllOutputIsActuallyReadOnTermination()
Expand Down Expand Up @@ -396,7 +395,7 @@ public function testStartIsNonBlocking()
$start = microtime(true);
$process->start();
$end = microtime(true);
$this->assertLessThan(0.2, $end-$start);
$this->assertLessThan(1, $end - $start);
$process->wait();
}

Expand Down
0