Fix time sensitive profiler test (ready)

This commit is contained in:
Possum
2015-01-29 14:08:50 +01:00
committed by Fabien Potencier
parent 5a5a640cbc
commit a80cb35e51
4 changed files with 8 additions and 6 deletions
@@ -32,13 +32,14 @@ abstract class Twig_Tests_Profiler_Dumper_AbstractTest extends PHPUnit_Framework
$embedded = clone $embedded;
$index->addProfile($embedded);
$a = range(1, 1000);
usleep(500);
$embedded->leave();
$profile->leave();
usleep(5000);
usleep(4500);
$index->leave();
$profile->leave();
return $profile;
}
}
+1 -1
View File
@@ -15,7 +15,7 @@ class Twig_Tests_Profiler_Dumper_HtmlTest extends Twig_Tests_Profiler_Dumper_Abs
{
$dumper = new Twig_Profiler_Dumper_Html();
$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>
└ embedded.twig::block(<span style="background-color: #dfd">body</span>)
└ <span style="background-color: #ffd">embedded.twig</span>
+1 -1
View File
@@ -15,7 +15,7 @@ class Twig_Tests_Profiler_Dumper_TextTest extends Twig_Tests_Profiler_Dumper_Abs
{
$dumper = new Twig_Profiler_Dumper_Text();
$this->assertStringMatchesFormat(<<<EOF
main
main %d.%dms/%d%
└ index.twig %d.%dms/%d%
└ embedded.twig::block(body)
└ embedded.twig
+2 -1
View File
@@ -69,9 +69,10 @@ class Twig_Tests_Profiler_ProfileTest extends PHPUnit_Framework_TestCase
public function testGetDuration()
{
$profile = new Twig_Profiler_Profile();
usleep(1);
$profile->leave();
$this->assertTrue($profile->getDuration() > 0);
$this->assertTrue($profile->getDuration() > 0, sprintf('Expected duration > 0, got: %f', $profile->getDuration()));
}
public function testSerialize()