|
|
<?php
|
|
|
|
|
|
require_once 'storage.php';
|
|
|
|
|
|
echo "Testing GitHub Storage Directory Creation and File Saving...\n";
|
|
|
|
|
|
|
|
|
$storage = new GitHubStorage();
|
|
|
|
|
|
|
|
|
echo "1. Checking GitHub configuration...\n";
|
|
|
if (!$storage->isConfigured()) {
|
|
|
echo "ERROR: GitHub storage is not properly configured.\n";
|
|
|
echo "Please check your GitHub token and repository settings.\n";
|
|
|
exit(1);
|
|
|
}
|
|
|
echo "β GitHub configuration is valid.\n";
|
|
|
|
|
|
|
|
|
echo "2. Testing directory creation...\n";
|
|
|
$userPath = $storage->getUserPath();
|
|
|
if (!$userPath) {
|
|
|
echo "ERROR: Could not determine user path.\n";
|
|
|
exit(1);
|
|
|
}
|
|
|
echo "User path: $userPath\n";
|
|
|
|
|
|
|
|
|
echo "3. Testing file save...\n";
|
|
|
$testContent = "<!DOCTYPE html>\n<html>\n<head>\n<title>Test Page</title>\n</head>\n<body>\n<h1>Test Content</h1>\n<p>This is a test file created at " . date('Y-m-d H:i:s') . "</p>\n</body>\n</html>";
|
|
|
$testFilename = "test-" . date('YmdHis') . ".html";
|
|
|
|
|
|
$result = $storage->save($testFilename, $testContent);
|
|
|
|
|
|
if ($result) {
|
|
|
echo "β File saved successfully: $testFilename\n";
|
|
|
|
|
|
|
|
|
echo "4. Testing file load...\n";
|
|
|
$loadedContent = $storage->load($testFilename);
|
|
|
if ($loadedContent === $testContent) {
|
|
|
echo "β File loaded successfully and content matches.\n";
|
|
|
} else {
|
|
|
echo "WARNING: File loaded but content doesn't match exactly.\n";
|
|
|
echo "Expected length: " . strlen($testContent) . "\n";
|
|
|
echo "Actual length: " . strlen($loadedContent) . "\n";
|
|
|
}
|
|
|
} else {
|
|
|
echo "ERROR: Failed to save test file.\n";
|
|
|
exit(1);
|
|
|
}
|
|
|
|
|
|
echo "\nAll tests completed successfully!\n";
|
|
|
?> |