mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-15 11:56:50 +00:00
Fix time sensitive profiler test (ready)
This commit is contained in:
@@ -32,13 +32,14 @@ abstract class Twig_Tests_Profiler_Dumper_AbstractTest extends PHPUnit_Framework
|
|||||||
|
|
||||||
$embedded = clone $embedded;
|
$embedded = clone $embedded;
|
||||||
$index->addProfile($embedded);
|
$index->addProfile($embedded);
|
||||||
$a = range(1, 1000);
|
usleep(500);
|
||||||
$embedded->leave();
|
$embedded->leave();
|
||||||
$profile->leave();
|
|
||||||
|
|
||||||
usleep(5000);
|
usleep(4500);
|
||||||
$index->leave();
|
$index->leave();
|
||||||
|
|
||||||
|
$profile->leave();
|
||||||
|
|
||||||
return $profile;
|
return $profile;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ class Twig_Tests_Profiler_Dumper_HtmlTest extends Twig_Tests_Profiler_Dumper_Abs
|
|||||||
{
|
{
|
||||||
$dumper = new Twig_Profiler_Dumper_Html();
|
$dumper = new Twig_Profiler_Dumper_Html();
|
||||||
$this->assertStringMatchesFormat(<<<EOF
|
$this->assertStringMatchesFormat(<<<EOF
|
||||||
<pre>main
|
<pre>main <span style="color: #d44">%d.%dms/%d%</span>
|
||||||
└ <span style="background-color: #ffd">index.twig</span> <span style="color: #d44">%d.%dms/%d%</span>
|
└ <span style="background-color: #ffd">index.twig</span> <span style="color: #d44">%d.%dms/%d%</span>
|
||||||
└ embedded.twig::block(<span style="background-color: #dfd">body</span>)
|
└ embedded.twig::block(<span style="background-color: #dfd">body</span>)
|
||||||
└ <span style="background-color: #ffd">embedded.twig</span>
|
└ <span style="background-color: #ffd">embedded.twig</span>
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ class Twig_Tests_Profiler_Dumper_TextTest extends Twig_Tests_Profiler_Dumper_Abs
|
|||||||
{
|
{
|
||||||
$dumper = new Twig_Profiler_Dumper_Text();
|
$dumper = new Twig_Profiler_Dumper_Text();
|
||||||
$this->assertStringMatchesFormat(<<<EOF
|
$this->assertStringMatchesFormat(<<<EOF
|
||||||
main
|
main %d.%dms/%d%
|
||||||
└ index.twig %d.%dms/%d%
|
└ index.twig %d.%dms/%d%
|
||||||
└ embedded.twig::block(body)
|
└ embedded.twig::block(body)
|
||||||
└ embedded.twig
|
└ embedded.twig
|
||||||
|
|||||||
@@ -69,9 +69,10 @@ class Twig_Tests_Profiler_ProfileTest extends PHPUnit_Framework_TestCase
|
|||||||
public function testGetDuration()
|
public function testGetDuration()
|
||||||
{
|
{
|
||||||
$profile = new Twig_Profiler_Profile();
|
$profile = new Twig_Profiler_Profile();
|
||||||
|
usleep(1);
|
||||||
$profile->leave();
|
$profile->leave();
|
||||||
|
|
||||||
$this->assertTrue($profile->getDuration() > 0);
|
$this->assertTrue($profile->getDuration() > 0, sprintf('Expected duration > 0, got: %f', $profile->getDuration()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSerialize()
|
public function testSerialize()
|
||||||
|
|||||||
Reference in New Issue
Block a user