Erweitere die Tests

This commit is contained in:
2025-06-19 14:19:09 +02:00
parent a964663f51
commit cf6eff6ab0
9 changed files with 195 additions and 44 deletions
+41 -5
View File
@@ -17,6 +17,7 @@ class WorkingHoursTest extends Unit
$obj = new WorkingHours();
$this->assertNull($obj->getWorkingDay());
$this->assertNull($obj->getWorkingTime());
$this->assertFalse($obj->isHomeOffice());
$this->expectException(Error::class);
$obj->jsonSerialize();
@@ -32,17 +33,21 @@ class WorkingHoursTest extends Unit
new DateTime('2020-11-30'),
new DateInterval("PT8H"),
[
'workingDay' => '2020-11-30',
'workingTime' => '08:00:00',
'workingDay' => '2020-11-30',
'workingTime' => '08:00:00',
'isHomeOffice' => true,
],
true,
],
[
new DateTime('2021-05-03'),
new DateInterval("PT7H45M"),
[
'workingDay' => '2021-05-03',
'workingTime' => '07:45:00',
'workingDay' => '2021-05-03',
'workingTime' => '07:45:00',
'isHomeOffice' => false,
],
false,
],
];
}
@@ -51,10 +56,38 @@ class WorkingHoursTest extends Unit
* @param DateTime $date
* @param DateInterval $interval
* @param array<string, string> $shouldJson
* @param bool $isHomeOffice
*/
#[DataProvider('workingHoursProvider')]
public function testWorkingHoursWithContent(DateTime $date, DateInterval $interval, array $shouldJson): void
public function testWorkingHoursWithContent(DateTime $date, DateInterval $interval, array $shouldJson, bool $isHomeOffice): void
{
$obj = new WorkingHours();
$obj->setWorkingDay($date)->setWorkingTime($interval)->setIsHomeOffice($isHomeOffice);
$this->assertNotNull($obj->getWorkingDay());
$this->assertInstanceOf(DateTime::class, $obj->getWorkingDay());
$this->assertEquals($date, $obj->getWorkingDay());
$this->assertNotNull($obj->getWorkingTime());
$this->assertInstanceOf(DateInterval::class, $obj->getWorkingTime());
$this->assertEquals($interval, $obj->getWorkingTime());
$this->assertIsBool($obj->isHomeOffice());
$this->assertEquals($isHomeOffice, $obj->isHomeOffice());
$json = $obj->jsonSerialize();
$this->assertEquals($shouldJson, $json);
}
/**
* @param DateTime $date
* @param DateInterval $interval
* @param array<string, string> $shouldJson
*/
#[DataProvider('workingHoursProvider')]
public function testWorkingHoursWithContentWithoutHomeOfficeInformation(DateTime $date, DateInterval $interval, array $shouldJson): void
{
$shouldJson['isHomeOffice'] = false;
$obj = new WorkingHours();
$obj->setWorkingDay($date)->setWorkingTime($interval);
@@ -66,6 +99,9 @@ class WorkingHoursTest extends Unit
$this->assertInstanceOf(DateInterval::class, $obj->getWorkingTime());
$this->assertEquals($interval, $obj->getWorkingTime());
$this->assertIsBool($obj->isHomeOffice());
$this->assertFalse($obj->isHomeOffice());
$json = $obj->jsonSerialize();
$this->assertEquals($shouldJson, $json);
}