Skip to content

Commit

Permalink
Use REQUEST_TIME_FLOAT if available.
Browse files Browse the repository at this point in the history
This will give a more correct initialization time when using the
DataCollectors without a KernelInterface implementation such as Silex.
  • Loading branch information
henrikbjorn authored and fabpot committed Apr 23, 2013
1 parent 7a63538 commit a1e5c6d
Showing 1 changed file with 15 additions and 1 deletion.
Expand Up @@ -24,7 +24,7 @@ protected function setUp()
}
}

public function testCollectWithoutKernel()
public function testCollect()
{
$c = new TimeDataCollector;

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

$this->assertEquals(2000, $c->getStartTime());

$request = new Request();
$c->collect($request, new Response);
$this->assertEquals(0, $c->getStartTime());

$kernel = $this->getMock('Symfony\Component\HttpKernel\KernelInterface');
$kernel->expects($this->once())->method('getStartTime')->will($this->returnValue(123456));

$c = new TimeDataCollector($kernel);
$request = new Request();
$request->server->set('REQUEST_TIME', 1);

$c->collect($request, new Response());
$this->assertEquals(123456000, $c->getStartTime());
}

}

0 comments on commit a1e5c6d

Please sign in to comment.