- Add ImportEmployees Action and ImportEmployeesInput - Add GetEmployeeImportColumnsQuery - Encapsulate toImportEmployeesInput in ImportRequest - Use Executor in Bo\EmployeesController - Add feature tests for Bo\EmployeesController
51 lines
1.4 KiB
PHP
51 lines
1.4 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use App\Models\User;
|
|
use Domain\Enums\UserRole;
|
|
use Illuminate\Http\UploadedFile;
|
|
|
|
describe('EmployeesController', function () {
|
|
beforeEach(function () {
|
|
// GIVEN
|
|
/** @var \Tests\TestCase $this */
|
|
$this->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');
|
|
});
|
|
});
|