public function ProfilerTest::testCollect

File

drupal/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Profiler/ProfilerTest.php, line 29

Class

ProfilerTest

Namespace

Symfony\Component\HttpKernel\Tests\Profiler

Code

public function testCollect() {
  if (!class_exists('SQLite3') && (!class_exists('PDO') || !in_array('sqlite', \PDO::getAvailableDrivers()))) {
    $this
      ->markTestSkipped('This test requires SQLite support in your environment');
  }
  $request = new Request();
  $request->query
    ->set('foo', 'bar');
  $response = new Response();
  $collector = new RequestDataCollector();
  $tmp = tempnam(sys_get_temp_dir(), 'sf2_profiler');
  if (file_exists($tmp)) {
    @unlink($tmp);
  }
  $storage = new SqliteProfilerStorage('sqlite:' . $tmp);
  $storage
    ->purge();
  $profiler = new Profiler($storage);
  $profiler
    ->add($collector);
  $profile = $profiler
    ->collect($request, $response);
  $profile = $profiler
    ->loadProfile($profile
    ->getToken());
  $this
    ->assertEquals(array(
    'foo' => 'bar',
  ), $profiler
    ->get('request')
    ->getRequestQuery()
    ->all());
  @unlink($tmp);
}