#!/usr/bin/env php loadYaml('pipeline')->gen(5); zenData('repo')->loadYaml('repo')->gen(1); su('admin'); $gitlab = new gitlabModelTest(); r($gitlab->apiGetByGraphqlTest('')) && p('0') && e('Unexpected end of document'); // 测试步骤1:空查询字符串 r($gitlab->apiGetByGraphqlTest('error')) && p('0') && e('Parse error on "error" (IDENTIFIER) at [1, 1]'); // 测试步骤2:无效的GraphQL语法 $validQuery = 'query {project(fullPath: "gitlab-instance-76af86df/testhtml") {repository {tree(path: "") {lastCommit {sha message}}}}}'; r($gitlab->apiGetByGraphqlTest($validQuery)) && p('lastCommit:sha') && e('1b9405639ddef9585b3743b0637b4f79775409b7'); // 测试步骤3:正确的GraphQL查询 $complexQuery = 'query {project(fullPath: "gitlab-instance-76af86df/testhtml") {repository {tree(path: "") {lastCommit {sha message}}}}}'; r($gitlab->apiGetByGraphqlTest($complexQuery)) && p('lastCommit:sha') && e('1b9405639ddef9585b3743b0637b4f79775409b7'); // 测试步骤4:复杂的GraphQL查询 $invalidPathQuery = 'query {project(fullPath: "nonexistent/project") {repository {tree(path: "") {lastCommit {sha message}}}}}'; r($gitlab->apiGetByGraphqlTest($invalidPathQuery)) && p() && e(0); // 测试步骤5:查询不存在的项目路径