feat(controllers): add api endpoints
This commit is contained in:
57
tests/Feature/WorkingDayTest.php
Normal file
57
tests/Feature/WorkingDayTest.php
Normal file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
// use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Tests\TestCase;
|
||||
|
||||
class WorkingDayTest extends TestCase
|
||||
{
|
||||
public function testWorkingDayWillReturnSuccessResponseAndTrueIfWorkingDayGiven(): void
|
||||
{
|
||||
$response = $this->get('/api/v1/working-days/CZ/2024-01-15'); // Mon
|
||||
$response->assertStatus(200);
|
||||
$response->assertJson(
|
||||
[
|
||||
'date' => '2024-01-15',
|
||||
'isWorkingDay' => true,
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
public function testWorkingDayWillReturnSuccessResponseAndFalseIfWeekendDayGiven(): void
|
||||
{
|
||||
$response = $this->get('/api/v1/working-days/CZ/2024-01-07'); // San
|
||||
$response->assertStatus(200);
|
||||
$response->assertJson(
|
||||
[
|
||||
'date' => '2024-01-07',
|
||||
'isWorkingDay' => false,
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
public function testWorkingDayWillReturnErrorResponseIfInvalidCountryCodeGiven(): void
|
||||
{
|
||||
$response = $this->get('/api/v1/working-days/XX/2024-01-01'); // Invalid country code
|
||||
$response->assertStatus(400);
|
||||
$response->assertJsonStructure(
|
||||
[
|
||||
'errors' => ['countryCode']
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
public function testWorkingDayWillReturnErrorResponseIfInvalidDateFormatGiven(): void
|
||||
{
|
||||
$response = $this->get('/api/v1/working-days/CZ/invalid-date'); // Invalid date format
|
||||
$response->assertStatus(400);
|
||||
$response->assertJsonStructure(
|
||||
[
|
||||
'errors' => ['date']
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user