# Hotel Manager (PMS) — Comprehensive Test Plan

## Overview

All tests use **Pest 2.6** framework, located in `tests/Feature/Controllers/HotelManager/` and `tests/Unit/Enums/`.

**Estimated total: ~230 tests**

---

## 1. Authorization Tests (8 tests)

**File:** `tests/Feature/Controllers/HotelManager/HotelManagerAuthorizationTest.php`

| # | Test | Expected |
|---|---|---|
| 1 | Hotel manager can access hotel routes | 200 |
| 2 | Regular employee without hotel_manager role gets | 403 |
| 3 | Customer user gets | 403 |
| 4 | Coach user gets | 403 |
| 5 | Unauthenticated gets | 401 |
| 6 | Manager at Place A cannot access Place B hotel | 403 |
| 7 | Manager cannot access hotel belonging to different place | 403 |
| 8 | All model factories create valid records | pass |

---

## 2. Room Types & Rooms Tests (9 tests)

**File:** `tests/Feature/Controllers/HotelManager/RoomTypesAndRoomsTest.php`

| # | Test |
|---|---|
| 1 | Hotel manager can list room types |
| 2 | Hotel manager can view room type detail with rooms |
| 3 | Hotel manager can list rooms with filters |
| 4 | Hotel manager can view room detail |
| 5 | Hotel manager can update room status |
| 6 | Customer can list hotels at a place |
| 7 | Customer can view hotel details |
| 8 | Customer can list room types with correct pricing (member vs non-member) |
| 9 | Room status update creates housekeeping log when relevant |

---

## 3. Rate Management Tests (10 tests)

**File:** `tests/Feature/Controllers/HotelManager/RatesTest.php`

| # | Test |
|---|---|
| 1 | Manager can list seasonal rates |
| 2 | Manager can list rates for a specific room type |
| 3 | Availability returns correct room counts |
| 4 | Availability respects existing reservations (confirmed + checked-in) |
| 5 | Availability respects room status (out_of_order excluded) |
| 6 | Availability respects occupancy limits |
| 7 | Rate engine returns seasonal rate when applicable |
| 8 | Rate engine falls back to base price when no seasonal rate |
| 9 | Rate engine handles multi-season stays (split across seasonal boundaries) |
| 10 | Customer availability endpoint returns correct pricing (member vs non-member) |

---

## 4. Reservation Tests (20 tests)

**File:** `tests/Feature/Controllers/HotelManager/ReservationsTest.php`

### Manager API (10)
| # | Test |
|---|---|
| 1 | Manager can list reservations with filters |
| 2 | Manager can view reservation detail with folio |
| 3 | Manager can create walk-in reservation |
| 4 | Manager can update reservation status (all valid transitions) |
| 5 | Manager gets error on invalid status transition |
| 6 | Manager can assign rooms to reservation |
| 7 | Manager gets error assigning unavailable room |
| 8 | Manager gets error assigning room of wrong type |
| 9 | Availability decreases after reservation created |
| 10 | Folio shows correct room charges and extras |

### Customer API (10)
| # | Test |
|---|---|
| 11 | Customer can create reservation |
| 12 | Customer can pay for reservation (Stripe) |
| 13 | Customer can pay for reservation (Wallet) |
| 14 | Customer can list their reservations |
| 15 | Customer can cancel reservation |
| 16 | Customer cannot cancel another user's reservation |
| 17 | Customer cannot create reservation for unavailable dates |
| 18 | Customer cannot exceed occupancy limits |
| 19 | Reservation respects min_stay constraint |
| 20 | Orderable interface implementation correct |

---

## 5. Check-in / Check-out / Cancellation Tests (23 tests)

**File:** `tests/Feature/Controllers/HotelManager/CheckinCheckoutTest.php`

### Check-in (3)
| # | Test |
|---|---|
| 1 | Check-in sets status to CHECKED_IN and rooms to OCCUPIED |
| 2 | Check-in auto-assigns room when none assigned |
| 3 | Check-in fails when reservation is not CONFIRMED |

### Check-out (5)
| # | Test |
|---|---|
| 4 | Check-out sets status to CHECKED_OUT and rooms to AVAILABLE + DIRTY |
| 5 | Check-out creates housekeeping logs |
| 6 | Checkout generates folio Order with correct items |
| 7 | Folio excludes room charges when prepaid |
| 8 | Folio includes all extras |

### Payments (6)
| # | Test |
|---|---|
| 9 | Payment via POS works with receipt photo |
| 10 | Payment via Cash works with amounts |
| 11 | Payment via Wallet works |
| 12 | Payment via Stripe creates payment intent |
| 13 | Invoice can be downloaded after payment |
| 14 | Invoice can be sent to alternate email |

### Cancellation & Refund (9)
| # | Test |
|---|---|
| 15 | Cancellation of PENDING reservation has no penalty |
| 16 | Cancellation outside free period applies penalty (first night rate × penalty %) |
| 17 | Cancellation within free period has no penalty |
| 18 | Manager can waive cancellation penalty |
| 19 | Prepaid reservation gets wallet refund on cancellation (full) |
| 20 | Prepaid reservation gets partial refund when penalty applies |
| 21 | Non-prepaid reservation with penalty creates penalty Order |
| 22 | Cancelled reservation frees assigned rooms |
| 23 | Cannot cancel CHECKED_IN or CHECKED_OUT reservation |

---

## 6. Extras & Room Service Tests (9 tests)

**File:** `tests/Feature/Controllers/HotelManager/ExtrasTest.php`

