自动提交
This commit is contained in:
57
test_git_operations.php
Normal file
57
test_git_operations.php
Normal file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
// 测试Git操作功能
|
||||
$apiUrl = 'http://localhost:8080/index.php';
|
||||
|
||||
// 测试1: 获取文件列表
|
||||
echo "测试1: 获取文件列表\n";
|
||||
$ch = curl_init($apiUrl);
|
||||
curl_setopt_array($ch, [
|
||||
CURLOPT_POST => true,
|
||||
CURLOPT_POSTFIELDS => http_build_query(['action' => 'get_files']),
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_HTTPHEADER => ['Content-Type: application/x-www-form-urlencoded']
|
||||
]);
|
||||
$response = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
if ($response) {
|
||||
$result = json_decode($response, true);
|
||||
echo "文件列表结果:\n";
|
||||
echo json_encode($result, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE) . "\n\n";
|
||||
}
|
||||
|
||||
// 测试2: 获取分支列表
|
||||
echo "测试2: 获取分支列表\n";
|
||||
$ch = curl_init($apiUrl);
|
||||
curl_setopt_array($ch, [
|
||||
CURLOPT_POST => true,
|
||||
CURLOPT_POSTFIELDS => http_build_query(['action' => 'get_branches']),
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_HTTPHEADER => ['Content-Type: application/x-www-form-urlencoded']
|
||||
]);
|
||||
$response = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
if ($response) {
|
||||
$result = json_decode($response, true);
|
||||
echo "分支列表结果:\n";
|
||||
echo json_encode($result, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE) . "\n\n";
|
||||
}
|
||||
|
||||
// 测试3: Git状态
|
||||
echo "测试3: Git状态\n";
|
||||
$ch = curl_init($apiUrl);
|
||||
curl_setopt_array($ch, [
|
||||
CURLOPT_POST => true,
|
||||
CURLOPT_POSTFIELDS => http_build_query(['action' => 'git_operation', 'operation' => 'status']),
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_HTTPHEADER => ['Content-Type: application/x-www-form-urlencoded']
|
||||
]);
|
||||
$response = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
if ($response) {
|
||||
$result = json_decode($response, true);
|
||||
echo "Git状态结果:\n";
|
||||
echo json_encode($result, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE) . "\n\n";
|
||||
}
|
||||
|
||||
echo "测试完成!\n";
|
||||
?>
|
||||
Reference in New Issue
Block a user