znt/module/common/test/model/istutorialmode.php

56 lines
1.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=测试 commonModel::isTutorialMode();
timeout=0
cid=15684
- 执行commonTest模块的isTutorialModeTest方法 @0
- 执行commonTest模块的isTutorialModeTest方法 @0
- 执行commonTest模块的isTutorialModeTest方法 @1
- 执行commonTest模块的isTutorialModeTest方法 @0
- 执行commonTest模块的isTutorialModeTest方法 @1
*/
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/model.class.php';
su('admin');
$commonTest = new commonModelTest();
// 备份原始session状态
$originalTutorialMode = isset($_SESSION['tutorialMode']) ? $_SESSION['tutorialMode'] : null;
// 测试步骤1未设置tutorialMode默认状态
unset($_SESSION['tutorialMode']);
r($commonTest->isTutorialModeTest()) && p() && e('0');
// 测试步骤2设置tutorialMode为空字符串
$_SESSION['tutorialMode'] = '';
r($commonTest->isTutorialModeTest()) && p() && e('0');
// 测试步骤3设置tutorialMode为非空字符串
$_SESSION['tutorialMode'] = 'guide';
r($commonTest->isTutorialModeTest()) && p() && e('1');
// 测试步骤4设置tutorialMode为0
$_SESSION['tutorialMode'] = 0;
r($commonTest->isTutorialModeTest()) && p() && e('0');
// 测试步骤5设置tutorialMode为true
$_SESSION['tutorialMode'] = true;
r($commonTest->isTutorialModeTest()) && p() && e('1');
// 恢复原始session状态
if($originalTutorialMode !== null)
{
$_SESSION['tutorialMode'] = $originalTutorialMode;
}
else
{
unset($_SESSION['tutorialMode']);
}