@@ -45,8 +45,14 @@ class EducationTest extends TestCase
|
||||
|
||||
private function declaration(): array
|
||||
{
|
||||
$country = (string) Str::uuid();
|
||||
$province = (string) Str::uuid();
|
||||
$territory = (string) Str::uuid();
|
||||
DB::table('geo_locations')->insert(['id' => $territory, 'name' => 'Território sintético', 'code' => $territory, 'location_type' => 'district']);
|
||||
DB::table('geo_locations')->insert(['id' => $country, 'name' => 'País sintético', 'code' => $country, 'location_type' => 'country']);
|
||||
DB::table('geo_locations')->insert(['id' => $province, 'name' => 'Província sintética', 'code' => $province,
|
||||
'location_type' => 'province', 'parent_id' => $country]);
|
||||
DB::table('geo_locations')->insert(['id' => $territory, 'name' => 'Distrito sintético', 'code' => $territory,
|
||||
'location_type' => 'district', 'parent_id' => $province]);
|
||||
|
||||
return [
|
||||
'project_id' => Project::create(['code' => (string) Str::uuid(), 'name' => 'Projecto sintético', 'status' => 'draft'])->id,
|
||||
@@ -68,7 +74,7 @@ class EducationTest extends TestCase
|
||||
|
||||
public function test_educational_proposal_requires_review_and_is_a_single_unpublished_canonical_opportunity(): void
|
||||
{
|
||||
$this->manager();
|
||||
$manager = $this->manager();
|
||||
$demandData = $this->declaration();
|
||||
$this->post('/management/education/demands', $demandData)->assertSessionHasNoErrors();
|
||||
$demand = LabourDemand::where('project_id', $demandData['project_id'])->firstOrFail();
|
||||
@@ -76,6 +82,8 @@ class EducationTest extends TestCase
|
||||
$data = ['demand_version' => 1, 'sector_id' => $sector->id, 'title' => 'Oficina sintética',
|
||||
'intervention' => 'Resposta formativa sintética para verificação do fluxo.', 'risks' => 'Custos e viabilidade por confirmar.',
|
||||
'source' => 'Fonte sintética identificada no teste.', 'currency' => 'MZN'];
|
||||
$data['district_id'] = $demandData['geo_location_id'];
|
||||
$data['province_id'] = DB::table('geo_locations')->where('id', $demandData['geo_location_id'])->value('parent_id');
|
||||
$url = '/management/education/demands/'.$demand->id.'/investment';
|
||||
$this->post($url, $data)->assertUnprocessable();
|
||||
$this->manager();
|
||||
@@ -121,6 +129,33 @@ class EducationTest extends TestCase
|
||||
$this->travelBack();
|
||||
}
|
||||
|
||||
public function test_provider_and_course_catalogues_follow_documented_capacity_territory(): void
|
||||
{
|
||||
$manager = $this->manager();
|
||||
$first = $this->declaration();
|
||||
$firstCourse = $this->course();
|
||||
$capacity = $first;
|
||||
unset($capacity['project_id'], $capacity['employer']);
|
||||
TrainingCapacity::create([...$capacity, 'course_id' => $firstCourse->id, 'submitted_by' => $manager->id]);
|
||||
|
||||
$otherProvince = (string) Str::uuid();
|
||||
$otherDistrict = (string) Str::uuid();
|
||||
$country = DB::table('geo_locations')->where('id', $first['geo_location_id'])->value('parent_id');
|
||||
$country = DB::table('geo_locations')->where('id', $country)->value('parent_id');
|
||||
DB::table('geo_locations')->insert(['id' => $otherProvince, 'name' => 'Província de teste B', 'code' => $otherProvince,
|
||||
'location_type' => 'province', 'parent_id' => $country]);
|
||||
DB::table('geo_locations')->insert(['id' => $otherDistrict, 'name' => 'Distrito de teste B', 'code' => $otherDistrict,
|
||||
'location_type' => 'district', 'parent_id' => $otherProvince]);
|
||||
$otherCourse = $this->course();
|
||||
TrainingCapacity::create([...$capacity, 'geo_location_id' => $otherDistrict, 'course_id' => $otherCourse->id, 'submitted_by' => $manager->id]);
|
||||
|
||||
$this->get('/management/education?geo_location_id='.$first['geo_location_id'])
|
||||
->assertInertia(fn (AssertableInertia $page) => $page
|
||||
->where('filters.geo_location_id', $first['geo_location_id'])
|
||||
->has('providers', 1)->where('providers.0.id', $firstCourse->provider_id)
|
||||
->has('courses', 1)->where('courses.0.id', $firstCourse->id));
|
||||
}
|
||||
|
||||
public function test_access_requires_verified_manager_and_enabled_feature(): void
|
||||
{
|
||||
$this->get('/management/education')->assertRedirect('/login');
|
||||
@@ -150,6 +185,12 @@ class EducationTest extends TestCase
|
||||
$this->assertStringNotContainsString($data['source'], $audit->after_data);
|
||||
$this->post('/management/education/demands', [...$data, 'quantity' => -1])->assertSessionHasErrors('quantity');
|
||||
$this->post('/management/education/demands', [...$data, 'period_end' => now()->toDateString()])->assertSessionHasErrors('period_end');
|
||||
$country = (string) Str::uuid();
|
||||
DB::table('geo_locations')->insert([
|
||||
'id' => $country, 'name' => 'País fora do escopo', 'code' => $country, 'location_type' => 'country',
|
||||
]);
|
||||
$this->post('/management/education/demands', [...$data, 'geo_location_id' => $country])
|
||||
->assertSessionHasErrors('geo_location_id');
|
||||
Skill::findOrFail($data['skill_id'])->delete();
|
||||
$this->post('/management/education/demands', $data)->assertSessionHasErrors('skill_id');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user