ProfilerTest.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien.potencier@symfony-project.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\Tests\Component\HttpKernel\Profiler;
  11. use Symfony\Component\HttpKernel\DataCollector\RequestDataCollector;
  12. use Symfony\Component\HttpKernel\Profiler\SQLiteProfilerStorage;
  13. use Symfony\Component\HttpKernel\Profiler\Profiler;
  14. use Symfony\Component\HttpFoundation\Request;
  15. use Symfony\Component\HttpFoundation\Response;
  16. class ProfilerTest extends \PHPUnit_Framework_TestCase
  17. {
  18. public function testCollect()
  19. {
  20. $request = new Request();
  21. $request->query->set('foo', 'bar');
  22. $response = new Response();
  23. $collector = new RequestDataCollector();
  24. $storage = new SQLiteProfilerStorage(sys_get_temp_dir().'/sf2_profiler.db');
  25. $storage->purge(true);
  26. $profiler = new Profiler($storage);
  27. $profiler->add($collector);
  28. $profiler->setToken('foobar');
  29. $profiler->collect($request, $response);
  30. $profiler = new Profiler($storage);
  31. $profiler->setToken('foobar');
  32. $this->assertEquals(array('foo' => 'bar'), $profiler->get('request')->getRequestQuery()->all());
  33. }
  34. }