+ [misc] Add unit tests for backupModel::backSQL() method

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
liugang
2025-09-15 15:06:09 +08:00
co-authored by Claude
parent 1e70eadb30
commit 985551affd
2 changed files with 54 additions and 0 deletions
@@ -0,0 +1,25 @@
<?php
declare(strict_types = 1);
class backupTest
{
public function __construct()
{
global $tester;
$this->objectModel = $tester->loadModel('backup');
}
/**
* Test backSQL method.
*
* @param string $backupFile
* @access public
* @return mixed
*/
public function backSQLTest($backupFile = null)
{
$result = $this->objectModel->backSQL($backupFile);
if(dao::isError()) return dao::getError();
return $result;
}
}
+29
View File
@@ -0,0 +1,29 @@
#!/usr/bin/env php
<?php
/**
title=测试 backupModel::backSQL();
timeout=0
cid=0
- 执行backupTest模块的backSQLTest方法,参数是'/tmp/test_backup' 属性result @1
- 执行backupTest模块的backSQLTest方法,参数是'backup/test.sql' 属性result @~~
- 执行backupTest模块的backSQLTest方法,参数是'/tmp/zentao_backup.sql' 属性result @1
- 执行backupTest模块的backSQLTest方法,参数是'/tmp/very_long_backup_file_name_for_testing_purpose.sql' 属性result @1
- 执行backupTest模块的backSQLTest方法,参数是'/tmp/backup_测试-2024.sql' 属性result @1
*/
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/backup.unittest.class.php';
su('admin');
$backupTest = new backupTest();
r($backupTest->backSQLTest('/tmp/test_backup')) && p('result') && e('1');
r($backupTest->backSQLTest('backup/test.sql')) && p('result') && e('~~');
r($backupTest->backSQLTest('/tmp/zentao_backup.sql')) && p('result') && e('1');
r($backupTest->backSQLTest('/tmp/very_long_backup_file_name_for_testing_purpose.sql')) && p('result') && e('1');
r($backupTest->backSQLTest('/tmp/backup_测试-2024.sql')) && p('result') && e('1');