======================================== Send Now Active Hierarchy Filter Tests ======================================== 1. Testing ScheduleRepository::findByStudyId() filters by status ✅ Test 1: ScheduleRepository::findByStudyId() includes 'WHERE study_id = ? AND status = 1' ✅ Test 2: ScheduleRepository::findByStudyId() docblock mentions 'active schedules' 2. Testing NotificationRepository::findByScheduleId() filters by status ✅ Test 3: NotificationRepository::findByScheduleId() includes 'WHERE n.schedule_id = ? AND n.status = 1' ✅ Test 4: NotificationRepository::findByScheduleId() docblock mentions 'active/pending notifications' ✅ Test 5: Status filter is in WHERE clause of findByScheduleId() 3. Testing StudiesController updates ✅ Test 6: Controller uses 'No active schedule found' error message ✅ Test 7: Controller uses 'No active notification found' error message ✅ Test 8: Controller logs 'active schedule' when found ✅ Test 9: Controller logs 'No active notification found' when missing 4. Testing query patterns for consistency ✅ Test 10: ScheduleRepository::find() does NOT filter by status (correct - find by ID should return any status) ✅ Test 11: NotificationRepository::find() does NOT filter by status (correct - find by ID should return any status) 5. Testing database behavior with real repositories ⚠️ Database not found, skipping database tests 6. Testing for regressions in other methods ✅ Test 12: ScheduleRepository::findAllByStudyId() exists and does not filter by status ✅ Test 13: NotificationRepository::findAllByScheduleId() exists and does not filter by status ======================================== Test Results: 13/13 passed ======================================== ✅ All tests passed! Send Now button now correctly filters active hierarchy. Expected behavior: - Study 126 (active) → Schedule 230 (active) → Notification 1534 (active) - Will NOT find: Schedule 229 (inactive) or Notification 1531 (inactive)