mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-21 17:48:43 +02:00
N°5279 - PHP 8.1: Migrate usages of deprecated strftime() function
In the end we made an adapter to keep using the strftime() format (https://www.php.net/manual/fr/function.strftime.php); not to ease migration but because we couldn't use \DateTime::format(). We can't use \DateTime::format() directly on the whole filename as it would also format characters that are not supposed to be. eg. "__DB__-Y-m-d-production" would become "itopdb-2023-02-09-+01:00Thu, 09 Feb 2023 11:34:01 +0100202309", mind the "production" part being converted.
This commit is contained in:
@@ -423,6 +423,35 @@ class utilsTest extends ItopTestCase
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider StrftimeFormatToDateTimeFormatProvider
|
||||
* @covers \utils::StrftimeFormatToDateTimeFormat
|
||||
*
|
||||
* @param string $sInput
|
||||
* @param string $sExpectedFormat
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testStrftimeFormatToDateTimeFormat(string $sInput, string $sExpectedFormat)
|
||||
{
|
||||
$sTestedFormat = utils::StrftimeFormatToDateTimeFormat($sInput);
|
||||
$this->assertEquals($sExpectedFormat, $sTestedFormat, "DateTime format transformation for '$sInput' doesn't match. Got '$sTestedFormat', expected '$sExpectedFormat'.");
|
||||
}
|
||||
|
||||
public function StrftimeFormatToDateTimeFormatProvider(): array
|
||||
{
|
||||
return [
|
||||
'Standard date time' => [
|
||||
'%Y-%m-%d %H:%M:%S',
|
||||
'Y-m-d H:i:s',
|
||||
],
|
||||
'All placeholders' => [
|
||||
'%d | %m | %y | %Y | %H | %M | %S | %a | %A | %e | %j | %u | %w | %U | %V | %W | %b | %B | %h | %C | %g | %G | %k | %I | %l | %p | %P | %r | %R | %T | %X | %z | %Z | %c | %D | %F | %s | %x | %n | %t | %%',
|
||||
'd | m | y | Y | H | i | s | D | l | j | z | N | w | %U | W | %W | M | F | M | %C | y | Y | G | h | g | A | a | h:i:s A | H:i | H:i:s | %X | O | T | %c | m/d/y | Y-m-d | U | %x | %n | %t | %',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider ToCamelCaseProvider
|
||||
* @covers utils::ToCamelCase
|
||||
|
||||
Reference in New Issue
Block a user