No Description

TimeDataCollectorTest.php 1.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\HttpKernel\Tests\DataCollector;
  11. use Symfony\Component\HttpKernel\DataCollector\TimeDataCollector;
  12. use Symfony\Component\HttpFoundation\Request;
  13. use Symfony\Component\HttpFoundation\Response;
  14. /**
  15. * @group time-sensitive
  16. */
  17. class TimeDataCollectorTest extends \PHPUnit_Framework_TestCase
  18. {
  19. public function testCollect()
  20. {
  21. $c = new TimeDataCollector();
  22. $request = new Request();
  23. $request->server->set('REQUEST_TIME', 1);
  24. $c->collect($request, new Response());
  25. $this->assertEquals(1000, $c->getStartTime());
  26. $request->server->set('REQUEST_TIME_FLOAT', 2);
  27. $c->collect($request, new Response());
  28. $this->assertEquals(2000, $c->getStartTime());
  29. $request = new Request();
  30. $c->collect($request, new Response());
  31. $this->assertEquals(0, $c->getStartTime());
  32. $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\KernelInterface')->getMock();
  33. $kernel->expects($this->once())->method('getStartTime')->will($this->returnValue(123456));
  34. $c = new TimeDataCollector($kernel);
  35. $request = new Request();
  36. $request->server->set('REQUEST_TIME', 1);
  37. $c->collect($request, new Response());
  38. $this->assertEquals(123456000, $c->getStartTime());
  39. }
  40. }