You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
1.3 KiB
35 lines
1.3 KiB
<?php
|
|
|
|
namespace Tests\Unit;
|
|
|
|
use App\Console\Commands\RetryInvalidTimeCourseCarAppointments;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
class RetryInvalidTimeCourseCarAppointmentsTest extends TestCase
|
|
{
|
|
/** @dataProvider payloads */
|
|
public function test_only_the_incident_time_format_is_selected($payload, $expected)
|
|
{
|
|
$command = new class extends RetryInvalidTimeCourseCarAppointments {
|
|
public function matches($payload)
|
|
{
|
|
return $this->hasInvalidTimes($payload);
|
|
}
|
|
};
|
|
$this->assertSame($expected, $command->matches($payload));
|
|
}
|
|
|
|
public function payloads()
|
|
{
|
|
return [
|
|
'incident' => [json_encode(['leaveTime' => '2026-11-26 59:59:58', 'failureTime' => '2026-11-26 59:59:59']), true],
|
|
'corrected' => [json_encode(['leaveTime' => '2026-11-26 23:59:58', 'failureTime' => '2026-11-26 23:59:59']), false],
|
|
'only one wrong field' => [json_encode(['leaveTime' => '2026-11-26 59:59:58', 'failureTime' => '2026-11-26 23:59:59']), false],
|
|
'missing fields' => ['{}', false],
|
|
'unrelated occurrence' => [json_encode(['message' => '59:59:59']), false],
|
|
'invalid json' => ['not-json', false],
|
|
'invalid types' => [json_encode(['leaveTime' => [], 'failureTime' => []]), false],
|
|
];
|
|
}
|
|
}
|