user = User::factory()->create(['role' => UserRole::SuperAdmin]); $this->actingAs($this->user, 'backend'); }); it('can access import form', function () { // WHEN /** @var \Tests\TestCase $this */ $response = $this->get('/bo/settings/employees'); // THEN $response->assertOk(); $response->assertViewHas('importColumns'); }); it('can download example file', function () { // WHEN /** @var \Tests\TestCase $this */ $response = $this->get('/bo/settings/employees/import-example'); // THEN $response->assertOk(); }); it('can import employees file', function () { // GIVEN /** @var \Tests\TestCase $this */ $csvContent = "identifiant;nom;prenom;solde\nEMP001;Dupont;Jean;100.00\n"; $file = UploadedFile::fake()->createWithContent('employees.csv', $csvContent); // WHEN $response = $this->post('/bo/settings/employees/file', [ 'import' => $file, ]); // THEN $response->assertSessionHasNoErrors(); $response->assertRedirect('/bo/settings/employees'); }); });