Hi @ajsmith_codes.
I think this line:
$originalTask = $project->task;
Should be:
$originalTask = $project->task->body;
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I am building on the app Birdboard that was created in the TDD series. I have a bunch of tests from that series that already work, but I'm lacking one to test for updates to the task body of a project. What I'm having trouble with is getting the value of the task.
Here is what I have so far:
function test_updating_a_task() { $this->withoutExceptionHandling();
$project = ProjectFactory::withTasks(1)->create();
$this->actingAs($project->owner)
->patch($project->tasks[0]->path(), [
'body' => 'foobar',
'updated' => true
]);
$this->assertCount(3, $project->activity);
$this->patch($project->tasks[0]->path(), [
'body' => 'foobar',
'updated' => false
]);
$project->refresh();
$this->assertCount(4, $project->activity);
$this->assertEquals('updated_task', $project->activity->last()->description);
}
This is the existing Update method in my ProjectTasksController:
public function update(Project $project, Task $task)
{
$this->authorize('update', $task->project);
$task->update(request()->validate(['body' => 'required']));
//catch the changes to the task body and if it changes with complete or incomplete
request('completed') ? $task->complete() : $task->incomplete();
return redirect($project->path());
}
So the issue was in your Task model:
protected static $recordableEvents = ['created', 'deleted'];
You only record create and delete activities...
Change it to:
protected static $recordableEvents = ['created', 'deleted', 'updated'];
Please or to participate in this conversation.