znt/module/holiday/test/model/isholiday.php

49 lines
2.5 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=测试 holidayModel::isHoliday();
timeout=0
cid=16747
- 步骤1正常节假日元旦 @It is a holiday
- 步骤2正常工作日不在节假日范围 @It is not a holiday
- 步骤3边界值测试节假日开始日期 @It is a holiday
- 步骤4边界值测试节假日结束日期 @It is a holiday
- 步骤5异常输入空字符串 @It is not a holiday
- 步骤6异常输入无效日期格式 @It is not a holiday
- 步骤7测试工作日类型记录不认为是节假日 @It is not a holiday
*/
// 1. 导入依赖(路径固定,不可修改)
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/model.class.php';
// 2. zendata数据准备 - 手动插入数据确保准确性
global $tester;
$tester->dbh->query('DELETE FROM zt_holiday');
$tester->dbh->query('INSERT INTO zt_holiday (id, name, type, year, begin, end, `desc`) VALUES
(1, "元旦", "holiday", "2024", "2024-01-01", "2024-01-01", "元旦节假日"),
(2, "春节", "holiday", "2024", "2024-02-10", "2024-02-17", "春节节假日"),
(3, "清明节", "holiday", "2024", "2024-04-04", "2024-04-06", "清明节假日"),
(4, "劳动节", "holiday", "2024", "2024-05-01", "2024-05-03", "劳动节节假日"),
(5, "补班日", "working", "2024", "2024-02-18", "2024-02-18", "补班日")');
zenData('user')->gen(1);
// 3. 用户登录
su('admin');
// 4. 创建测试实例
$holidayTest = new holidayModelTest();
// 5. 测试步骤至少5个
r($holidayTest->isHolidayTest('2024-01-01')) && p() && e('It is a holiday'); // 步骤1正常节假日元旦
r($holidayTest->isHolidayTest('2024-03-15')) && p() && e('It is not a holiday'); // 步骤2正常工作日不在节假日范围
r($holidayTest->isHolidayTest('2024-02-10')) && p() && e('It is a holiday'); // 步骤3边界值测试节假日开始日期
r($holidayTest->isHolidayTest('2024-02-17')) && p() && e('It is a holiday'); // 步骤4边界值测试节假日结束日期
r($holidayTest->isHolidayTest('')) && p() && e('It is not a holiday'); // 步骤5异常输入空字符串
r($holidayTest->isHolidayTest('invalid-date')) && p() && e('It is not a holiday'); // 步骤6异常输入无效日期格式
r($holidayTest->isHolidayTest('2024-02-18')) && p() && e('It is not a holiday'); // 步骤7测试工作日类型记录不认为是节假日