<?php

namespace Tests;

use PHPUnit\Framework\TestCase;

/**
 * Base Test Case
 * Provides common functionality for all tests
 */
abstract class BaseTestCase extends TestCase {
    
    protected $db;
    
    /**
     * Set up before each test
     */
    protected function setUp(): void {
        parent::setUp();
        $this->db = \Database::getInstance();
    }
    
    /**
     * Tear down after each test
     */
    protected function tearDown(): void {
        parent::tearDown();
        // Clean up can be added here if needed
    }
    
    /**
     * Assert that a value is a valid date
     */
    protected function assertValidDate($date, $format = 'Y-m-d') {
        $d = \DateTime::createFromFormat($format, $date);
        $this->assertTrue($d && $d->format($format) === $date, "Invalid date format: $date");
    }
    
    /**
     * Assert that a value is a valid email
     */
    protected function assertValidEmail($email) {
        $this->assertTrue(filter_var($email, FILTER_VALIDATE_EMAIL) !== false, "Invalid email: $email");
    }
    
    /**
     * Assert that a value is a valid phone number (10 digits)
     */
    protected function assertValidPhoneNumber($phone) {
        $this->assertTrue(
            strlen($phone) === 10 && ctype_digit($phone),
            "Invalid phone number: $phone (must be exactly 10 digits)"
        );
    }
}
