58 lines
		
	
	
		
			1.6 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			58 lines
		
	
	
		
			1.6 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
| <?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']
 | |
|             ]
 | |
|         );
 | |
|     }
 | |
| }
 |