znt/module/dept/test/model/updateorder.php

46 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=测试 deptModel::updateOrder();
timeout=0
cid=15981
- 测试步骤1正常多部门排序更新 @1
- 测试步骤2单个部门排序更新 @1
- 测试步骤3空数组输入测试 @1
- 测试步骤4不存在部门ID测试 @1
- 测试步骤5验证排序结果正确性 @1
*/
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/model.class.php';
su('admin');
global $tester;
// 直接准备测试数据避免zendata问题
$tester->dao->delete()->from(TABLE_DEPT)->exec();
for($i = 1; $i <= 10; $i++)
{
$dept = new stdClass();
$dept->id = $i;
$dept->name = "部门{$i}";
$dept->parent = $i <= 5 ? 0 : 1;
$dept->path = $i <= 5 ? ",{$i}," : ",1,{$i},";
$dept->grade = $i <= 5 ? 1 : 2;
$dept->order = $i;
$dept->manager = '';
$tester->dao->insert(TABLE_DEPT)->data($dept)->exec();
}
$deptTest = new deptModelTest();
r($deptTest->updateOrderTest(array('3', '1', '5', '2', '4'))) && p() && e('1'); // 测试步骤1正常多部门排序更新
r($deptTest->updateOrderTest(array('6'))) && p() && e('1'); // 测试步骤2单个部门排序更新
r($deptTest->updateOrderTest(array())) && p() && e('1'); // 测试步骤3空数组输入测试
r($deptTest->updateOrderTest(array('999', '888'))) && p() && e('1'); // 测试步骤4不存在部门ID测试
r($deptTest->updateOrderSimpleTest(array('7', '8', '9'))) && p() && e('1'); // 测试步骤5验证排序结果正确性