+ Add unit test case for solution->getByID.
This commit is contained in:
@@ -21,7 +21,7 @@ class solutionModel extends model
|
||||
*/
|
||||
public function getByID(int $solutionID): ?object
|
||||
{
|
||||
$solution = $this->dao->select('*')->from(TABLE_SOLUTION)->where('id')->eq($solutionID)->fetch();
|
||||
$solution = $this->dao->select('*')->from(TABLE_SOLUTION)->where('id')->eq($solutionID)->fetch();
|
||||
if(!$solution) return null;
|
||||
|
||||
$solution->instances = array();
|
||||
|
||||
Executable
+42
@@ -0,0 +1,42 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
|
||||
/**
|
||||
|
||||
title=测试 solutionModel->getByID();
|
||||
timeout=0
|
||||
cid=1
|
||||
|
||||
- 解决方案ID为空 @0
|
||||
- 解决方案ID存在
|
||||
- 属性name @禅道 DevOps 解决方案1
|
||||
- 属性status @notEnoughResource
|
||||
- 解决方案ID存在,检查实例数量 @3
|
||||
- 解决方案ID存在
|
||||
- 属性name @禅道 DevOps 解决方案2
|
||||
- 属性status @notEnoughResource
|
||||
- 解决方案ID存在,检查实例数量 @1
|
||||
- 解决方案ID不存在 @0
|
||||
|
||||
*/
|
||||
|
||||
include dirname(__FILE__, 5) . '/test/lib/init.php';
|
||||
include dirname(__FILE__, 2) . '/solution.class.php';
|
||||
|
||||
zdTable('space')->config('space')->gen(2);
|
||||
zdTable('solution')->config('solution')->gen(2);
|
||||
zdTable('instance')->config('instance')->gen(4);
|
||||
|
||||
$solutionModel = new solutionTest();
|
||||
|
||||
r($solutionModel->getByIdTest(0)) && p() && e('0'); // 解决方案ID为空
|
||||
|
||||
$solution = $solutionModel->getByIdTest(1);
|
||||
r($solution) && p('name,status') && e('禅道 DevOps 解决方案1,notEnoughResource'); // 解决方案ID存在
|
||||
r(count($solution->instances)) && p() && e('3'); // 解决方案ID存在,检查实例数量
|
||||
|
||||
$solution = $solutionModel->getByIdTest(2);
|
||||
r($solution) && p('name,status') && e('禅道 DevOps 解决方案2,notEnoughResource'); // 解决方案ID存在
|
||||
r(count($solution->instances)) && p() && e('1'); // 解决方案ID存在,检查实例数量
|
||||
|
||||
r($solutionModel->getByIdTest(5)) && p() && e('0'); // 解决方案ID不存在
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* The test class file of solution module of ZenTaoPMS.
|
||||
*
|
||||
* @copyright Copyright 2009-2023 禅道软件(青岛)有限公司(ZenTao Software (Qingdao) Co., Ltd. www.zentao.net)
|
||||
* @license ZPL(https://zpl.pub/page/zplv12.html) or AGPL(https://www.gnu.org/licenses/agpl-3.0.en.html)
|
||||
* @author Yanyi Cao <caoyanyi@easycorp.ltd>
|
||||
* @package solution
|
||||
* @link https://www.zentao.net
|
||||
*/
|
||||
class solutionTest
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
su('admin');
|
||||
|
||||
global $tester;
|
||||
$this->objectModel = $tester->loadModel('solution');
|
||||
}
|
||||
|
||||
public function getByIdTest(int $solutionID): object|null
|
||||
{
|
||||
return $this->objectModel->getByID($solutionID);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
---
|
||||
title: instance
|
||||
author: Yanyi Cao
|
||||
version: "1.0"
|
||||
fields:
|
||||
- field: id
|
||||
range: 1-4
|
||||
- field: space
|
||||
range: '1{2},2{2}'
|
||||
- field: solution
|
||||
range: '1{3},2'
|
||||
- field: name
|
||||
range: '`Jenkins`,`GitLab`,`GitLab`,`Jenkins`'
|
||||
- field: appID
|
||||
range: '`59`,`58`,`58`,`59`'
|
||||
- field: appName
|
||||
range: '`Jenkins`,`GitLab`,`GitLab`,`Jenkins`'
|
||||
- field: appVersion
|
||||
range: '`2.401.3`,`15.3.4`,`15.3.4`,`2.401.3`'
|
||||
- field: chart
|
||||
range: '`jenkins`,`gitlab`,`gitlab`,`jenkins`'
|
||||
- field: logo
|
||||
range: '`//img.qucheng.com/app/j/jenkins-icon.svg`,`//img.qucheng.com/app/g/gitlab-icon.svg`,`//img.qucheng.com/app/g/gitlab-icon.svg`,`//img.qucheng.com/app/j/jenkins-icon.svg`'
|
||||
- field: version
|
||||
range: '`2023.10.901`'
|
||||
- field: desc
|
||||
range: '`Jenkins是国际上流行的免费开源软件项目,是基于Java开发持续集成工具,用于监控持续重复的工作,旨在提供一个开放的易用的软件平台,使软件的持续集成自动化,大大节约人力和时效。`,`GitLab是由GitLab
|
||||
Inc.开发,使用MIT许可证的基于网络的Git仓库管理工具,且具有wiki和issue跟踪功能。使用Git作为代码管理工具,并在此基础上搭建起来的web服务。`,`GitLab是由GitLab
|
||||
Inc.开发,使用MIT许可证的基于网络的Git仓库管理工具,且具有wiki和issue跟踪功能。使用Git作为代码管理工具,并在此基础上搭建起来的web服务。`,`Jenkins是国际上流行的免费开源软件项目,是基于Java开发持续集成工具,用于监控持续重复的工作,旨在提供一个开放的易用的软件平台,使软件的持续集成自动化,大大节约人力和时效。`'
|
||||
- field: introduction
|
||||
range: '`基于Java开发的一款持续集成工具`,`GitLab 一款基于Git的一体化软件开发平台。`,`GitLab 一款基于Git的一体化软件开发平台。`,`基于Java开发的一款持续集成工具`'
|
||||
- field: source
|
||||
range: '`cloud`'
|
||||
- field: channel
|
||||
range: '`stable`'
|
||||
- field: k8name
|
||||
range: '`jenkins-20231019112830`,`gitlab-20231019131424`,`gitlab-20231025104407`,`jenkins-20231025104735`'
|
||||
- field: status
|
||||
range: '`running`,`starting`,,'
|
||||
- field: pinned
|
||||
range: "0"
|
||||
- field: domain
|
||||
range: '`jvud.devops.corp.cc`,`gmip.devops.corp.cc`,`9krd.devops.corp.cc`,`adkm.devops.corp.cc`'
|
||||
- field: smtpSnippetName
|
||||
range: ""
|
||||
- field: ldapSnippetName
|
||||
range: ""
|
||||
- field: ldapSettings
|
||||
range: ""
|
||||
- field: dbSettings
|
||||
range: '`{"ingress":{"enabled":true,"host":"jvud.devops.corp.cc"},"global":{"ingress":{"enabled":true,"host":"jvud.devops.corp.cc"}},"ci":{"enabled":true},"mysql":{"enabled":false,"auth":{"user":"user_52","password":"vmqA3pzlswbB","host":"qucheng-mysql.quickon-system.svc","port":3306,"database":"db_52","dbservice":{"name":"qucheng-mysql","namespace":"quickon-system"}}}}`,`{"ingress":{"enabled":true,"host":"gmip.devops.corp.cc"},"global":{"ingress":{"enabled":true,"host":"gmip.devops.corp.cc"}},"ci":{"enabled":true},"mysql":{"enabled":false,"auth":{"user":"user_53","password":"cjPmBztaTYvy","host":"qucheng-mysql.quickon-system.svc","port":3306,"database":"db_53","dbservice":{"name":"qucheng-mysql","namespace":"quickon-system"}}}}`,`{"ingress":{"enabled":true,"host":"9krd.devops.corp.cc"},"global":{"ingress":{"enabled":true,"host":"9krd.devops.corp.cc"}},"ci":{"enabled":true},"mysql":{"enabled":false,"auth":{"user":"user_54","password":"GTFyIESAUjsP","host":"qucheng-mysql.quickon-system.svc","port":3306,"database":"db_54","dbservice":{"name":"qucheng-mysql","namespace":"quickon-system"}}}}`,`{"ingress":{"enabled":true,"host":"adkm.devops.corp.cc"},"global":{"ingress":{"enabled":true,"host":"adkm.devops.corp.cc"}},"ci":{"enabled":true},"mysql":{"enabled":false,"auth":{"user":"user_55","password":"wvKn8a7JyxcZ","host":"qucheng-mysql.quickon-system.svc","port":3306,"database":"db_55","dbservice":{"name":"qucheng-mysql","namespace":"quickon-system"}}}}`'
|
||||
- field: autoBackup
|
||||
range: "0"
|
||||
- field: backupKeepDays
|
||||
range: '`1`'
|
||||
- field: autoRestore
|
||||
range: "0"
|
||||
- field: env
|
||||
range: ""
|
||||
- field: createdBy
|
||||
range: '`wwccss`'
|
||||
- field: createdAt
|
||||
range: '`2023-10-19 11:28:30`,`2023-10-19 13:14:24`,`2023-10-25 10:44:07`,`2023-10-25 10:47:35`'
|
||||
- field: deleted
|
||||
range: "0"
|
||||
...
|
||||
@@ -0,0 +1,43 @@
|
||||
---
|
||||
title: solution
|
||||
author: Yanyi Cao
|
||||
version: "1.0"
|
||||
fields:
|
||||
- field: id
|
||||
range: 1-2
|
||||
- field: name
|
||||
prefix: '禅道 DevOps 解决方案'
|
||||
range: 1-2
|
||||
- field: appID
|
||||
range: '`2`'
|
||||
- field: appName
|
||||
range: '`devops`'
|
||||
- field: appVersion
|
||||
range: '`1.1.0`'
|
||||
- field: version
|
||||
range: '`2023.10.901`'
|
||||
- field: chart
|
||||
range: '`devops`'
|
||||
- field: cover
|
||||
range: '`https://img.qucheng.com/app/d/devops-bg.png`'
|
||||
- field: desc
|
||||
range: '`禅道 DevOps 解决方案是一套软件全生命周期管理、跟踪、集成、发布解决方案。包含禅道项目管理工具、代码仓库、集成工具等。用户可以跟踪软件项目进度,管理代码的集成与发布。`'
|
||||
- field: introduction
|
||||
range: '`覆盖从立项到发布,端到端的软件开发全流程跟踪。全面集成 Jenkins、Gitlab 等工具。`'
|
||||
- field: source
|
||||
range: '`cloud`'
|
||||
- field: channel
|
||||
range: '`stable`'
|
||||
- field: components
|
||||
range: '`{"git":{"id":58,"name":"gitlab","alias":"GitLab","chart":"gitlab","app_version":"15.3.4","version":"2023.10.901","logo":"https:\/\/img.qucheng.com\/app\/g\/gitlab-icon.svg","status":"installed"},"ci":{"id":59,"name":"jenkins","alias":"Jenkins","chart":"jenkins","app_version":"2.401.3","version":"2023.10.901","logo":"https:\/\/img.qucheng.com\/app\/j\/jenkins-icon.svg","status":"installing"}}`'
|
||||
- field: status
|
||||
range: '`notEnoughResource`'
|
||||
- field: deleted
|
||||
range: "0"
|
||||
- field: createdBy
|
||||
range: '`wwccss`'
|
||||
- field: createdAt
|
||||
range: '`2023-10-16 09:25:07`'
|
||||
- field: updatedDate
|
||||
range: '`2023-12-08 16:10:08`'
|
||||
...
|
||||
@@ -0,0 +1,20 @@
|
||||
---
|
||||
title: space
|
||||
author: Yanyi Cao
|
||||
version: "1.0"
|
||||
fields:
|
||||
- field: id
|
||||
range: 1-2
|
||||
- field: name
|
||||
range: '`默认空间`'
|
||||
- field: k8space
|
||||
range: '`quickon-app`'
|
||||
- field: owner
|
||||
range: '`wwccss`,'
|
||||
- field: default
|
||||
range: '`1`'
|
||||
- field: createdAt
|
||||
range: '`2023-08-29 11:20:29`,`2023-10-16 09:25:11`'
|
||||
- field: deleted
|
||||
range: "0"
|
||||
...
|
||||
Reference in New Issue
Block a user