Skip to content

Add comprehensive test suite for observers and order processing#25

Merged
ablunier merged 1 commit intomainfrom
claude/add-critical-tests-crQfF
Feb 20, 2026
Merged

Add comprehensive test suite for observers and order processing#25
ablunier merged 1 commit intomainfrom
claude/add-critical-tests-crQfF

Conversation

@ablunier
Copy link
Copy Markdown
Contributor

Summary

This PR adds an extensive test suite covering the core business logic for membership subscriptions, course enrollments, and order processing pipelines. The tests validate observer patterns, payment processing, and authorization policies across the application.

Key Changes

Observer Tests

  • OrderObserver: Tests subscription activation on order status changes (payment-received, dispatched), subscription extension for existing active subscriptions, customer group benefit application, and course enrollment handling
  • MembershipTierObserver: Tests automatic Lunar product creation when tiers are created, product option generation, and cascading deletion
  • MembershipPlanObserver: Tests product variant creation for billing intervals, pricing setup, tax class updates, and variant lifecycle management
  • CourseObserver: Tests automatic product creation with variants for each course rate option, product option attachment, and product updates on course changes

Pipeline Tests

  • TagOrder Pipeline: Tests order tagging based on product types (membership subscriptions, course enrollments, donations) with priority handling for membership tags

Controller Tests

  • ProcessPaymentController: Tests authentication requirements, cart ownership validation, fingerprint verification, payment gateway adapter resolution, and route mapping for different order types

Policy Tests

  • MediaPolicy: Tests access control for public/private media based on course enrollment status, including media attached to courses and course modules

Notable Implementation Details

  • Tests use Pest PHP framework with descriptive test organization via describe() blocks
  • Comprehensive setup in beforeEach() hooks creating necessary Lunar models (Language, Currency, Channel, TaxZone, etc.)
  • Helper functions for common test patterns (e.g., createMembershipPlanWithVariant(), createCartWithBilling())
  • Tests validate both positive cases (successful operations) and negative cases (authorization failures, invalid states)
  • Observer tests verify cascading effects (e.g., subscription creation triggers customer group assignment)
  • Tests cover edge cases like duplicate course enrollments and subscription extensions from existing active subscriptions

https://claude.ai/code/session_01GU2cPzCDohbHNzBS6dMGW8

…edia policy

Cover 53 test cases across 7 new test files for previously untested business logic:
- OrderObserver: subscription activation, course enrollment, benefit application
- CourseObserver: product/variant creation, update sync, deletion
- MembershipTierObserver: product lifecycle management
- MembershipPlanObserver: variant/price creation, tax class propagation
- ProcessPaymentController: auth, ownership, fingerprint, route mapping
- TagOrder pipeline: order type classification by product type and SKU
- MediaPolicy: public/private access, enrollment-based authorization

https://claude.ai/code/session_01GU2cPzCDohbHNzBS6dMGW8
@ablunier ablunier merged commit ba78c3a into main Feb 20, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants