znt/module/common/test/tao/checkprivbyrights.php

37 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=测试 commonTao::checkPrivByRights();
timeout=0
cid=15723
- 步骤1正常权限检查情况 @1
- 步骤2无数据库权限情况 @0
- 步骤3acls['views']为空的情况 @1
- 步骤4特殊模块处理情况 @1
- 步骤5产品模块特殊处理 @1
- 步骤6系统默认返回true的情况 @1
- 步骤7views配置中不包含对应菜单 @0
*/
// 1. 导入依赖(路径固定,不可修改)
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/tao.class.php';
// 2. 用户登录(选择合适角色)
su('admin');
// 3. 创建测试实例(变量名与模块名一致)
$commonTest = new commonTaoTest();
// 4. 强制要求必须包含至少5个测试步骤
r($commonTest->checkPrivByRightsTest('user', 'browse', array('views' => array('system' => true)), null)) && p() && e('1'); // 步骤1正常权限检查情况
r($commonTest->checkPrivByRightsTest('user', 'edit', array('views' => array('system' => true)), 'no_db_priv')) && p() && e('0'); // 步骤2无数据库权限情况
r($commonTest->checkPrivByRightsTest('task', 'view', array(), null)) && p() && e('1'); // 步骤3acls['views']为空的情况
r($commonTest->checkPrivByRightsTest('my', 'team', array('views' => array('system' => true)), null)) && p() && e('1'); // 步骤4特殊模块处理情况
r($commonTest->checkPrivByRightsTest('story', 'view', array('views' => array('product' => true)), null)) && p() && e('1'); // 步骤5产品模块特殊处理
r($commonTest->checkPrivByRightsTest('index', 'dashboard', array('views' => array('project' => true)), null)) && p() && e('1'); // 步骤6系统默认返回true的情况
r($commonTest->checkPrivByRightsTest('bug', 'create', array('views' => array('product' => true)), null)) && p() && e('0'); // 步骤7views配置中不包含对应菜单