znt/module/backup/test/zen/getbackuplist.php

41 lines
1.6 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=测试 backupZen::getBackupList();
timeout=0
cid=15146
- 步骤1测试获取备份列表返回类型为数组 @array
- 步骤2测试创建备份文件后列表数量大于0 @1
- 步骤4测试备份列表元素包含name属性 @1
- 步骤5测试备份列表元素包含files属性 @1
*/
// 1. 导入依赖
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/zen.class.php';
// 2. 用户登录
su('admin');
// 3. 创建测试实例
$backupTest = new backupZenTest();
// 4. 准备测试数据 - 创建测试备份文件
global $tester;
$backupPath = $tester->loadModel('backup')->getBackupPath();
$testBackupFile = $backupPath . 'test_getbackuplist_' . time() . '.sql.php';
file_put_contents($testBackupFile, '<?php die(); ?>');
// 5. 测试步骤 - 至少5个测试步骤
r(gettype($backupTest->getBackupListTest())) && p() && e('array'); // 步骤1测试获取备份列表返回类型为数组
r(count($backupTest->getBackupListTest()) > 0) && p() && e('1'); // 步骤2测试创建备份文件后列表数量大于0
$result = $backupTest->getBackupListTest(); $firstItem = reset($result); r(property_exists($firstItem, 'time') ? 1 : 0) && p() && e('1'); // 步骤3测试备份列表元素包含time属性
r(property_exists($firstItem, 'name') ? 1 : 0) && p() && e('1'); // 步骤4测试备份列表元素包含name属性
r(property_exists($firstItem, 'files') ? 1 : 0) && p() && e('1'); // 步骤5测试备份列表元素包含files属性
// 6. 清理测试文件
if(file_exists($testBackupFile)) unlink($testBackupFile);