From 97bdc794a110ae86d695ff4aed73508bf311bcb9 Mon Sep 17 00:00:00 2001 From: liugang Date: Fri, 19 Sep 2025 22:25:20 +0800 Subject: [PATCH] * [misc] Enhance unit tests for companyModel::getOutsideCompanies() 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 --- .../test/model/getoutsidecompanies.php | 33 +++++++++++++------ 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/module/company/test/model/getoutsidecompanies.php b/module/company/test/model/getoutsidecompanies.php index 21ed62b827..203a4a6daa 100755 --- a/module/company/test/model/getoutsidecompanies.php +++ b/module/company/test/model/getoutsidecompanies.php @@ -1,20 +1,33 @@ #!/usr/bin/env php gen(2); /** -title=测试companyModel->getOutsideCompaniesTest(); -cid=1 -pid=1 +title=测试 companyModel::getOutsideCompanies(); +timeout=0 +cid=0 -查询外部公司 >> 外部公司 +- 步骤1:验证第一个外部公司存在属性2 @外部公司 +- 步骤2:验证返回数组长度(5个公司-内部公司1个=4个外部公司) @4 +- 步骤3:验证返回数组计数正确属性count(*) @4 +- 步骤4:验证内部公司ID=1不在结果中属性1 @ +- 步骤5:验证返回的键是2,3,4,5 + - 属性keys(*) @2 */ +include dirname(__FILE__, 5) . '/test/lib/init.php'; +include dirname(__FILE__, 2) . '/lib/company.unittest.class.php'; + +// 使用基础的公司数据配置文件,生成多个公司数据进行测试 +zendata('company')->loadYaml('company', false, 2)->gen(5); + +su('admin'); + $company = new companyTest(); -r($company->getOutsideCompaniesTest()) && p('2') && e('外部公司'); // 查询外部公司 + +r($company->getOutsideCompaniesTest()) && p('2') && e('外部公司'); // 步骤1:验证第一个外部公司存在 +r($company->getOutsideCompaniesTest()) && p() && e('4'); // 步骤2:验证返回数组长度(5个公司-内部公司1个=4个外部公司) +r($company->getOutsideCompaniesTest()) && p('count(*)') && e('4'); // 步骤3:验证返回数组计数正确 +r($company->getOutsideCompaniesTest()) && p('1') && e(''); // 步骤4:验证内部公司ID=1不在结果中 +r($company->getOutsideCompaniesTest()) && p('keys(*)') && e('2,3,4,5'); // 步骤5:验证返回的键是2,3,4,5 \ No newline at end of file