aboutsummaryrefslogtreecommitdiffstats
path: root/tests/phpunit/includes/api/query
diff options
context:
space:
mode:
authorTim Starling <tstarling@wikimedia.org>2025-03-10 16:47:31 +1100
committerTim Starling <tstarling@wikimedia.org>2025-03-10 17:30:40 +1100
commit9a463504747a5f143e0e81c986a7ccfa5f1c27fd (patch)
tree417424d69431475942d4ce25599acd2a8d675ab1 /tests/phpunit/includes/api/query
parent93766d07c7ebf4bca9c1477e49c5326743b9fd74 (diff)
downloadmediawikicore-9a463504747a5f143e0e81c986a7ccfa5f1c27fd.tar.gz
mediawikicore-9a463504747a5f143e0e81c986a7ccfa5f1c27fd.zip
block: Add localized duration to API responses
* Add duration-l10n to BlockLogFormatter with a localized duration string * Add duration-l10n to ApiQueryBlocks * Fix bug in Language::formatDurationBetweenTimestamps() which caused it to be off by one hour if the specified timestamp straddled a daylight savings boundary. Bug: T388089 Change-Id: Ie88ca47053b2b9d6e3119aff5374e676d1835a44
Diffstat (limited to 'tests/phpunit/includes/api/query')
-rw-r--r--tests/phpunit/includes/api/query/ApiQueryBlocksTest.php9
1 files changed, 7 insertions, 2 deletions
diff --git a/tests/phpunit/includes/api/query/ApiQueryBlocksTest.php b/tests/phpunit/includes/api/query/ApiQueryBlocksTest.php
index c7c8ba6906b4..d1fd0e92a049 100644
--- a/tests/phpunit/includes/api/query/ApiQueryBlocksTest.php
+++ b/tests/phpunit/includes/api/query/ApiQueryBlocksTest.php
@@ -30,11 +30,15 @@ class ApiQueryBlocksTest extends ApiTestCase {
$badActor = $this->getTestUser()->getUser();
$sysop = $this->getTestSysop()->getUser();
+ $time = time();
+ $ts = wfTimestamp( TS_MW, $time );
+ $expiry = wfTimestamp( TS_MW, $time + 24 * 60 * 60 );
$block = $this->getServiceContainer()->getDatabaseBlockStore()
->insertBlockWithParams( [
'targetUser' => $badActor,
'by' => $sysop,
- 'expiry' => 'infinity',
+ 'timestamp' => $ts,
+ 'expiry' => $expiry,
] );
[ $data ] = $this->doApiRequest( [
@@ -47,7 +51,8 @@ class ApiQueryBlocksTest extends ApiTestCase {
$subset = [
'id' => $block->getId(),
'user' => $badActor->getName(),
- 'expiry' => $block->getExpiry(),
+ 'expiry' => wfTimestamp( TS_ISO_8601, $expiry ),
+ 'duration-l10n' => '1 day',
];
$this->assertArraySubmapSame( $subset, $data['query']['blocks'][0] );
}