Make testBug26425BlockTimestampDefaultsToTime be tolerrant of up to 2 seconds
authorBrian Wolff <bawolff@users.mediawiki.org>
Thu, 18 Aug 2011 06:23:44 +0000 (06:23 +0000)
committerBrian Wolff <bawolff@users.mediawiki.org>
Thu, 18 Aug 2011 06:23:44 +0000 (06:23 +0000)
difference.

Otherwise if the test happens to be run on a second barrier, it could
falsely fail (like it did just now when codur said some hurtful things
about my code failing unit-tests where it really didn't ;)

Some of the other block tests seem to itermitantly fail for no appearent
reason (null comes back instead of the block)... I don't know why.

tests/phpunit/includes/BlockTest.php

index 8d90445..a5ec6c9 100644 (file)
@@ -75,8 +75,9 @@ class BlockTest extends MediaWikiLangTestCase {
         * per bug 26425
         */
        function testBug26425BlockTimestampDefaultsToTime() {
-
-               $this->assertEquals( $this->madeAt, $this->block->mTimestamp, "If no timestamp is specified, the block is recorded as time()");
+               // delta to stop one-off errors when things happen to go over a second mark.
+               $delta = abs( $this->madeAt - $this->block->mTimestamp );
+               $this->assertLessThan( 2, $delta, "If no timestamp is specified, the block is recorded as time()");
 
        }