From 5ef3fef63db08157c79790a2168aa5e76008a7ea Mon Sep 17 00:00:00 2001 From: liugang Date: Wed, 5 Nov 2025 17:23:55 +0800 Subject: [PATCH] + [misc] Add unit tests for cneModel::apiGet() method MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- module/cne/test/model/apiget.php | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100755 module/cne/test/model/apiget.php diff --git a/module/cne/test/model/apiget.php b/module/cne/test/model/apiget.php new file mode 100755 index 0000000000..8ad5e8eaaa --- /dev/null +++ b/module/cne/test/model/apiget.php @@ -0,0 +1,27 @@ +#!/usr/bin/env php +apiGetTest('/api/cne/app/status', array('name' => 'test-app'), array(), '')) && p('code') && e('200'); // 测试步骤1:正常的API GET请求 +r($cneTest->apiGetTest('/api/cne/app/info', array('name' => 'my-app'), array(), '')) && p('data:name') && e('my-app'); // 测试步骤2:带查询参数的API GET请求 +r($cneTest->apiGetTest('/api/cne/app/error', array(), array(), '')) && p('code') && e('404'); // 测试步骤3:API返回404错误的情况 +r($cneTest->apiGetTest('/api/cne/app/auth-error', array(), array(), '')) && p('code') && e('401'); // 测试步骤4:API返回401认证错误的情况 +r($cneTest->apiGetTest('/api/cne/app/custom-host', array(), array(), 'http://custom-host')) && p('code') && e('200'); // 测试步骤5:使用自定义host的API GET请求 \ No newline at end of file