aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorFred Emmott <fe@fb.com>2014-09-29 13:03:32 -0700
committerFred Emmott <fe@fb.com>2014-09-30 15:53:02 -0700
commitf30c5f730e0ae68d4090da781a41e081c8e0c28f (patch)
treec9793514b63a4f7bd761ab42a20ed808cedb1535 /tests
parent6f093ade8a025039c04e88c473e619153656c6a7 (diff)
downloadforums-f30c5f730e0ae68d4090da781a41e081c8e0c28f.tar
forums-f30c5f730e0ae68d4090da781a41e081c8e0c28f.tar.gz
forums-f30c5f730e0ae68d4090da781a41e081c8e0c28f.tar.bz2
forums-f30c5f730e0ae68d4090da781a41e081c8e0c28f.tar.xz
forums-f30c5f730e0ae68d4090da781a41e081c8e0c28f.zip
[ticket/13122] Make phpbb_wrapper_gmgetdate_test more reliable
If you're unlucky, calling time() or similar twice in a row will give you different results. Facebook runs these tests thousands of times a day, so we occasionally get bogus failures. PHPBB3-13122
Diffstat (limited to 'tests')
-rw-r--r--tests/wrapper/gmgetdate_test.php13
1 files changed, 12 insertions, 1 deletions
diff --git a/tests/wrapper/gmgetdate_test.php b/tests/wrapper/gmgetdate_test.php
index dc0e38544d..2e55a78d21 100644
--- a/tests/wrapper/gmgetdate_test.php
+++ b/tests/wrapper/gmgetdate_test.php
@@ -50,7 +50,18 @@ class phpbb_wrapper_gmgetdate_test extends phpbb_test_case
$date_array['year']
);
- $this->assertEquals($expected, $actual);
+ // Calling second-granularity time functions twice isn't guaranteed to
+ // give the same results. As long as they're in the right order, allow
+ // a 1 second difference.
+ $this->assertGreaterThanOrEqual(
+ $expected, $actual,
+ 'Expected second time to be after (or equal to) the previous one'
+ );
+ $this->assertLessThanOrEqual(
+ 1,
+ abs($actual - $expected),
+ "Expected $actual to be within 1 second of $expected."
+ );
if (isset($current_timezone))
{