znt/module/sonarqube/test/model/apigetreport.php

40 lines
2 KiB
PHP
Executable file
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env php
<?php
/**
title=测试 sonarqubeModel::apiGetReport();
timeout=0
cid=18379
- 步骤1无效sonarqubeID和空projectKey @return empty
- 步骤2不存在的sonarqubeID @return empty
- 步骤3不存在的projectKey第0条的msg属性 @Component key 'wrong_project' not found
- 步骤4无效的metricKeys第0条的msg属性 @The following metric keys are not found: invalid_metric
- 步骤5使用默认metricKeys第component条的key属性 @unittest
- 步骤6使用单个有效metricKeys第component条的key属性 @unittest
- 步骤7使用多个有效metricKeys第component条的key属性 @unittest
*/
// 1. 导入依赖
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/model.class.php';
// 2. zendata数据准备
zenData('pipeline')->loadYaml('pipeline')->gen(5);
// 3. 用户登录
su('admin');
// 4. 创建测试实例
$sonarqubeTest = new sonarqubeModelTest();
// 5. 测试步骤必须包含至少5个测试步骤
r($sonarqubeTest->apiGetReportTest(0, '')) && p() && e('return empty'); // 步骤1无效sonarqubeID和空projectKey
r($sonarqubeTest->apiGetReportTest(999, 'nonexistent')) && p() && e('return empty'); // 步骤2不存在的sonarqubeID
r($sonarqubeTest->apiGetReportTest(2, 'wrong_project')) && p('0:msg') && e("Component key 'wrong_project' not found"); // 步骤3不存在的projectKey
r($sonarqubeTest->apiGetReportTest(2, 'unittest', 'invalid_metric')) && p('0:msg') && e("The following metric keys are not found: invalid_metric"); // 步骤4无效的metricKeys
r($sonarqubeTest->apiGetReportTest(2, 'unittest', '')) && p('component:key') && e('unittest'); // 步骤5使用默认metricKeys
r($sonarqubeTest->apiGetReportTest(2, 'unittest', 'bugs')) && p('component:key') && e('unittest'); // 步骤6使用单个有效metricKeys
r($sonarqubeTest->apiGetReportTest(2, 'unittest', 'bugs,coverage,vulnerabilities')) && p('component:key') && e('unittest'); // 步骤7使用多个有效metricKeys