예제 #1
0
    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);
    }
예제 #2
0
 /**
  * Gets the Collectors ordered by priority.
  *
  * @return array An array of collectors
  */
 public function all()
 {
     arsort($this->order);
     $collectors = [];
     foreach ($this->order as $name => $priority) {
         $collectors[$name] = parent::get($name);
     }
     return $collectors;
 }
예제 #3
0
 public function testCollect()
 {
     $request = new Request();
     $request->query->set('foo', 'bar');
     $response = new Response();
     $collector = new RequestDataCollector();
     $profiler = new Profiler($this->storage);
     $profiler->add($collector);
     $profile = $profiler->collect($request, $response);
     $profile = $profiler->loadProfile($profile->getToken());
     $this->assertEquals(array('foo' => 'bar'), $profiler->get('request')->getRequestQuery()->all());
 }
예제 #4
0
 public function testCollect()
 {
     $request = new Request();
     $request->query->set('foo', 'bar');
     $response = new Response('', 204);
     $collector = new RequestDataCollector();
     $profiler = new Profiler($this->storage);
     $profiler->add($collector);
     $profile = $profiler->collect($request, $response);
     $this->assertSame(204, $profile->getStatusCode());
     $this->assertSame('GET', $profile->getMethod());
     $this->assertEquals(array('foo' => 'bar'), $profiler->get('request')->getRequestQuery()->all());
 }
예제 #5
0
 public function testCollect()
 {
     $request = new Request();
     $request->query->set('foo', 'bar');
     $response = new Response();
     $collector = new RequestDataCollector();
     $storage = new SQLiteProfilerStorage(sys_get_temp_dir() . '/sf2_profiler.db');
     $storage->purge(true);
     $profiler = new Profiler($storage);
     $profiler->add($collector);
     $profiler->setToken('foobar');
     $profiler->collect($request, $response);
     $profiler = new Profiler($storage);
     $profiler->setToken('foobar');
     $this->assertEquals(array('foo' => 'bar'), $profiler->get('request')->getRequestQuery()->all());
 }
예제 #6
0
 public function testCollect()
 {
     $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);
 }