Samwilson has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/328354 )

Change subject: Check for expiry dates in a 10-second window
......................................................................

Check for expiry dates in a 10-second window

This changes the tests of expiry dates to be 10-second ranges,
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
---
M tests/phpunit/includes/user/UserTest.php
1 file changed, 12 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/54/328354/1

diff --git a/tests/phpunit/includes/user/UserTest.php 
b/tests/phpunit/includes/user/UserTest.php
index 0819bf2..74cd846 100644
--- a/tests/phpunit/includes/user/UserTest.php
+++ b/tests/phpunit/includes/user/UserTest.php
@@ -726,7 +726,15 @@
                $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;
@@ -739,7 +747,9 @@
                $user2->mBlock = $block;
                $user2->load();
                $cookies = $request2->response()->getCookies();
-               $this->assertEquals( $newExpiry, 
$cookies['wm_infinite_blockBlockID']['expire'] );
+               // Check for expiry dates in a 10-second window, to account for 
slow testing.
+               $this->assertGreaterThan( $newExpiry - 5, 
$cookies['wm_infinite_blockBlockID']['expire'] );
+               $this->assertLessThan( $newExpiry + 5, 
$cookies['wm_infinite_blockBlockID']['expire'] );
 
                // Clean up.
                $block->delete();

-- 
To view, visit https://gerrit.wikimedia.org/r/328354
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I5efde7785134a75487d31ef3d8b7b14f53b7f5d0
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Samwilson <s...@samwilson.id.au>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to