From: Sam Wilson Date: Tue, 20 Dec 2016 12:13:56 +0000 (+0800) Subject: Check for expiry dates in a 10-second window X-Git-Tag: 1.31.0-rc.0~4496^2 X-Git-Url: http://git.cyclocoop.org/%40spipnet%40?a=commitdiff_plain;h=9d8358e097ad614bf14abf42f5f75a4e4308648c;p=lhc%2Fweb%2Fwiklou.git Check for expiry dates in a 10-second window This changes a test of expiry dates to be a 10-second range, to account for slow testing. For example, a test may start and set the block's expiry in one second, but by the time it is reading the value from that block's cookie it can sometimes be the next second. Making it 10 seconds just gives it more room for being slow. Bug: T153527 Change-Id: I5efde7785134a75487d31ef3d8b7b14f53b7f5d0 --- diff --git a/tests/phpunit/includes/user/UserTest.php b/tests/phpunit/includes/user/UserTest.php index 0819bf255c..7cbae2deb9 100644 --- a/tests/phpunit/includes/user/UserTest.php +++ b/tests/phpunit/includes/user/UserTest.php @@ -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;