assertNull($obj->getWorkingDay()); $this->assertNull($obj->getWorkingTime()); $this->expectException(Error::class); $obj->jsonSerialize(); } /** * @return array[] */ public function workingHoursProvider(): array { return [ [ new DateTime('2020-11-30'), new DateInterval("PT8H"), [ 'workingDay' => '2020-11-30', 'workingTime' => '08:00:00', ], ], [ new DateTime('2021-05-03'), new DateInterval("PT7H45M"), [ 'workingDay' => '2021-05-03', 'workingTime' => '07:45:00', ], ], ]; } /** * @param DateTime $date * @param DateInterval $interval * @param array $should_json * * @dataProvider workingHoursProvider */ public function testWorkingHoursWithContent(DateTime $date, DateInterval $interval, array $should_json): void { $obj = new WorkingHours(); $obj ->setWorkingDay($date) ->setWorkingTime($interval); $this->assertNotNull($obj->getWorkingDay()); $this->assertNotNull($obj->getWorkingTime()); $json = $obj->jsonSerialize(); $this->assertIsArray($json); $this->assertEquals($should_json, $json); } }