Merge "Check for expiry dates in a 10-second window"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Wed, 21 Dec 2016 08:04:27 +0000 (08:04 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Wed, 21 Dec 2016 08:04:28 +0000 (08:04 +0000)
tests/phpunit/includes/user/UserTest.php

index 0819bf2..7cbae2d 100644 (file)
@@ -726,7 +726,15 @@ class UserTest extends MediaWikiTestCase {
                $cookies = $request1->response()->getCookies();
                // Calculate the expected cookie expiry date.
                $this->assertArrayHasKey( 'wm_infinite_blockBlockID', $cookies );
-               $this->assertEquals( time() + $cookieExpiration, $cookies['wm_infinite_blockBlockID']['expire'] );
+               // Check for expiry dates in a 10-second window, to account for slow testing.
+               $this->assertGreaterThan(
+                       time() + $cookieExpiration - 5,
+                       $cookies['wm_infinite_blockBlockID']['expire']
+               );
+               $this->assertLessThan(
+                       time() + $cookieExpiration + 5,
+                       $cookies['wm_infinite_blockBlockID']['expire']
+               );
 
                // 3. Change the block's expiry (to 2 days), and the cookie's should be changed also.
                $newExpiry = time() + 2 * 24 * 60 * 60;