* - directory refactor * - readme.md update * Update readme.md Co-authored-by: Adrian Hopek <adrian.hopek@blumilk.pl> * Update readme.md Co-authored-by: Ewelina Lasowy <56546832+EwelinaLasowy@users.noreply.github.com> * Update readme.md Co-authored-by: Ewelina Lasowy <56546832+EwelinaLasowy@users.noreply.github.com> * Update readme.md Co-authored-by: Ewelina Lasowy <56546832+EwelinaLasowy@users.noreply.github.com> * Update readme.md Co-authored-by: Adrian Hopek <adrian.hopek@blumilk.pl> Co-authored-by: Ewelina Lasowy <56546832+EwelinaLasowy@users.noreply.github.com>
		
			
				
	
	
		
			78 lines
		
	
	
		
			1.8 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			78 lines
		
	
	
		
			1.8 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
| <?php
 | |
| 
 | |
| declare(strict_types=1);
 | |
| 
 | |
| namespace Tests\Feature;
 | |
| 
 | |
| use Illuminate\Foundation\Testing\DatabaseMigrations;
 | |
| use Inertia\Testing\AssertableInertia as Assert;
 | |
| use Tests\FeatureTestCase;
 | |
| use Toby\Eloquent\Models\User;
 | |
| use Toby\Eloquent\Models\VacationLimit;
 | |
| 
 | |
| class VacationLimitTest extends FeatureTestCase
 | |
| {
 | |
|     use DatabaseMigrations;
 | |
| 
 | |
|     public function testAdminCanSeeVacationLimits(): void
 | |
|     {
 | |
|         $admin = User::factory()->createQuietly();
 | |
| 
 | |
|         User::factory(10)->create();
 | |
| 
 | |
|         $this->actingAs($admin)
 | |
|             ->get("/vacation-limits")
 | |
|             ->assertOk()
 | |
|             ->assertInertia(
 | |
|                 fn(Assert $page) => $page
 | |
|                     ->component("VacationLimits")
 | |
|                     ->has("limits.data", 10),
 | |
|             );
 | |
|     }
 | |
| 
 | |
|     public function testAdminCanUpdateVacationLimits(): void
 | |
|     {
 | |
|         $admin = User::factory()->createQuietly();
 | |
| 
 | |
|         User::factory(3)->create();
 | |
| 
 | |
|         [$limit1, $limit2, $limit3] = VacationLimit::all();
 | |
| 
 | |
|         $data = [
 | |
|             [
 | |
|                 "id" => $limit1->id,
 | |
|                 "days" => 25,
 | |
|             ],
 | |
|             [
 | |
|                 "id" => $limit2->id,
 | |
|                 "days" => null,
 | |
|             ],
 | |
|             [
 | |
|                 "id" => $limit3->id,
 | |
|                 "days" => 20,
 | |
|             ],
 | |
|         ];
 | |
| 
 | |
|         $this->actingAs($admin)
 | |
|             ->put("/vacation-limits", [
 | |
|                 "items" => $data,
 | |
|             ])
 | |
|             ->assertRedirect();
 | |
| 
 | |
|         $this->assertDatabaseHas("vacation_limits", [
 | |
|             "id" => $limit1->id,
 | |
|             "days" => 25,
 | |
|         ]);
 | |
| 
 | |
|         $this->assertDatabaseHas("vacation_limits", [
 | |
|             "id" => $limit2->id,
 | |
|             "days" => null,
 | |
|         ]);
 | |
| 
 | |
|         $this->assertDatabaseHas("vacation_limits", [
 | |
|             "id" => $limit3->id,
 | |
|             "days" => 20,
 | |
|         ]);
 | |
|     }
 | |
| }
 |