'Popcorn', 'detail' => 'buttered', 'brand' => 'Orville Redenbacher', ]; $this->factory()->create($attributes); $this->factory()->create([ 'name' => 'tomatoes', 'detail' => 'canned', 'brand' => 'Kroger', ]); foreach ($attributes as $attribute => $value) { $partial = substr($value, rand(0, 3), 3); $search_route = route("$this->routeBase.index", [ 'filter' => ['search' => $partial] ]); $response = $this->get($search_route); $response->assertOk(); $response->assertJsonCount(1, 'data'); $response->assertJsonFragment([$attribute => $value]); } } }