mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-12 10:26:32 +00:00
feature #2560 Added pssibility to reset the profiler (derrabus)
This PR was merged into the 1.x branch.
Discussion
----------
Added pssibility to reset the profiler
In order to implement symfony/symfony#18244 properly, I needed the ability to reset a Twig profile.
Commits
-------
ea922bb6 Added pssibility to reset the profiler.
This commit is contained in:
@@ -145,6 +145,12 @@ class Twig_Profiler_Profile implements IteratorAggregate, Serializable
|
||||
);
|
||||
}
|
||||
|
||||
public function reset()
|
||||
{
|
||||
$this->starts = $this->ends = $this->profiles = array();
|
||||
$this->enter();
|
||||
}
|
||||
|
||||
public function getIterator()
|
||||
{
|
||||
return new ArrayIterator($this->profiles);
|
||||
|
||||
@@ -97,4 +97,14 @@ class Twig_Tests_Profiler_ProfileTest extends \PHPUnit\Framework\TestCase
|
||||
$this->assertEquals($profile1->getType(), $profile3->getType());
|
||||
$this->assertEquals($profile1->getName(), $profile3->getName());
|
||||
}
|
||||
|
||||
public function testReset()
|
||||
{
|
||||
$profile = new Twig_Profiler_Profile();
|
||||
usleep(1);
|
||||
$profile->leave();
|
||||
$profile->reset();
|
||||
|
||||
$this->assertEquals(0, $profile->getDuration());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user