<?php
/**
 * Basic functionality tests for HVAC Community Events
 */

class Test_Basic_Functionality extends WP_UnitTestCase {
    
    protected $plugin;
    
    public function setUp(): void {
        parent::setUp();
        $this->plugin = HVAC_Community_Events::get_instance();
    }
    
    public function tearDown(): void {
        parent::tearDown();
    }
    
    public function test_plugin_loaded() {
        $this->assertTrue(
            class_exists('HVAC_Community_Events'),
            'Plugin main class should be loaded'
        );
    }
    
    public function test_plugin_version() {
        $this->assertTrue(
            defined('HVAC_CE_VERSION'),
            'Plugin version constant should be defined'
        );
        $this->assertNotEmpty(
            HVAC_CE_VERSION,
            'Plugin version should not be empty'
        );
    }
    
    public function test_dependencies_available() {
        $this->assertTrue(
            class_exists('Tribe__Events__Main'),
            'The Events Calendar classes should be available'
        );
        $this->assertTrue(
            class_exists('Tribe__Events__Community__Main'),
            'Community Events classes should be available'
        );
    }
    
    public function test_basic_event_creation() {
        $event_id = create_test_event();
        $this->assertNotEmpty($event_id, 'Should be able to create a test event');
        
        $event = get_post($event_id);
        $this->assertEquals(
            Tribe__Events__Main::POSTTYPE,
            $event->post_type,
            'Event should have correct post type'
        );
    }
    
    public function test_event_meta_functions() {
        $event_id = create_test_event();
        
        // Test start date
        $start_date = tribe_get_start_date($event_id);
        $this->assertNotFalse(
            $start_date,
            'Should be able to get event start date'
        );
        
        // Test end date
        $end_date = tribe_get_end_date($event_id);
        $this->assertNotFalse(
            $end_date,
            'Should be able to get event end date'
        );
    }
    
    public function test_event_query() {
        create_test_event();
        create_test_event();
        
        $events = tribe_events_get_events();
        $this->assertNotEmpty(
            $events,
            'Should be able to query events'
        );
        $this->assertGreaterThanOrEqual(
            2,
            count($events),
            'Should find at least two events'
        );
    }
}