Skip to content

Commit 8ddc35c

Browse files
henrikbjornfabpot
authored andcommitted
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.
1 parent a7ffc01 commit 8ddc35c

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

Tests/DataCollector/TimeDataCollectorTest.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ protected function setUp()
2424
}
2525
}
2626

27-
public function testCollectWithoutKernel()
27+
public function testCollect()
2828
{
2929
$c = new TimeDataCollector;
3030

@@ -40,6 +40,20 @@ public function testCollectWithoutKernel()
4040
$c->collect($request, new Response());
4141

4242
$this->assertEquals(2000, $c->getStartTime());
43+
44+
$request = new Request();
45+
$c->collect($request, new Response);
46+
$this->assertEquals(0, $c->getStartTime());
47+
48+
$kernel = $this->getMock('Symfony\Component\HttpKernel\KernelInterface');
49+
$kernel->expects($this->once())->method('getStartTime')->will($this->returnValue(123456));
50+
51+
$c = new TimeDataCollector($kernel);
52+
$request = new Request();
53+
$request->server->set('REQUEST_TIME', 1);
54+
55+
$c->collect($request, new Response());
56+
$this->assertEquals(123456000, $c->getStartTime());
4357
}
4458

4559
}

0 commit comments

Comments
 (0)