feat: Add comprehensive documentation suite and reorganize project structure
- Created complete documentation in docs/ directory - Added PROJECT_OVERVIEW.md with feature highlights and getting started guide - Added ARCHITECTURE.md with system design and technical details - Added SECURITY.md with comprehensive security implementation guide - Added DEVELOPMENT.md with development workflows and best practices - Added DEPLOYMENT.md with production deployment instructions - Added API.md with complete REST API documentation - Added CONTRIBUTING.md with contribution guidelines - Added CHANGELOG.md with version history and migration notes - Reorganized all documentation files into docs/ directory for better organization - Updated README.md with proper documentation links and quick navigation - Enhanced project structure with professional documentation standards
This commit is contained in:
159
tests/bootstrap.php
Normal file
159
tests/bootstrap.php
Normal file
@@ -0,0 +1,159 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPUnit Bootstrap for EasyStream Testing
|
||||
*/
|
||||
|
||||
// Define testing environment
|
||||
define('_ISVALID', true);
|
||||
define('TESTING', true);
|
||||
|
||||
// Set error reporting for testing
|
||||
error_reporting(E_ALL);
|
||||
ini_set('display_errors', 1);
|
||||
|
||||
// Set timezone
|
||||
date_default_timezone_set('UTC');
|
||||
|
||||
// Start session for testing
|
||||
if (!session_id()) {
|
||||
session_start();
|
||||
}
|
||||
|
||||
// Include core configuration
|
||||
require_once __DIR__ . '/../f_core/config.core.php';
|
||||
|
||||
// Override database configuration for testing
|
||||
global $cfg;
|
||||
$cfg['db_host'] = getenv('DB_HOST') ?: 'test-db';
|
||||
$cfg['db_name'] = getenv('DB_NAME') ?: 'easystream_test';
|
||||
$cfg['db_user'] = getenv('DB_USER') ?: 'test';
|
||||
$cfg['db_pass'] = getenv('DB_PASS') ?: 'test';
|
||||
|
||||
// Enable debug mode for testing
|
||||
$cfg['debug_mode'] = true;
|
||||
$cfg['logging_database_logging'] = true;
|
||||
$cfg['error_alerts'] = false; // Disable email alerts during testing
|
||||
|
||||
// Create test directories
|
||||
$testDirs = [
|
||||
__DIR__ . '/temp',
|
||||
__DIR__ . '/fixtures',
|
||||
__DIR__ . '/coverage',
|
||||
__DIR__ . '/results',
|
||||
'f_data/logs/test',
|
||||
'f_data/uploads/test',
|
||||
'f_data/cache/test'
|
||||
];
|
||||
|
||||
foreach ($testDirs as $dir) {
|
||||
if (!is_dir($dir)) {
|
||||
mkdir($dir, 0755, true);
|
||||
}
|
||||
}
|
||||
|
||||
// Test helper functions
|
||||
function createTestUser($username = 'testuser', $email = 'test@example.com', $role = 'member')
|
||||
{
|
||||
global $db;
|
||||
|
||||
$hashedPassword = password_hash('testpassword', PASSWORD_DEFAULT);
|
||||
|
||||
$sql = "INSERT INTO `db_users` (`username`, `email`, `password_hash`, `role`, `status`, `email_verified`, `created_at`)
|
||||
VALUES (?, ?, ?, ?, 'active', 1, NOW())";
|
||||
|
||||
$result = $db->Execute($sql, [$username, $email, $hashedPassword, $role]);
|
||||
|
||||
if ($result) {
|
||||
return $db->Insert_ID();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function cleanupTestData()
|
||||
{
|
||||
global $db;
|
||||
|
||||
// Clean up test data
|
||||
$tables = ['db_users', 'db_videofiles', 'db_livefiles', 'db_comments', 'db_interactions', 'db_logs'];
|
||||
|
||||
foreach ($tables as $table) {
|
||||
$db->Execute("DELETE FROM `{$table}` WHERE `created_at` >= DATE_SUB(NOW(), INTERVAL 1 HOUR)");
|
||||
}
|
||||
|
||||
// Clean up test files
|
||||
$testFiles = glob(__DIR__ . '/temp/*');
|
||||
foreach ($testFiles as $file) {
|
||||
if (is_file($file)) {
|
||||
unlink($file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function createTestVideo($userId = null, $title = 'Test Video', $status = 'ready')
|
||||
{
|
||||
global $db;
|
||||
|
||||
if (!$userId) {
|
||||
$userId = createTestUser();
|
||||
}
|
||||
|
||||
$sql = "INSERT INTO `db_videofiles` (`user_id`, `title`, `filename`, `status`, `privacy`, `created_at`)
|
||||
VALUES (?, ?, 'test_video.mp4', ?, 'public', NOW())";
|
||||
|
||||
$result = $db->Execute($sql, [$userId, $title, $status]);
|
||||
|
||||
if ($result) {
|
||||
return $db->Insert_ID();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function createTestStream($userId = null, $title = 'Test Stream', $status = 'scheduled')
|
||||
{
|
||||
global $db;
|
||||
|
||||
if (!$userId) {
|
||||
$userId = createTestUser();
|
||||
}
|
||||
|
||||
$streamKey = 'test_' . uniqid();
|
||||
|
||||
$sql = "INSERT INTO `db_livefiles` (`user_id`, `title`, `stream_key`, `status`, `privacy`, `created_at`)
|
||||
VALUES (?, ?, ?, ?, 'public', NOW())";
|
||||
|
||||
$result = $db->Execute($sql, [$userId, $title, $streamKey, $status]);
|
||||
|
||||
if ($result) {
|
||||
return [
|
||||
'stream_id' => $db->Insert_ID(),
|
||||
'stream_key' => $streamKey
|
||||
];
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Mock file upload for testing
|
||||
function createMockUploadedFile($filename, $content, $mimeType = 'text/plain')
|
||||
{
|
||||
$tempFile = __DIR__ . '/temp/' . $filename;
|
||||
file_put_contents($tempFile, $content);
|
||||
|
||||
return [
|
||||
'name' => $filename,
|
||||
'type' => $mimeType,
|
||||
'tmp_name' => $tempFile,
|
||||
'error' => UPLOAD_ERR_OK,
|
||||
'size' => strlen($content)
|
||||
];
|
||||
}
|
||||
|
||||
// Initialize error handler for testing
|
||||
$errorHandler = VErrorHandler::getInstance();
|
||||
|
||||
// Clean up any existing test data
|
||||
register_shutdown_function('cleanupTestData');
|
||||
|
||||
echo "EasyStream Test Environment Initialized\n";
|
||||
Reference in New Issue
Block a user