Skip to content

Commit 7401075

Browse files
committed
避免測試環境註冊 Wiki 匯入關閉事件
- composer test 移除 255 例外處理 - CI 直接執行 PHPUnit
1 parent 70eb629 commit 7401075

3 files changed

Lines changed: 11 additions & 9 deletions

File tree

.github/workflows/phpunit.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,4 @@ jobs:
3737
php artisan key:generate
3838
3939
- name: Run PHPUnit suite
40-
run: composer test
40+
run: ./vendor/bin/phpunit

app/Http/Controllers/WikiMaintenanceController.php

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -159,13 +159,15 @@ public function importFromUrl(Request $request)
159159
'task_id' => $taskId
160160
]);
161161

162-
// 註冊關閉時執行的函數
163-
register_shutdown_function(function() use ($taskId, $url, $targetSourceId, $sourceName) {
164-
if (function_exists('fastcgi_finish_request')) {
165-
fastcgi_finish_request();
166-
}
167-
$this->executeImportTask($taskId, $url, $targetSourceId, $sourceName);
168-
});
162+
if (!app()->runningUnitTests() && !app()->runningInConsole()) {
163+
// 註冊關閉時執行的函數(僅在 HTTP 請求流程使用)
164+
register_shutdown_function(function () use ($taskId, $url, $targetSourceId, $sourceName) {
165+
if (function_exists('fastcgi_finish_request')) {
166+
fastcgi_finish_request();
167+
}
168+
$this->executeImportTask($taskId, $url, $targetSourceId, $sourceName);
169+
});
170+
}
169171

170172
return $response;
171173
}

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
"@php artisan package:discover --ansi"
5454
],
5555
"test": [
56-
"./vendor/bin/phpunit || if [ $? -eq 255 ]; then echo 'Tests passed (ignoring Laravel 5.5 cache cleanup error)' && exit 0; else exit $?; fi"
56+
"./vendor/bin/phpunit"
5757
]
5858
},
5959
"config": {

0 commit comments

Comments
 (0)