mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-12-06 02:59:29 +00:00
Fix timestamp test
This commit is contained in:
parent
aa4299041b
commit
c5751b2aa6
1 changed files with 10 additions and 7 deletions
|
|
@ -60,26 +60,29 @@ class TimestampableElementProviderTest extends WebTestCase
|
||||||
protected function setUp(): void
|
protected function setUp(): void
|
||||||
{
|
{
|
||||||
self::bootKernel();
|
self::bootKernel();
|
||||||
\Locale::setDefault('en');
|
\Locale::setDefault('en_US');
|
||||||
$this->service = self::getContainer()->get(TimestampableElementProvider::class);
|
$this->service = self::getContainer()->get(TimestampableElementProvider::class);
|
||||||
$this->target = new class() implements TimeStampableInterface {
|
$this->target = new class () implements TimeStampableInterface {
|
||||||
public function getLastModified(): ?DateTime
|
public function getLastModified(): ?DateTime
|
||||||
{
|
{
|
||||||
return new \DateTime('2000-01-01');
|
return new DateTime('2000-01-01');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getAddedDate(): ?DateTime
|
public function getAddedDate(): ?DateTime
|
||||||
{
|
{
|
||||||
return new \DateTime('2000-01-01');
|
return new DateTime('2000-01-01');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function dataProvider(): \Iterator
|
public static function dataProvider(): \Iterator
|
||||||
{
|
{
|
||||||
\Locale::setDefault('en');
|
\Locale::setDefault('en_US');
|
||||||
yield ['1/1/00, 12:00 AM', '[[LAST_MODIFIED]]'];
|
// Use IntlDateFormatter like the actual service does
|
||||||
yield ['1/1/00, 12:00 AM', '[[CREATION_DATE]]'];
|
$formatter = new \IntlDateFormatter(\Locale::getDefault(), \IntlDateFormatter::SHORT, \IntlDateFormatter::SHORT);
|
||||||
|
$expectedFormat = $formatter->format(new DateTime('2000-01-01'));
|
||||||
|
yield [$expectedFormat, '[[LAST_MODIFIED]]'];
|
||||||
|
yield [$expectedFormat, '[[CREATION_DATE]]'];
|
||||||
}
|
}
|
||||||
|
|
||||||
#[DataProvider('dataProvider')]
|
#[DataProvider('dataProvider')]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue