count(3)->create(); $response = $this->get(route('venta.index')); $response->assertOk(); $response->assertJsonStructure([]); } #[Test] public function store_uses_form_request_validation(): void { $this->assertActionUsesFormRequest( \App\Http\Controllers\VentaController::class, 'store', \App\Http\Requests\VentaStoreRequest::class ); } #[Test] public function store_saves(): void { $fecha = Carbon::parse(fake()->dateTime()); $total = fake()->randomFloat(/** decimal_attributes **/); $tipo_pago = fake()->randomElement(/** enum_attributes **/); $estado = fake()->randomElement(/** enum_attributes **/); $response = $this->post(route('venta.store'), [ 'fecha' => $fecha->toDateTimeString(), 'total' => $total, 'tipo_pago' => $tipo_pago, 'estado' => $estado, ]); $venta = Ventum::query() ->where('fecha', $fecha) ->where('total', $total) ->where('tipo_pago', $tipo_pago) ->where('estado', $estado) ->get(); $this->assertCount(1, $venta); $ventum = $venta->first(); $response->assertCreated(); $response->assertJsonStructure([]); } #[Test] public function show_behaves_as_expected(): void { $ventum = Venta::factory()->create(); $response = $this->get(route('venta.show', $ventum)); $response->assertOk(); $response->assertJsonStructure([]); } #[Test] public function update_uses_form_request_validation(): void { $this->assertActionUsesFormRequest( \App\Http\Controllers\VentaController::class, 'update', \App\Http\Requests\VentaUpdateRequest::class ); } #[Test] public function update_behaves_as_expected(): void { $ventum = Venta::factory()->create(); $fecha = Carbon::parse(fake()->dateTime()); $total = fake()->randomFloat(/** decimal_attributes **/); $tipo_pago = fake()->randomElement(/** enum_attributes **/); $estado = fake()->randomElement(/** enum_attributes **/); $response = $this->put(route('venta.update', $ventum), [ 'fecha' => $fecha->toDateTimeString(), 'total' => $total, 'tipo_pago' => $tipo_pago, 'estado' => $estado, ]); $ventum->refresh(); $response->assertOk(); $response->assertJsonStructure([]); $this->assertEquals($fecha, $ventum->fecha); $this->assertEquals($total, $ventum->total); $this->assertEquals($tipo_pago, $ventum->tipo_pago); $this->assertEquals($estado, $ventum->estado); } #[Test] public function destroy_deletes_and_responds_with(): void { $ventum = Venta::factory()->create(); $ventum = Ventum::factory()->create(); $response = $this->delete(route('venta.destroy', $ventum)); $response->assertNoContent(); $this->assertModelMissing($ventum); } }