You are here

public function AbstractProfilerStorageTest::testStoreTime in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/http-kernel/Tests/Profiler/AbstractProfilerStorageTest.php \Symfony\Component\HttpKernel\Tests\Profiler\AbstractProfilerStorageTest::testStoreTime()

File

vendor/symfony/http-kernel/Tests/Profiler/AbstractProfilerStorageTest.php, line 157

Class

AbstractProfilerStorageTest

Namespace

Symfony\Component\HttpKernel\Tests\Profiler

Code

public function testStoreTime() {
  $dt = new \DateTime('now');
  $start = $dt
    ->getTimestamp();
  for ($i = 0; $i < 3; ++$i) {
    $dt
      ->modify('+1 minute');
    $profile = new Profile('time_' . $i);
    $profile
      ->setIp('127.0.0.1');
    $profile
      ->setUrl('http://foo.bar');
    $profile
      ->setTime($dt
      ->getTimestamp());
    $profile
      ->setMethod('GET');
    $this
      ->getStorage()
      ->write($profile);
  }
  $records = $this
    ->getStorage()
    ->find('', '', 3, 'GET', $start, time() + 3 * 60);
  $this
    ->assertCount(3, $records, '->find() returns all previously added records');
  $this
    ->assertEquals($records[0]['token'], 'time_2', '->find() returns records ordered by time in descendant order');
  $this
    ->assertEquals($records[1]['token'], 'time_1', '->find() returns records ordered by time in descendant order');
  $this
    ->assertEquals($records[2]['token'], 'time_0', '->find() returns records ordered by time in descendant order');
  $records = $this
    ->getStorage()
    ->find('', '', 3, 'GET', $start, time() + 2 * 60);
  $this
    ->assertCount(2, $records, '->find() should return only first two of the previously added records');
}