From a80cb35e512cab0d32636156d5c27ab46cd1f101 Mon Sep 17 00:00:00 2001 From: Possum Date: Thu, 29 Jan 2015 14:08:50 +0100 Subject: [PATCH] Fix time sensitive profiler test (ready) --- test/Twig/Tests/Profiler/Dumper/AbstractTest.php | 7 ++++--- test/Twig/Tests/Profiler/Dumper/HtmlTest.php | 2 +- test/Twig/Tests/Profiler/Dumper/TextTest.php | 2 +- test/Twig/Tests/Profiler/ProfileTest.php | 3 ++- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/test/Twig/Tests/Profiler/Dumper/AbstractTest.php b/test/Twig/Tests/Profiler/Dumper/AbstractTest.php index 9020d3f39..555a5e744 100644 --- a/test/Twig/Tests/Profiler/Dumper/AbstractTest.php +++ b/test/Twig/Tests/Profiler/Dumper/AbstractTest.php @@ -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; } } diff --git a/test/Twig/Tests/Profiler/Dumper/HtmlTest.php b/test/Twig/Tests/Profiler/Dumper/HtmlTest.php index 1593a031c..66a68c4be 100644 --- a/test/Twig/Tests/Profiler/Dumper/HtmlTest.php +++ b/test/Twig/Tests/Profiler/Dumper/HtmlTest.php @@ -15,7 +15,7 @@ class Twig_Tests_Profiler_Dumper_HtmlTest extends Twig_Tests_Profiler_Dumper_Abs { $dumper = new Twig_Profiler_Dumper_Html(); $this->assertStringMatchesFormat(<<main +
main %d.%dms/%d%index.twig %d.%dms/%d%
   └ embedded.twig::block(body)
   └ embedded.twig
diff --git a/test/Twig/Tests/Profiler/Dumper/TextTest.php b/test/Twig/Tests/Profiler/Dumper/TextTest.php
index 2fac9a718..e2ea165ac 100644
--- a/test/Twig/Tests/Profiler/Dumper/TextTest.php
+++ b/test/Twig/Tests/Profiler/Dumper/TextTest.php
@@ -15,7 +15,7 @@ class Twig_Tests_Profiler_Dumper_TextTest extends Twig_Tests_Profiler_Dumper_Abs
     {
         $dumper = new Twig_Profiler_Dumper_Text();
         $this->assertStringMatchesFormat(<<leave();
 
-        $this->assertTrue($profile->getDuration() > 0);
+        $this->assertTrue($profile->getDuration() > 0, sprintf('Expected duration > 0, got: %f', $profile->getDuration()));
     }
 
     public function testSerialize()