0
0
Fork 0
mirror of https://github.com/kevinpapst/kimai2.git synced 2025-04-19 11:39:48 +00:00
kevinpapst_kimai2/tests/Export/Package/CellFormatter/DateStringFormatterTest.php
2025-01-20 16:09:29 +01:00

44 lines
1.3 KiB
PHP

<?php
/*
* This file is part of the Kimai time-tracking app.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace App\Tests\Export\Package\CellFormatter;
use App\Export\Package\CellFormatter\DateStringFormatter;
use PHPUnit\Framework\TestCase;
/**
* @covers \App\Export\Package\CellFormatter\DateStringFormatter
*/
class DateStringFormatterTest extends TestCase
{
public function testFormatValueReturnsFormattedDateForDateTime(): void
{
$formatter = new DateStringFormatter();
$date = new \DateTime('2023-10-01 12:37');
$result = $formatter->formatValue($date);
$this->assertIsString($result);
$this->assertEquals('2023-10-01', $result);
}
public function testFormatValueReturnsNullForNullValue(): void
{
$formatter = new DateStringFormatter();
$result = $formatter->formatValue(null);
self::assertNull($result);
}
public function testFormatValueThrowsExceptionForNonDateTime(): void
{
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage('Only DateTimeInterface can be formatted');
$formatter = new DateStringFormatter();
$formatter->formatValue('not a date');
}
}