znt/module/dataview/test/model/gentreeoptions.php

35 lines
1.6 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=测试 dataviewModel::genTreeOptions();
timeout=0
cid=15952
- 步骤1单层路径创建 @Root Node
- 步骤2多层路径创建 @Level 3
- 步骤3现有节点扩展 @New Node
- 步骤4多个兄弟节点第一个 @Branch 1
- 步骤5多个兄弟节点第二个 @Branch 2
*/
// 1. 导入依赖(路径固定,不可修改)
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/model.class.php';
// 2. 用户登录(选择合适角色)
su('admin');
// 3. 创建测试实例(变量名与模块名一致)
$dataviewTest = new dataviewModelTest();
// 4. 🔴 强制要求必须包含至少5个测试步骤
$tree1 = new stdclass();
r($dataviewTest->genTreeOptionsTest($tree1, array('root' => 'Root Node'), array('root'))->children[0]->title) && p() && e('Root Node'); // 步骤1单层路径创建
$tree2 = new stdclass();
r($dataviewTest->genTreeOptionsTest($tree2, array('level1' => 'Level 1', 'level2' => 'Level 2', 'level3' => 'Level 3'), array('level1', 'level2', 'level3'))->children[0]->children[0]->children[0]->title) && p() && e('Level 3'); // 步骤2多层路径创建
r($dataviewTest->genTreeOptionsTestWithExisting(array('existing' => 'Existing Node', 'new' => 'New Node'), array('existing', 'new'))->children[0]->children[0]->title) && p() && e('New Node'); // 步骤3现有节点扩展
r($dataviewTest->genTreeOptionsTestMultiple()['tree']->children[0]->title) && p() && e('Branch 1'); // 步骤4多个兄弟节点第一个
r($dataviewTest->genTreeOptionsTestMultiple()['tree']->children[1]->title) && p() && e('Branch 2'); // 步骤5多个兄弟节点第二个