title: Fix flaky TitlePermissionTest::testUserBlock
authorTimo Tijhof <krinklemail@gmail.com>
Sun, 25 Aug 2019 15:04:19 +0000 (16:04 +0100)
committerTimo Tijhof <krinklemail@gmail.com>
Sun, 25 Aug 2019 15:04:19 +0000 (16:04 +0100)
The mock timestamp is asserted via $prev, which is set a few lines
up.

The input timestamp is set as 0, which usually passes (if these two
lines execute in the same second), but when the two lines of code
are on opposite sides of a clock second boundary, the test would
fail.

Instead of fixing the setTimestamp() call, remove it in favour of
fixing the 'timestamp' option instead, which was needlessly
being set to one thing and then overwritten by setTimestamp.

Bug: T231166
Change-Id: If6a1e4ec7b91efee0a43e6dd86794f15c5a440b3

tests/phpunit/includes/TitlePermissionTest.php

index e6cf8c8..208b955 100644 (file)
@@ -942,11 +942,10 @@ class TitlePermissionTest extends MediaWikiLangTestCase {
                        'address' => '127.0.8.1',
                        'by' => $this->user->getId(),
                        'reason' => 'no reason given',
-                       'timestamp' => $prev + 3600,
+                       'timestamp' => $prev,
                        'auto' => true,
                        'expiry' => 0
                ] );
-               $this->user->mBlock->setTimestamp( 0 );
                $this->assertEquals( [ [ 'autoblockedtext',
                                "[[User:Useruser|\u{202A}Useruser\u{202C}]]", 'no reason given', '127.0.0.1',
                                "\u{202A}Useruser\u{202C}", null, 'infinite', '127.0.8.1',