namespace Symfony\Component\HttpKernel\Tests\Profiler;
use PHPUnit\Framework\TestCase;
+use Symfony\Component\HttpKernel\DataCollector\DataCollectorInterface;
use Symfony\Component\HttpKernel\DataCollector\RequestDataCollector;
use Symfony\Component\HttpKernel\Profiler\FileProfilerStorage;
use Symfony\Component\HttpKernel\Profiler\Profiler;
$profiler = new Profiler($this->storage);
$profiler->add($collector);
$profile = $profiler->collect($request, $response);
+ $profiler->saveProfile($profile);
$this->assertSame(204, $profile->getStatusCode());
$this->assertSame('GET', $profile->getMethod());
- $this->assertEquals(array('foo' => 'bar'), $profiler->get('request')->getRequestQuery()->all());
+ $this->assertSame('bar', $profile->getCollector('request')->getRequestQuery()->all()['foo']->getValue());
+ }
+
+ public function testReset()
+ {
+ $collector = $this->getMockBuilder(DataCollectorInterface::class)
+ ->setMethods(array('collect', 'getName', 'reset'))
+ ->getMock();
+ $collector->expects($this->any())->method('getName')->willReturn('mock');
+ $collector->expects($this->once())->method('reset');
+
+ $profiler = new Profiler($this->storage);
+ $profiler->add($collector);
+ $profiler->reset();
}
public function testFindWorksWithDates()
$this->assertCount(0, $profiler->find(null, null, null, null, 'some string', ''));
}
+ public function testFindWorksWithStatusCode()
+ {
+ $profiler = new Profiler($this->storage);
+
+ $this->assertCount(0, $profiler->find(null, null, null, null, null, null, '204'));
+ }
+
protected function setUp()
{
$this->tmp = tempnam(sys_get_temp_dir(), 'sf2_profiler');