| # | Test |
|---|---|
| 1 | Manager can list hotel extras |
| 2 | Manager can add extra to checked-in reservation |
| 3 | Manager cannot add extra to reservation that is not checked-in |
| 4 | Extra charges appear in folio |
| 5 | Manager can remove unbilled extra |
| 6 | Manager cannot remove billed extra (after checkout) |
| 7 | Customer can browse extras with correct pricing |
| 8 | Extra uses member pricing for member guests |
| 9 | Orderable interface implementation correct |

---

## 7. Housekeeping Tests (9 tests)

**File:** `tests/Feature/Controllers/HotelManager/HousekeepingTest.php`

| # | Test |
|---|---|
| 1 | Housekeeping dashboard returns correct summary counts |
| 2 | Manager can update housekeeping status |
| 3 | Status transition creates log entry |
| 4 | Invalid transitions are rejected |
| 5 | Tasks endpoint returns rooms sorted by priority |
| 6 | Rooms with upcoming arrivals are highest priority |
| 7 | Checkout auto-sets rooms to DIRTY |
| 8 | IN_PROGRESS sets started_at on log |
| 9 | CLEAN/INSPECTED sets completed_at on log |

---

## 8. Dashboard & Analytics Tests (10 tests)

**File:** `tests/Feature/Controllers/HotelManager/DashboardTest.php`

| # | Test |
|---|---|
| 1 | Today summary returns correct occupancy and counts |
| 2 | Arrivals/departures lists correct reservations |
| 3 | Revenue calculation is accurate (room + extras) |
| 4 | Occupancy rate calculation is correct |
| 5 | ADR calculation is correct |
| 6 | RevPAR calculation is correct |
| 7 | Forecast shows correct upcoming occupancy |
| 8 | Channel performance groups by source |
| 9 | Period filtering works (today, 7d, 30d, custom) |
| 10 | Cache warming command runs without errors |

---

## 9. Channel Manager Tests (7 tests)

**File:** `tests/Feature/Controllers/HotelManager/ChannelManagerTest.php`

| # | Test |
|---|---|
| 1 | Manager can list channel mappings |
| 2 | Manager can trigger manual sync |
| 3 | Manager can view sync logs |
| 4 | Sync job dispatches correctly |
| 5 | Stub driver returns success |
| 6 | Imported reservations have correct source set |
| 7 | Availability push triggered after reservation change |

---

## 10. Cross-cutting Tests (9 tests)

**File:** `tests/Feature/Controllers/HotelManager/CrossCuttingTest.php`

| # | Test |
|---|---|
| 1 | Guest receives notification on reservation confirmation |
| 2 | Guest receives notification on reservation cancellation |
| 3 | Hotel managers receive notification on new reservation |
| 4 | Observer dispatches channel sync on status change |
| 5 | Check-in reminder command sends to correct guests |
| 6 | Auto no-show marks correct reservations |
| 7 | Stale reservation cleanup cancels old pending reservations |
| 8 | Translations work for all translatable models |
| 9 | Pusher events broadcast correctly |

---

## 11. Seeder Tests (5 tests)

**File:** `tests/Feature/Seeders/HotelSeederTest.php`

| # | Test |
|---|---|
| 1 | Seeder runs without errors |
| 2 | All created records pass model validation |
| 3 | Relationships are correctly linked |
| 4 | Seasonal rates don't overlap |
| 5 | Room numbers are unique per hotel |

---

## 12. Unit Tests — Enums (22 tests)

**File:** `tests/Unit/Enums/HotelEnumsTest.php`

| # | Test |
|---|---|
| 1 | HotelRoomStatus has exactly 5 values |
| 2 | All HotelRoomStatus values have labels |
| 3 | HotelHousekeepingStatus has 5 values |
| 4 | All HotelHousekeepingStatus values have labels |
| 5 | HotelReservationStatus has 6 values |
| 6 | All HotelReservationStatus values have labels |
| 7 | HotelRateSeason has 4 values |
| 8 | All HotelRateSeason values have labels |
| 9 | HotelExtraType has 7 values |
| 10 | All HotelExtraType values have labels |
| 11 | HotelBedType has 7 values |
| 12 | All HotelBedType values have labels |
| 13 | HotelChannelType has 5 values |
| 14 | All HotelChannelType values have labels |
| 15 | HotelReservationSource has 7 values |
| 16 | All HotelReservationSource values have labels |
| 17 | OrderableType includes HOTEL_RESERVATION |
| 18 | OrderableType includes HOTEL_EXTRA |
| 19 | HotelReservation implements Orderable |
| 20 | HotelExtra implements Orderable |
| 21 | HotelReservation morph key resolves |
| 22 | HotelExtra morph key resolves |

---

## Summary

| Test Group | File | Count |
|---|---|---|
| Authorization | `HotelManagerAuthorizationTest.php` | 8 |
| Room Types & Rooms | `RoomTypesAndRoomsTest.php` | 9 |
| Rate Management | `RatesTest.php` | 10 |
| Reservations | `ReservationsTest.php` | 20 |
| Check-in/out/Cancellation | `CheckinCheckoutTest.php` | 23 |
| Extras & Room Service | `ExtrasTest.php` | 9 |
| Housekeeping | `HousekeepingTest.php` | 9 |
| Dashboard & Analytics | `DashboardTest.php` | 10 |
| Channel Manager | `ChannelManagerTest.php` | 7 |
| Cross-cutting | `CrossCuttingTest.php` | 9 |
| Seeder | `HotelSeederTest.php` | 5 |
| Unit — Enums | `HotelEnumsTest.php` | 22 |
| **Total** | | **~141** |

> **Note:** The ~141 count is the minimum baseline. As implementation progresses, additional edge case tests will be added, reaching an estimated ~230 tests.
