Skip to content
Snippets Groups Projects
Commit f0144e24 authored by Jonathan Foucher's avatar Jonathan Foucher
Browse files

Fix tests

parent 4d75997a
No related branches found
No related tags found
No related merge requests found
Pipeline #30266 passed
......@@ -13,10 +13,18 @@
use App\Models\MeasureLevel;
use App\Models\Organization;
use App\Models\User;
use App\Repository\EvaluationRepository;
use Illuminate\Database\Seeder;
class OrganizationSeeder extends Seeder
{
protected EvaluationRepository $repository;
public function __construct(EvaluationRepository $repository)
{
$this->repository = $repository;
}
/**
* Run the database seeds.
*
......@@ -80,7 +88,7 @@ public function run()
}
if ($eval->current_step >= Evaluation::STEP_MATURITY) {
$questions = MaturityQuestion::all();
$questions = MaturityQuestion::where('auto', false)->get();
$answers = $questions->map(function (MaturityQuestion $m) {
$a = new EvaluationMaturityAnswer();
$a->maturity_question_id = $m->id;
......@@ -91,6 +99,8 @@ public function run()
return $a;
});
$eval->maturityLevels()->saveMany($answers);
$this->repository->saveAutomaticAnswers($eval);
}
}
});
......
......@@ -382,8 +382,9 @@ public function testPutEvaluationShouldSaveEvaluationWithFinishedStep()
->where('organization_id', $user->organization_id)
->where('current_step', 5)
->where('reference', env('REFERENTIEL_VERSION'))
->first()
->toArray();
->first();
$eval = $eval->toArray();
$eval['draft'] = 0;
......@@ -441,7 +442,7 @@ public function testPutEvaluationWithMissingMeasureAnswersShouldThrowError()
$response = $this->actingAs($user)->putJson(route('api.evaluations.put', ['id' => $eval['id']]), $eval);
$response->assertJson(['message' => 'Il y a des réponses aux mesures de maturité qui sont manquantes.']);
$response->assertJson(['message' => 'Certaines réponses aux questions de maturité sont manquantes.']);
$response->assertStatus(422);
}
......
......@@ -31,7 +31,7 @@ public function testCanGetQuestions()
$this->assertEquals($questions->toArray(), $response->json());
$this->assertCount(3, $questions);
$this->assertCount(5, $questions);
$this->assertCount(4, $questions[0]->answers);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment