znt/module/setting/test/model/getursr.php

51 lines
1.8 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=测试 settingModel::getURSR();
timeout=0
cid=18363
- 执行settingTest模块的getURSRTest方法 @12345
- 执行settingTest模块的getURSRTest方法参数是true @2
- 执行settingTest模块的getURSRTest方法参数是true @0
- 执行settingTest模块的getURSRTest方法参数是true @0
- 执行settingTest模块的getURSRTest方法参数是true @12345
*/
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/model.class.php';
// 准备测试数据创建包含URSR配置的config记录
$configTable = zenData('config');
$configTable->owner->range('system');
$configTable->module->range('custom');
$configTable->section->range('');
$configTable->key->range('URSR,other1,other2,other3,other4');
$configTable->value->range('2,value1,value2,value3,value4');
$configTable->gen(5);
su('admin');
$settingTest = new settingModelTest();
// 步骤1测试从配置文件获取URSR如果配置中存在URSR
r($settingTest->getURSRTest()) && p() && e('12345');
// 步骤2测试从数据库config表获取URSR清空配置中的URSR
r($settingTest->getURSRTest(true)) && p() && e('2');
// 步骤3清空config中的URSR记录测试不存在的情况
global $tester;
$tester->dao->delete()->from(TABLE_CONFIG)->where('`key`')->eq('URSR')->exec();
r($settingTest->getURSRTest(true)) && p() && e('0');
// 步骤4重新插入URSR配置值为空字符串
$tester->dao->insert(TABLE_CONFIG)->data(array('owner' => 'system', 'module' => 'custom', 'section' => '', 'key' => 'URSR', 'value' => ''))->exec();
r($settingTest->getURSRTest(true)) && p() && e('0');
// 步骤5更新URSR配置为数字字符串
$tester->dao->update(TABLE_CONFIG)->set('value')->eq('12345')->where('`key`')->eq('URSR')->exec();
r($settingTest->getURSRTest(true)) && p() && e('12345');