create(); Streak::factory()->create([ 'goal_id' => $goal->id, 'happened_at' => '2019-12-29', ]); Streak::factory()->create([ 'goal_id' => $goal->id, 'happened_at' => '2019-12-31', ]); Streak::factory()->create([ 'goal_id' => $goal->id, 'happened_at' => '2019-12-30', ]); Streak::factory()->create([ 'goal_id' => $goal->id, 'happened_at' => '2020-01-01', ]); Streak::factory()->create([ 'goal_id' => $goal->id, 'happened_at' => '2020-01-02', ]); Streak::factory()->create([ 'goal_id' => $goal->id, 'happened_at' => '2020-01-03', ]); Streak::factory()->create([ 'goal_id' => $goal->id, 'happened_at' => '2020-01-04', ]); Streak::factory()->create([ 'goal_id' => $goal->id, 'happened_at' => '2020-01-06', ]); Streak::factory()->create([ 'goal_id' => $goal->id, 'happened_at' => '2020-01-07', ]); Streak::factory()->create([ 'goal_id' => $goal->id, 'happened_at' => '2020-01-08', ]); Streak::factory()->create([ 'goal_id' => $goal->id, 'happened_at' => '2020-01-09', ]); Streak::factory()->create([ 'goal_id' => $goal->id, 'happened_at' => '2019-01-09', ]); $this->assertEquals( [ 'max_streak' => 7, 'current_streak' => 3, ], GoalHelper::getStreakData($goal) ); } }