Skip to content

Commit

Permalink
Fix time sensitive profiler test (ready)
Browse files Browse the repository at this point in the history
  • Loading branch information
SpacePossum authored and fabpot committed Feb 16, 2015
1 parent 5a5a640 commit a80cb35
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
7 changes: 4 additions & 3 deletions test/Twig/Tests/Profiler/Dumper/AbstractTest.php
Expand Up @@ -32,13 +32,14 @@ protected function getProfile()

$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;
}
}
2 changes: 1 addition & 1 deletion test/Twig/Tests/Profiler/Dumper/HtmlTest.php
Expand Up @@ -15,7 +15,7 @@ public function testDump()
{
$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>
Expand Down
2 changes: 1 addition & 1 deletion test/Twig/Tests/Profiler/Dumper/TextTest.php
Expand Up @@ -15,7 +15,7 @@ public function testDump()
{
$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
Expand Down
3 changes: 2 additions & 1 deletion test/Twig/Tests/Profiler/ProfileTest.php
Expand Up @@ -69,9 +69,10 @@ public function testGetAddProfile()
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()
Expand Down

0 comments on commit a80cb35

Please sign in to comment.