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

58 lines
2.1 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::apiGetProjects();
timeout=0
cid=18377
- 步骤1正常情况第0条的name属性 @Special Key Test
- 步骤2关键字搜索第0条的key属性 @special.key:test-123
- 步骤3projectKey查询 @return empty
- 步骤4无效ID(0) @return empty
- 步骤5无效ID(999) @return empty
- 步骤6组合参数 @return empty
- 步骤7空关键字第0条的name属性 @Special Key Test
*/
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/model.class.php';
// 准备测试数据
zenData('pipeline')->loadYaml('pipeline')->gen(5);
// 设置用户登录
su('admin');
// 创建测试实例
$sonarqube = new sonarqubeModelTest();
// 测试参数定义
$validSonarqubeID = 2;
$invalidSonarqubeID1 = 0;
$invalidSonarqubeID2 = 999;
$keyword = 'test';
$projectKey = 'unittest-project';
$emptyKeyword = '';
// 测试步骤1正常sonarqubeID获取项目列表
r($sonarqube->apiGetProjectsTest($validSonarqubeID)) && p('0:name') && e('Special Key Test'); // 步骤1正常情况
// 测试步骤2使用关键字搜索项目
r($sonarqube->apiGetProjectsTest($validSonarqubeID, $keyword)) && p('0:key') && e('special.key:test-123'); // 步骤2关键字搜索
// 测试步骤3使用projectKey参数获取特定项目
r($sonarqube->apiGetProjectsTest($validSonarqubeID, '', $projectKey)) && p() && e('return empty'); // 步骤3projectKey查询
// 测试步骤4无效sonarqubeID0测试
r($sonarqube->apiGetProjectsTest($invalidSonarqubeID1)) && p() && e('return empty'); // 步骤4无效ID(0)
// 测试步骤5无效sonarqubeID999测试
r($sonarqube->apiGetProjectsTest($invalidSonarqubeID2)) && p() && e('return empty'); // 步骤5无效ID(999)
// 测试步骤6同时使用keyword和projectKey参数
r($sonarqube->apiGetProjectsTest($validSonarqubeID, $keyword, $projectKey)) && p() && e('return empty'); // 步骤6组合参数
// 测试步骤7使用空关键字搜索相当于获取所有项目
r($sonarqube->apiGetProjectsTest($validSonarqubeID, $emptyKeyword)) && p('0:name') && e('Special Key Test'); // 步骤7空关键字