Timing: Fix flaky TimingTest test
authorTimo Tijhof <krinklemail@gmail.com>
Thu, 18 Feb 2016 21:06:04 +0000 (21:06 +0000)
committerTimo Tijhof <krinklemail@gmail.com>
Thu, 18 Feb 2016 21:06:34 +0000 (21:06 +0000)
> 1) TimingTest::testMark
> Failed asserting that 1455828402.4503 is greater than 1455828402.4503.

Use usleep(100), similar to the other tests already there.

Change-Id: Ic45c99b7e928df397809d872ab8e41ada6ecf1e7

tests/phpunit/includes/libs/TimingTest.php

index aa60101..4d71944 100644 (file)
@@ -55,6 +55,7 @@ class TimingTest extends PHPUnit_Framework_TestCase {
                $this->assertArrayHasKey( 'startTime', $entry );
                $this->assertEquals( 0, $entry['duration'] );
 
+               usleep( 100 );
                $timing->mark( 'a' );
                $newEntry = $timing->getEntryByName( 'a' );
                $this->assertGreaterThan( $entry['startTime'], $newEntry['startTime'] );
@@ -67,9 +68,10 @@ class TimingTest extends PHPUnit_Framework_TestCase {
                $timing = new Timing;
 
                $timing->mark( 'a' );
-               $a = $timing->getEntryByName( 'a' );
-
+               usleep( 100 );
                $timing->mark( 'b' );
+
+               $a = $timing->getEntryByName( 'a' );
                $b = $timing->getEntryByName( 'b' );
 
                $timing->measure( 'a_to_b', 'a', 'b' );