$idEvento, 'nombre_evento' => 'Old Event', 'fecha_evento' => now()->subDays(40)->format('Y-m-d'), 'hora_inicio' => '10:00', 'hora_fin' => '12:00' ]); // 2. Create a QR for this event QrCode::create([ 'id_qr' => 'qr_old_1', 'id_evento' => $idEvento, 'tipo_qr' => 'publico' ]); // 3. Ensure they exist $this->assertDatabaseHas('eventos', ['id_evento' => $idEvento]); $this->assertDatabaseHas('qr_codes', ['id_qr' => 'qr_old_1']); // 4. Run the cleanup command Artisan::call('app:cleanup-old-events'); // 5. Verify QRs are gone but event remains $this->assertDatabaseMissing('qr_codes', ['id_qr' => 'qr_old_1']); $this->assertDatabaseHas('eventos', ['id_evento' => $idEvento]); } }