You are here

public function MongoDbProfilerStorageTest::testCleanup in Zircon Profile 8.0

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

File

vendor/symfony/http-kernel/Tests/Profiler/MongoDbProfilerStorageTest.php, line 100

Class

MongoDbProfilerStorageTest

Namespace

Symfony\Component\HttpKernel\Tests\Profiler

Code

public function testCleanup() {
  $dt = new \DateTime('-2 day');
  for ($i = 0; $i < 3; ++$i) {
    $dt
      ->modify('-1 day');
    $profile = new Profile('time_' . $i);
    $profile
      ->setTime($dt
      ->getTimestamp());
    $profile
      ->setMethod('GET');
    self::$storage
      ->write($profile);
  }
  $records = self::$storage
    ->find('', '', 3, 'GET');
  $this
    ->assertCount(1, $records, '->find() returns only one record');
  $this
    ->assertEquals($records[0]['token'], 'time_2', '->find() returns the latest added record');
  self::$storage
    ->purge();
}