Level 74
You are trying to do an update here but you don't pass any data along
$response = $this->put(route('owner.project.update', $created_project->id));
So most likely your validation fails and sends you back to where you were.
hey there. I've written a test for my update method but the assertRedirect code gives me error. Test:
public function test_owner_can_update_his_projects()
{
$this->actingAs(User::factory()->create());
$created_project = Project::factory()->create(['user_id' => auth()->user()->id]);
$response = $this->put(route('owner.project.update', $created_project->id));
$response->assertRedirect(route('owner.projects'));
$response->assertSessionHasNoErrors();
}
Update method codes:
public function update(ProjectUpdateRequest $request, Project $project)
{
$validated_data = $request->validated();
$project->update($validated_data);
return redirect()->route('owner.projects');
}
Error:
1) Tests\Feature\Owner\ProjectsTest::test_owner_can_update_his_projects
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'http://localhost/dashboard/owner/projects'
+'http://localhost'
E:\projects\tarhcadeh\vendor\laravel\framework\src\Illuminate\Testing\TestResponse.php:260
E:\projects\tarhcadeh\vendor\laravel\framework\src\Illuminate\Testing\TestResponse.php:205
E:\projects\tarhcadeh\tests\Feature\Owner\ProjectsTest.php:93
thanks in advance
Please or to participate in this conversation.