upskill-event-manager/wordpress-dev/bin/README-test-data.md
bengizmo a24d3af81b feat: Add certificate test data generation and verification
- Add comprehensive test data generation scripts for certificate testing
- Create scripts to verify certificate data and attendee filtering
- Add detailed findings and documentation on test data
- Include certificate tests for various filter combinations
- Fix issues with attendee filtering implementation in template
- Add validation for certificate template file syntax
- Document test data structure and verification results
2025-05-21 09:41:09 -03:00

148 lines
No EOL
4.9 KiB
Markdown

# HVAC Community Events Test Data Generation
This directory contains scripts for generating test data to thoroughly test all features of the HVAC Community Events plugin, including the certificate generation system.
## Available Scripts
### 1. `create-complete-test-data.sh` **(Recommended)**
**Purpose:** Creates a complete test dataset with events, attendees, and certificates in one go.
**What it does:**
- Creates 3 new events with realistic titles, descriptions, and venues
- Adds varied attendee data with realistic names and email addresses (58 total)
- Marks most attendees as checked-in (47 total)
- Generates certificates for checked-in attendees (47 total)
- Randomly marks some certificates as revoked (5) or emailed (31)
**Usage:**
```bash
./bin/create-complete-test-data.sh
```
**Features to test with this data:**
1. Certificate listing with pagination
2. Filtering by event name
3. Filtering by attendee name/email (new feature)
4. Filtering by revocation status
5. Certificate download functionality
6. Certificate email functionality
### 2. `run-certificate-helper.sh`
**Purpose:** Processes existing attendees to mark them as checked-in and generate certificates.
**What it does:**
- Goes through existing attendees and randomly marks some as checked-in
- Generates certificates for all checked-in attendees
- Randomly marks some certificates as revoked or emailed
**Usage:**
```bash
./bin/run-certificate-helper.sh
```
### 3. `generate-test-certificates.sh`
**Purpose:** Generates certificates for existing checked-in attendees.
**What it does:**
- Uploads and executes a PHP script on the server
- Generates certificates for all checked-in attendees
- Randomly marks some certificates as revoked or emailed
**Usage:**
```bash
./bin/generate-test-certificates.sh
```
### 4. `add-test-attendees.sh`
**Purpose:** Adds test attendees with check-ins to existing events.
**What it does:**
- Creates PayPal tickets for existing events if needed
- Adds attendees with "Ben Tester" as the first attendee
- Marks a subset of attendees as checked-in
- Sets up required metadata for certificate generation
**Usage:**
```bash
./bin/add-test-attendees.sh
```
### 5. (Legacy) `create-comprehensive-test-data.sh` and others
Several other scripts are available but may encounter issues with the server configuration. The recommended scripts above have been thoroughly tested and confirmed working.
## Testing Workflow
For a complete test of the certificate system:
1. Run the complete test data script:
```bash
./bin/create-complete-test-data.sh
```
2. Visit the certificate reports page to test filtering:
- https://wordpress-974670-5399585.cloudwaysapps.com/certificate-reports/
3. Test the attendee filtering feature:
- Try searching by full name (e.g., "Ben Tester")
- Try searching by partial name (e.g., "Ben" or "Smith")
- Try searching by email (e.g., "ben@tealmaker.com")
- Try searching by partial email (e.g., "@gmail.com")
4. Test other filter combinations:
- Filter by event + attendee
- Filter by revocation status + attendee
- Clear filters and verify all certificates are shown
5. Test certificate actions:
- Download certificate PDFs
- Test emailing certificates
- Test revoking certificates
- Test pagination on certificate reports page
## Certificate Data Structure
The certificate data is stored in the `wp_hvac_certificates` table with the following structure:
- `certificate_id`: Unique identifier
- `event_id`: Associated event
- `attendee_id`: Associated attendee
- `user_id`: Associated WordPress user (if applicable)
- `certificate_number`: Unique formatted number (HVAC-YYYY-XXXXX)
- `file_path`: Path to the PDF file
- `date_generated`: When the certificate was created
- `generated_by`: User who generated the certificate
- `revoked`: Certificate revocation status
- `revoked_date`, `revoked_by`, `revoked_reason`: Revocation details
- `email_sent`: Whether the certificate was emailed
- `email_sent_date`: When the certificate was emailed
## Testing the Attendee Filter
The new attendee filtering feature can be tested with the test data created by these scripts. The filter allows:
1. **Search by attendee name:**
- Full names like "Ben Tester"
- Partial names like "John" or "Smith"
- Case-insensitive matching
2. **Search by attendee email:**
- Complete emails like "ben@tealmaker.com"
- Partial email domains like "@gmail.com"
- Case-insensitive matching
The attendee filter works by performing SQL JOINs with the attendee metadata tables, allowing efficient searching across all certificate records.
## Troubleshooting
If you encounter issues with the scripts:
1. Check for PHP errors in the output
2. Verify that all required plugins are activated on the server
3. Make sure the certificate table exists in the database
4. Ensure certificate storage directory exists and is writable
For more complex issues, the `test-certificate-system.php` script can be used to diagnose problems with the certificate system.