znt/module/instance/test/model/deletebackupcron.php

48 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=测试 instanceModel::deleteBackupCron();
timeout=0
cid=16789
- 步骤1正常情况 @1
- 步骤2不存在的ID @1
- 步骤3边界值0 @1
- 步骤4负数ID @1
- 步骤5空ID @1
*/
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/model.class.php';
zendata('cron')->loadYaml('cron_deletebackupcron', false, 2)->gen(10);
zendata('instance')->loadYaml('instance_deletebackupcron', false, 2)->gen(5);
su('admin');
$instanceTest = new instanceModelTest();
// 创建测试用的instance对象
$instance1 = new stdClass();
$instance1->id = 1;
$instance2 = new stdClass();
$instance2->id = 999;
$instance3 = new stdClass();
$instance3->id = 0;
$instance4 = new stdClass();
$instance4->id = -1;
$instance5 = new stdClass();
$instance5->id = '';
r($instanceTest->deleteBackupCronTest($instance1)) && p() && e(1); // 步骤1正常情况
r($instanceTest->deleteBackupCronTest($instance2)) && p() && e(1); // 步骤2不存在的ID
r($instanceTest->deleteBackupCronTest($instance3)) && p() && e(1); // 步骤3边界值0
r($instanceTest->deleteBackupCronTest($instance4)) && p() && e(1); // 步骤4负数ID
r($instanceTest->deleteBackupCronTest($instance5)) && p() && e(1); // 步骤5空ID