Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use REQUEST_TIME_FLOAT if available.
This will give a more correct initialization time when using the DataCollectors without a KernelInterface implementation such as Silex.
- Loading branch information
1 parent
223cc6f
commit bd0709c
Showing
2 changed files
with
50 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
src/Symfony/Component/HttpKernel/Tests/DataCollector/TimeDataCollectorTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <fabien@symfony.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\Component\HttpKernel\Tests\DataCollector; | ||
|
||
use Symfony\Component\HttpKernel\DataCollector\TimeDataCollector; | ||
use Symfony\Component\HttpFoundation\Request; | ||
use Symfony\Component\HttpFoundation\Response; | ||
|
||
class TimeDataCollectorTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
protected function setUp() | ||
{ | ||
if (!class_exists('Symfony\Component\HttpFoundation\Request')) { | ||
$this->markTestSkipped('The "HttpFoundation" component is not available'); | ||
} | ||
} | ||
|
||
public function testCollectWithoutKernel() | ||
{ | ||
$c = new TimeDataCollector; | ||
|
||
$request = new Request(); | ||
$request->server->set('REQUEST_TIME', 1); | ||
|
||
$c->collect($request, new Response()); | ||
|
||
$this->assertEquals(1000, $c->getStartTime()); | ||
|
||
$request->server->set('REQUEST_TIME_FLOAT', 2); | ||
|
||
$c->collect($request, new Response()); | ||
|
||
$this->assertEquals(2000, $c->getStartTime()); | ||
} | ||
|
||
} |