@codingstuff91 What issue you are exactly facing?
BTW, have you created the project entry before trying to update it? In your test, I cannot see that you have created any project entry.
Summer Sale! All accounts are 50% off this week.
Hello the community of Lara addicts ^^
I request your help because i am stuck on a testing problem.
On my application, i have to manage some "Project", so i did some automated tests to ensure the features work correctly (the create and the update features)
But when i want to test the update a project feature, for an unknow reason the update method of my "ProjectController" doesnt work and i dont understand why... it seems that the project is not edited by the update method called in my test and i dont know why.
Besides, it is very strange, because the real feature works correctly so could you tell me what i did wrong or what i forgot ?
Here is the route is used for updating a project :
PUT|PATCH | admin/projects/{project}
Here is the Update method in my controller "ProjectController" :
public function update(UpdateProjectRequest $request, Project $project)
{
$project->update([
'name' => $request->name
]);
return redirect()->route('admin.index');
}
And finally here is my test :
public function test_a_project_can_be_updated()
{
$this->setup_test_db();
$project = Project::first();
// Mise à jour du projet
$response = $this->patch('/admin/projects/'.$project->id, [
'name' => 'NOUVEAU TITRE'
]);
$project = Project::first();
$this->assertEquals('NOUVEAU TITRE', $project->name);
}
Please or to participate in this conversation.