'Chocolate Chip Cookies', 'description' => 'Buttery, delicious cookies.', 'source' => "America's Test Kitchen", ]; $this->factory()->create($attributes); $this->factory()->create([ 'name' => 'Eggplant Parmesan', 'description' => 'Veggies and cheese!', 'source' => 'Joy of Baking', ]); foreach ($attributes as $attribute => $value) { $partial = substr($value, rand(0, 5), 5); $search_route = route($this->indexRouteName, [ 'filter' => ['search' => $partial] ]); $response = $this->get($search_route); $response->assertOk(); $response->assertJsonCount(1, 'data'); $response->assertJsonFragment([$attribute => $value]); } } }