- Add HVAC_Test_User_Factory class with: * User creation with specific roles * Multiple role support * Persona management system * Account cleanup integration - Create comprehensive test suite in HVAC_Test_User_Factory_Test.php - Update testing improvement plan documentation - Add implementation decisions to project memory bank - Restructure .gitignore with: * Whitelist approach for better file management * Explicit backup exclusions * Specific bin directory inclusions Part of the Account Management component from the testing framework improvement plan.
		
			
				
	
	
		
			79 lines
		
	
	
		
			No EOL
		
	
	
		
			2.5 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			79 lines
		
	
	
		
			No EOL
		
	
	
		
			2.5 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
| <?php
 | |
| /**
 | |
|  * HVAC Event Management Test Cases
 | |
|  * 
 | |
|  * Tests event creation, modification, and deletion functionality
 | |
|  * for HVAC trainers with proper role permissions.
 | |
|  */
 | |
| 
 | |
| require_once __DIR__.'/HVAC_Base_Test_Case.php';
 | |
| 
 | |
| class HVAC_Event_Management_Test extends HVAC_Base_Test_Case {
 | |
|     
 | |
|     protected $test_trainer;
 | |
|     protected $test_event_data = [
 | |
|         'title' => 'Test HVAC Training Event',
 | |
|         'description' => 'Test event description',
 | |
|         'start_date' => '',
 | |
|         'end_date' => '',
 | |
|         'capacity' => 20,
 | |
|         'price' => 199.00
 | |
|     ];
 | |
| 
 | |
|     public function setUp(): void {
 | |
|         parent::setUp();
 | |
|         
 | |
|         // Create a test trainer with HVAC role
 | |
|         $this->test_trainer = $this->factory->user->create_and_get([
 | |
|             'role' => 'hvac_trainer'
 | |
|         ]);
 | |
|         
 | |
|         // Set dates for test events
 | |
|         $this->test_event_data['start_date'] = date('Y-m-d H:i:s', strtotime('+1 week'));
 | |
|         $this->test_event_data['end_date'] = date('Y-m-d H:i:s', strtotime('+1 week 2 hours'));
 | |
|         
 | |
|         wp_set_current_user($this->test_trainer->ID);
 | |
|     }
 | |
| 
 | |
|     public function test_event_creation_with_valid_data() {
 | |
|         $event_id = $this->create_test_event();
 | |
|         $this->assertGreaterThan(0, $event_id);
 | |
|         
 | |
|         $event = tribe_get_event($event_id);
 | |
|         $this->assertEquals($this->test_event_data['title'], $event->post_title);
 | |
|     }
 | |
| 
 | |
|     public function test_event_creation_requires_hvac_role() {
 | |
|         // Switch to non-trainer user
 | |
|         $regular_user = $this->factory->user->create_and_get(['role' => 'subscriber']);
 | |
|         wp_set_current_user($regular_user->ID);
 | |
|         
 | |
|         $this->expectException(Exception::class);
 | |
|         $this->create_test_event();
 | |
|     }
 | |
| 
 | |
|     public function test_event_modification() {
 | |
|         $event_id = $this->create_test_event();
 | |
|         $new_title = 'Modified Test Event';
 | |
|         
 | |
|         $updated = tribe_update_event($event_id, [
 | |
|             'post_title' => $new_title,
 | |
|             'post_content' => 'Updated description'
 | |
|         ]);
 | |
|         
 | |
|         $this->assertNotFalse($updated);
 | |
|         $event = tribe_get_event($event_id);
 | |
|         $this->assertEquals($new_title, $event->post_title);
 | |
|     }
 | |
| 
 | |
|     public function test_event_deletion() {
 | |
|         $event_id = $this->create_test_event();
 | |
|         $deleted = tribe_delete_event($event_id);
 | |
|         $this->assertNotFalse($deleted);
 | |
|         $this->assertNull(tribe_get_event($event_id));
 | |
|     }
 | |
| 
 | |
|     protected function create_test_event() {
 | |
|         return tribe_create_event($this->test_event_data);
 | |
|     }
 | |
| } |