count(3)->create(); $response = $this->get(route('categoria.index')); $response->assertOk(); $response->assertJsonStructure([]); } #[Test] public function store_uses_form_request_validation(): void { $this->assertActionUsesFormRequest( \App\Http\Controllers\CategoriaController::class, 'store', \App\Http\Requests\CategoriaStoreRequest::class ); } #[Test] public function store_saves(): void { $nombre = fake()->word(); $response = $this->post(route('categoria.store'), [ 'nombre' => $nombre, ]); $categoria = Categorium::query() ->where('nombre', $nombre) ->get(); $this->assertCount(1, $categoria); $categorium = $categoria->first(); $response->assertCreated(); $response->assertJsonStructure([]); } #[Test] public function show_behaves_as_expected(): void { $categorium = Categoria::factory()->create(); $response = $this->get(route('categoria.show', $categorium)); $response->assertOk(); $response->assertJsonStructure([]); } #[Test] public function update_uses_form_request_validation(): void { $this->assertActionUsesFormRequest( \App\Http\Controllers\CategoriaController::class, 'update', \App\Http\Requests\CategoriaUpdateRequest::class ); } #[Test] public function update_behaves_as_expected(): void { $categorium = Categoria::factory()->create(); $nombre = fake()->word(); $response = $this->put(route('categoria.update', $categorium), [ 'nombre' => $nombre, ]); $categorium->refresh(); $response->assertOk(); $response->assertJsonStructure([]); $this->assertEquals($nombre, $categorium->nombre); } #[Test] public function destroy_deletes_and_responds_with(): void { $categorium = Categoria::factory()->create(); $categorium = Categorium::factory()->create(); $response = $this->delete(route('categoria.destroy', $categorium)); $response->assertNoContent(); $this->assertModelMissing($categorium); } }