[ 'method' => 'GET', 'header' => implode("\r\n", $headers) ] ]); $response = @file_get_contents($apiUrl, false, $context); $repoInfo = $response ? json_decode($response, true) : null; $testResults['api_connection'] = [ 'success' => $repoInfo !== null, 'response' => $repoInfo ? 'Repository found' : 'Failed to connect', 'repo_name' => $repoInfo['name'] ?? 'N/A', 'default_branch' => $repoInfo['default_branch'] ?? 'N/A' ]; // 测试2: 分支检查 if ($testResults['api_connection']['success']) { $branchUrl = "https://api.github.com/repos/{$github['owner']}/{$github['repo']}/branches/{$github['branch']}"; $branchContext = stream_context_create([ 'http' => [ 'method' => 'GET', 'header' => implode("\r\n", $headers) ] ]); $branchResponse = @file_get_contents($branchUrl, false, $branchContext); $branchInfo = $branchResponse ? json_decode($branchResponse, true) : null; $testResults['branch_check'] = [ 'success' => $branchInfo !== null, 'branch_name' => $github['branch'], 'exists' => $branchInfo !== null, 'commit_sha' => $branchInfo['commit']['sha'] ?? 'N/A' ]; } // 测试3: 目录结构检查 $testResults['directory_structure'] = []; $directories = [ 'pages' => "pages", 'users' => "pages/users", 'user_dir' => "pages/{$userPath}" ]; foreach ($directories as $key => $path) { $dirUrl = "https://api.github.com/repos/{$github['owner']}/{$github['repo']}/contents/{$path}"; $dirContext = stream_context_create([ 'http' => [ 'method' => 'GET', 'header' => implode("\r\n", $headers) ] ]); $dirResponse = @file_get_contents($dirUrl, false, $dirContext); $testResults['directory_structure'][$key] = [ 'path' => $path, 'exists' => $dirResponse !== false, 'response' => $dirResponse ? 'Found' : 'Not found' ]; } // 测试4: 文件保存测试 $storageManager = new StorageManager(); $testHtml = ' GitHub Advanced Test

🚀 GitHub Advanced Test Success!

Test Results

✅ GitHub API Connection: SUCCESS

✅ Branch Verification: SUCCESS

✅ Directory Structure: SUCCESS

✅ File Save Operation: SUCCESS

Test Details

Test Time: ' . date('Y-m-d H:i:s') . ' UTC

User: ' . htmlspecialchars($currentUser) . '

Repository: ' . htmlspecialchars($github['owner']) . '/' . htmlspecialchars($github['repo']) . '

Branch: ' . htmlspecialchars($github['branch']) . '

User Path: ' . htmlspecialchars($userPath) . '

🎉 All Systems Operational

Your VvvebJs installation is properly configured and can successfully save files to GitHub. You can now use all editor features with confidence!

'; $testFilename = 'github-advanced-test-' . time() . '.html'; $saveResult = $storageManager->saveFile($testFilename, $testHtml); $testResults['file_save'] = [ 'success' => $saveResult, 'filename' => $testFilename, 'content_length' => strlen($testHtml), 'message' => $saveResult ? 'File saved successfully to GitHub' : 'Failed to save file' ]; // 测试5: 文件检索测试 if ($saveResult) { $retrievedContent = $storageManager->getFile($testFilename); $testResults['file_retrieve'] = [ 'success' => $retrievedContent !== false, 'content_matches' => $retrievedContent === $testHtml, 'retrieved_length' => $retrievedContent ? strlen($retrievedContent) : 0 ]; } // 测试6: 文件列表测试 $fileList = $storageManager->listFiles(); $testResults['file_list'] = [ 'success' => is_array($fileList), 'file_count' => is_array($fileList) ? count($fileList) : 0, 'contains_test_file' => false ]; if (is_array($fileList)) { foreach ($fileList as $file) { if ($file['name'] === $testFilename) { $testResults['file_list']['contains_test_file'] = true; break; } } } // 计算总体成功率 $totalTests = 0; $passedTests = 0; foreach ($testResults as $test) { if (isset($test['success'])) { $totalTests++; if ($test['success']) $passedTests++; } elseif (is_array($test)) { foreach ($test as $subtest) { if (isset($subtest['success']) || isset($subtest['exists'])) { $totalTests++; if ($subtest['success'] ?? $subtest['exists'] ?? false) $passedTests++; } } } } $testResults['summary'] = [ 'total_tests' => $totalTests, 'passed_tests' => $passedTests, 'success_rate' => $totalTests > 0 ? round(($passedTests / $totalTests) * 100, 1) : 0, 'overall_success' => $passedTests === $totalTests ]; } catch (Exception $e) { error_log("GitHub Advanced Test Error: " . $e->getMessage()); $testResults['error'] = [ 'message' => $e->getMessage(), 'file' => $e->getFile(), 'line' => $e->getLine() ]; } } ?> VvvebJs GitHub 高级测试

🚀 VvvebJs GitHub 高级测试套件

📋 测试配置

GitHub仓库: /

分支:

基础路径:

当前用户:

用户路径:

Token状态:

🧪 运行完整测试

📋 测试项目清单
  • GitHub API连接测试 - 验证能否连接到GitHub API
  • 仓库访问测试 - 确认仓库存在且可访问
  • 分支验证测试 - 检查目标分支是否存在
  • 目录结构测试 - 验证必要的目录结构
  • 文件保存测试 - 测试实际的文件保存功能
  • 文件检索测试 - 验证保存的文件能否正确读取
  • 文件列表测试 - 测试文件列表功能
🎯 测试总览
%

/ 测试通过

📊 整体状态
🎉 全部测试通过!
你的VvvebJs配置完全正常,可以正常使用所有功能。
⚠️ 部分测试失败
请检查下方的详细测试结果,修复相关问题。
GitHub API连接

状态:

仓库:

默认分支:

分支验证

目标分支:

存在状态:

最新提交: ...

📁 目录结构检查
$dir): ?>

文件保存测试

文件名:

内容长度: 字节

结果:

在GitHub上查看
文件检索测试

读取状态:

内容匹配:

读取长度: 字节