0
0
Fork 0
mirror of https://github.com/kevinpapst/kimai2.git synced 2025-05-09 03:20:14 +00:00
kevinpapst_kimai2/tests/Export/Package/CellFormatter/DurationPlainFormatterTest.php
2025-04-22 20:43:22 +02:00

61 lines
1.9 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\DurationPlainFormatter;
use PHPUnit\Framework\TestCase;
/**
* @covers \App\Export\Package\CellFormatter\DurationPlainFormatter
*/
class DurationPlainFormatterTest extends TestCase
{
public function testFormatValueReturnsFormattedDurationQuiteLong(): void
{
$formatter = new DurationPlainFormatter();
$result = $formatter->formatValue(701213);
self::assertEquals('194:46:53', $result);
}
public function testFormatValueReturnsFormattedDurationForNumericValue(): void
{
$formatter = new DurationPlainFormatter();
$result = $formatter->formatValue(8246);
self::assertEquals('2:17:26', $result);
}
public function testFormatValueReturnsZeroForNonNumericValue(): void
{
$formatter = new DurationPlainFormatter();
$result = $formatter->formatValue('not a number');
self::assertEquals('0:00:00', $result);
}
public function testFormatValueReturnsFormattedDurationForFloatValue(): void
{
$formatter = new DurationPlainFormatter();
$result = $formatter->formatValue(44513.5);
self::assertEquals('12:21:53', $result);
}
public function testFormatValueReturnsZeroForNullValue(): void
{
$formatter = new DurationPlainFormatter();
$result = $formatter->formatValue(null);
self::assertEquals('0:00:00', $result);
}
public function testFormatValueReturnsFormattedDurationForNegativeValue(): void
{
$formatter = new DurationPlainFormatter();
$result = $formatter->formatValue(-3600);
self::assertEquals('-1:00:00', $result);
}
}