Преглед изворни кода

✅ (api-test): 取 /v3/me 后先断言 200,服务器出错时报 FAIL 而不是 ERROR / SKIP

term_exchange 不查状态码,/v3/me 503 时把 null 当 studio 传给生成客户端,
抛 InvalidArgumentException;admin_credits 取不到 roles 会误判为非管理员而 SKIP。

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
visuddhinanda пре 1 дан
родитељ
комит
997b2c13d2
2 измењених фајлова са 5 додато и 1 уклоњено
  1. 1 0
      api-test/cases/18_term_exchange.php
  2. 4 1
      api-test/cases/24_admin_credits.php

+ 1 - 0
api-test/cases/18_term_exchange.php

@@ -23,6 +23,7 @@ test('POST /v3/channels/{channel}/terms/imports(无 token)→ 401', function
 test('术语导出 → 原样导入一轮:xlsx 200 → 导入 200(未变 1)→ 坏文件 422', function () {
     $token = required_token();
     $me = raw('GET', '/v3/me', null, null, $token);
+    assert_status(200, $me, 'me');
     $body = new PostApiV3StudiosStudioChannelsRequest();
     $body->setName('e2e-tmp-exchange-'.time());
     $body->setType('translation');

+ 4 - 1
api-test/cases/24_admin_credits.php

@@ -16,6 +16,7 @@ use \WikipaliApi\Model\PostApiV3AdminCreditSettlementsRequest;
 function credit_admin(string $token): bool
 {
     $me = raw('GET', '/v3/me', null, null, $token);
+    assert_status(200, $me, 'me');
     $roles = $me['body']['data']['roles'] ?? [];
 
     return (bool) array_intersect(['administrator', 'root'], $roles);
@@ -106,7 +107,9 @@ test('POST /v3/admin/credit-settlements(未来日期)→ 422', function () {
 
 test('POST /v3/admin/credit-adjustments:给自己 +1 再 -1(固定 ref,只入账一次)', function () {
     $token = admin_token_or_skip();
-    $me = raw('GET', '/v3/me', null, null, $token)['body']['data']['id'];
+    $me = raw('GET', '/v3/me', null, null, $token);
+    assert_status(200, $me, 'me');
+    $me = $me['body']['data']['id'];
     foreach ([['8f0b5a52-3c1e-4e0a-9d7a-5b1f0c2e0001', 1], ['8f0b5a52-3c1e-4e0a-9d7a-5b1f0c2e0002', -1]] as [$ref, $delta]) {
         $body = new PostApiV3AdminCreditAdjustmentsRequest();
         $body->setUser($me);