forked from danopia/php-ircd
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_startup.php
More file actions
62 lines (48 loc) · 2.04 KB
/
test_startup.php
File metadata and controls
62 lines (48 loc) · 2.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?php
/**
* Test script to demonstrate server startup information
*/
// Initialize autoloader
require_once __DIR__ . '/vendor/autoload.php';
use PhpIrcd\Core\Config;
use PhpIrcd\Core\Server;
use PhpIrcd\Utils\Logger;
// Load configuration
$configPath = __DIR__ . '/config.php';
$config = new Config($configPath);
// Initialize logger with console output
$logger = new Logger('test_startup.log', 0, true);
echo "Testing PHP-IRCd Server Startup Information\n";
echo "============================================\n\n";
// Create server instance
try {
$server = new Server($config->getAll());
echo "Server instance created successfully!\n\n";
// Test the displayStartupInfo method using reflection
$reflection = new ReflectionClass($server);
$method = $reflection->getMethod('displayStartupInfo');
$method->setAccessible(true);
echo "Displaying startup information:\n";
echo "--------------------------------\n";
$method->invoke($server);
echo "\n\nTesting status display:\n";
echo "----------------------\n";
$server->displayStatus();
echo "\n\nTesting server statistics:\n";
echo "-------------------------\n";
$stats = $server->getServerStats();
echo "Server Statistics:\n";
echo " Name: " . $stats['server_info']['name'] . "\n";
echo " Network: " . $stats['server_info']['network'] . "\n";
echo " Version: " . $stats['server_info']['version'] . "\n";
echo " Running: " . ($stats['server_info']['running'] ? 'Yes' : 'No') . "\n";
echo " Uptime: " . $stats['server_info']['uptime_formatted'] . "\n";
echo " Connected Users: " . $stats['connections']['connected_users'] . "\n";
echo " Active Channels: " . $stats['connections']['active_channels'] . "\n";
echo " Memory Usage: " . $stats['memory']['current'] . " bytes\n";
echo " Memory Peak: " . $stats['memory']['peak'] . " bytes\n";
echo "\nTest completed successfully!\n";
} catch (Exception $e) {
echo "Error: " . $e->getMessage() . "\n";
echo "Stack trace:\n" . $e->getTraceAsString() . "\n";
}