znt/module/repo/test/model/getcachefile.php

41 lines
1.3 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=测试 repoModel::getCacheFile();
timeout=0
cid=18050
- 步骤1正常情况 @1
- 步骤2空路径 @1
- 步骤3空版本号 @1
- 步骤4边界值 @1
- 步骤5特殊字符 @1
*/
// 1. 导入依赖
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/model.class.php';
// 2. zendata数据准备
$table = zenData('repo');
$table->id->range('1-5');
$table->name->range('repo1,repo2,repo3,repo4,repo5');
$table->SCM->range('Git{3},Subversion{2}');
$table->path->range('/path/to/repo1,/path/to/repo2,/path/to/repo3,/path/to/repo4,/path/to/repo5');
$table->gen(5);
// 3. 用户登录
su('admin');
// 4. 创建测试实例
$repoTest = new repoModelTest();
// 5. 执行测试步骤
r($repoTest->getCacheFileTest(1, 'src/main.php', 'v1.0.0')) && p() && e('1'); // 步骤1正常情况
r($repoTest->getCacheFileTest(2, '', 'HEAD')) && p() && e('1'); // 步骤2空路径
r($repoTest->getCacheFileTest(3, 'docs/readme.txt', '')) && p() && e('1'); // 步骤3空版本号
r($repoTest->getCacheFileTest(999, 'test/file.js', 'master')) && p() && e('1'); // 步骤4边界值
r($repoTest->getCacheFileTest(5, 'path/with spaces/file@#$.txt', 'branch-#123')) && p() && e('1'); // 步骤5特殊字符