znt/module/user/test/model/getprogramauthedusers.php

50 lines
2.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=测试 userModel::getProgramAuthedUsers();
timeout=0
cid=19626
- 步骤1正常情况 @2
- 步骤2包含利益相关者 @4
- 步骤3包含白名单用户 @4
- 步骤4父项目集内部公开 @4
- 步骤5多层父项目集权限 @6
*/
// 1. 导入依赖(路径固定,不可修改)
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/model.class.php';
// 2. zendata数据准备根据需要配置
$project = zenData('project');
$project->id->range('1-10');
$project->type->range('program{5},project{5}');
$project->parent->range('0{2},1{2},2{1},3{5}');
$project->path->range('`,1,`,`,1,2,`,`,1,2,3,`,`,1,3,`,`,4,`,`,4,5,`,`,4,6,`,`,4,7,`,`,4,8,`');
$project->name->range('项目集1,项目集2,子项目集1,子项目集2,子项目集3,项目1,项目2,项目3,项目4,项目5');
$project->openedBy->range('admin,user1,user2,user3,user4,admin,user1,user2,user3,user4');
$project->PM->range('pm1,pm2,pm3,pm4,pm5,pm1,pm2,pm3,pm4,pm5');
$project->acl->range('open{2},program{3},private{5}');
$project->gen(10);
$company = zenData('company');
$company->id->range('1');
$company->admins->range('admin,superuser');
$company->gen(1);
// 3. 用户登录(选择合适角色)
su('admin');
// 4. 创建测试实例(变量名与模块名一致)
$userTest = new userModelTest();
// 5. 🔴 强制要求必须包含至少5个测试步骤
r(count($userTest->getProgramAuthedUsersTest((object)array('id' => 1, 'openedBy' => 'admin', 'PM' => 'pm1', 'parent' => 0, 'acl' => 'open', 'path' => ',1,')))) && p() && e('2'); // 步骤1正常情况
r(count($userTest->getProgramAuthedUsersTest((object)array('id' => 2, 'openedBy' => 'user1', 'PM' => 'pm2', 'parent' => 0, 'acl' => 'open', 'path' => ',2,'), array('stakeholder1' => 'stakeholder1'), array(), array()))) && p() && e('4'); // 步骤2包含利益相关者
r(count($userTest->getProgramAuthedUsersTest((object)array('id' => 3, 'openedBy' => 'user2', 'PM' => 'pm3', 'parent' => 0, 'acl' => 'open', 'path' => ',3,'), array(), array('whitelist1' => 'whitelist1'), array()))) && p() && e('4'); // 步骤3包含白名单用户
r(count($userTest->getProgramAuthedUsersTest((object)array('id' => 4, 'openedBy' => 'user3', 'PM' => 'pm4', 'parent' => 1, 'acl' => 'program', 'path' => ',1,4,')))) && p() && e('4'); // 步骤4父项目集内部公开
r(count($userTest->getProgramAuthedUsersTest((object)array('id' => 5, 'openedBy' => 'user4', 'PM' => 'pm5', 'parent' => 4, 'acl' => 'program', 'path' => ',1,4,5,')))) && p() && e('6'); // 步骤5多层父项目集权限