+ [misc] Add unit tests for testtaskModel::initCase() method
🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -977,4 +977,29 @@ class testtaskTest
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test initCase method.
|
||||
*
|
||||
* @param int $product
|
||||
* @param string $title
|
||||
* @param string $now
|
||||
* @param string $auto
|
||||
* @param string $frame
|
||||
* @param string $type
|
||||
* @param string $stage
|
||||
* @access public
|
||||
* @return object
|
||||
*/
|
||||
public function initCaseTest(int $product, string $title, string $now, string $auto, string $frame, string $type = 'unit', string $stage = 'unittest'): object
|
||||
{
|
||||
$reflection = new ReflectionClass($this->objectModel);
|
||||
$method = $reflection->getMethod('initCase');
|
||||
$method->setAccessible(true);
|
||||
|
||||
$result = $method->invokeArgs($this->objectModel, [$product, $title, $now, $auto, $frame, $type, $stage]);
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
Executable
+35
@@ -0,0 +1,35 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
|
||||
/**
|
||||
|
||||
title=测试 testtaskModel::initCase();
|
||||
timeout=0
|
||||
cid=0
|
||||
|
||||
- 执行testtaskTest模块的initCaseTest方法,参数是1, 'Test Case Title', '2024-01-01 10:00:00', 'no', 'phpunit' 属性product @1
|
||||
- 执行testtaskTest模块的initCaseTest方法,参数是2, 'Another Test Case', '2024-01-02 11:00:00', 'yes', 'jest' 属性type @unit
|
||||
- 执行testtaskTest模块的initCaseTest方法,参数是3, 'Feature Test Case', '2024-01-03 12:00:00', 'no', 'selenium', 'feature', 'functest' 属性type @feature
|
||||
- 执行testtaskTest模块的initCaseTest方法,参数是0, '', '2024-01-04 13:00:00', 'yes', '' 属性product @0
|
||||
- 执行testtaskTest模块的initCaseTest方法,参数是999, 'Large Product ID Test Case', '2024-12-31 23:59:59', 'auto', 'custom' 属性frame @custom
|
||||
|
||||
*/
|
||||
|
||||
include dirname(__FILE__, 5) . '/test/lib/init.php';
|
||||
include dirname(__FILE__, 2) . '/lib/testtask.unittest.class.php';
|
||||
|
||||
$user = zenData('user');
|
||||
$user->account->range('admin,test1,test2');
|
||||
$user->realname->range('管理员,测试用户1,测试用户2');
|
||||
$user->password->range('123456');
|
||||
$user->gen(3);
|
||||
|
||||
su('admin');
|
||||
|
||||
$testtaskTest = new testtaskTest();
|
||||
|
||||
r($testtaskTest->initCaseTest(1, 'Test Case Title', '2024-01-01 10:00:00', 'no', 'phpunit')) && p('product') && e('1');
|
||||
r($testtaskTest->initCaseTest(2, 'Another Test Case', '2024-01-02 11:00:00', 'yes', 'jest')) && p('type') && e('unit');
|
||||
r($testtaskTest->initCaseTest(3, 'Feature Test Case', '2024-01-03 12:00:00', 'no', 'selenium', 'feature', 'functest')) && p('type') && e('feature');
|
||||
r($testtaskTest->initCaseTest(0, '', '2024-01-04 13:00:00', 'yes', '')) && p('product') && e('0');
|
||||
r($testtaskTest->initCaseTest(999, 'Large Product ID Test Case', '2024-12-31 23:59:59', 'auto', 'custom')) && p('frame') && e('custom');
|
||||
Reference in New Issue
Block a user