<?php

namespace Tests;

/**
 * Property Test Case
 * Base class for property-based tests
 * Each property test should run at least 100 iterations
 */
abstract class PropertyTestCase extends BaseTestCase {
    
    /**
     * Number of iterations for property tests
     */
    protected $iterations = 100;
    
    /**
     * Run a property test with multiple iterations
     * 
     * @param callable $testFunction The test function to run
     * @param int $iterations Number of iterations (default: 100)
     */
    protected function runPropertyTest(callable $testFunction, $iterations = null) {
        $iterations = $iterations ?? $this->iterations;
        
        for ($i = 0; $i < $iterations; $i++) {
            try {
                $testFunction($i);
            } catch (\Exception $e) {
                $this->fail("Property test failed on iteration $i: " . $e->getMessage());
            }
        }
        
        $this->assertTrue(true, "Property held for all $iterations iterations");
    }
    
    /**
     * Generate random data for property testing
     */
    protected function generateRandomData() {
        return [
            'string' => randomString(rand(5, 20)),
            'phone' => randomPhoneNumber(10),
            'email' => randomEmail(),
            'date' => randomDate(),
            'int' => rand(1, 1000),
            'bool' => (bool)rand(0, 1)
        ];
    }
}
