|
40 | 40 |
|
41 | 41 | class ReminderTest extends DbTestCase |
42 | 42 | { |
43 | | - public function testAddVisibilityRestrict() |
44 | | - { |
45 | | - $e2e_root = getItemByTypeName('Entity', 'E2ETestEntity', true); |
46 | | - $e2e_test_child1 = getItemByTypeName('Entity', 'E2ETestSubEntity1', true); |
47 | | - $e2e_test_child2 = getItemByTypeName('Entity', 'E2ETestSubEntity2', true); |
48 | | - $test_root = getItemByTypeName('Entity', '_test_root_entity', true); |
49 | | - $test_child_1 = getItemByTypeName('Entity', '_test_child_1', true); |
50 | | - $test_child_2 = getItemByTypeName('Entity', '_test_child_2', true); |
51 | | - $test_child_3 = getItemByTypeName('Entity', '_test_child_3', true); |
52 | | - |
53 | | - $all_entities = "'0', '$test_root', '$e2e_root', '$e2e_test_child1', '$e2e_test_child2', '$test_child_1', '$test_child_2', '$test_child_3'"; |
54 | | - |
55 | | - //first, as a super-admin |
56 | | - $this->login(); |
57 | | - $users_id = \Session::getLoginUserID(); |
58 | | - $expected = preg_replace('/\s+/', ' ', "(`glpi_reminders`.`users_id` = '$users_id' |
59 | | - OR `glpi_reminders_users`.`users_id` = '$users_id' |
60 | | - OR (`glpi_profiles_reminders`.`profiles_id` = '4' |
61 | | - AND (`glpi_profiles_reminders`.`no_entity_restriction` = '1' |
62 | | - OR ((`glpi_profiles_reminders`.`entities_id` IN ('$test_root', '$test_child_1', '$test_child_2', '$test_child_3') |
63 | | - OR (`glpi_profiles_reminders`.`is_recursive` = '1' |
64 | | - AND `glpi_profiles_reminders`.`entities_id` IN ('0')))))) |
65 | | - OR ((`glpi_entities_reminders`.`entities_id` IN ('$test_root', '$test_child_1', '$test_child_2', '$test_child_3') |
66 | | - OR (`glpi_entities_reminders`.`is_recursive` = '1' |
67 | | - AND `glpi_entities_reminders`.`entities_id` IN ('0')))))"); |
68 | | - $this->assertSame( |
69 | | - $expected, |
70 | | - \Reminder::addVisibilityRestrict() |
71 | | - ); |
72 | | - |
73 | | - $this->login('normal', 'normal'); |
74 | | - $expected = preg_replace('/\s+/', ' ', "(`glpi_reminders`.`users_id` = '5' |
75 | | - OR `glpi_reminders_users`.`users_id` = '5' |
76 | | - OR (`glpi_profiles_reminders`.`profiles_id` = '2' |
77 | | - AND (`glpi_profiles_reminders`.`no_entity_restriction` = '1' |
78 | | - OR (`glpi_profiles_reminders`.`entities_id` IN ($all_entities)))) |
79 | | - OR (`glpi_entities_reminders`.`entities_id` IN ($all_entities)))"); |
80 | | - $this->assertSame( |
81 | | - $expected, |
82 | | - trim(preg_replace('/\s+/', ' ', \Reminder::addVisibilityRestrict())) |
83 | | - ); |
84 | | - |
85 | | - $this->login('tech', 'tech'); |
86 | | - $expected = preg_replace('/\s+/', ' ', "(`glpi_reminders`.`users_id` = '4' |
87 | | - OR `glpi_reminders_users`.`users_id` = '4' |
88 | | - OR (`glpi_profiles_reminders`.`profiles_id` = '6' |
89 | | - AND (`glpi_profiles_reminders`.`no_entity_restriction` = '1' |
90 | | - OR (`glpi_profiles_reminders`.`entities_id` IN ($all_entities)))) |
91 | | - OR (`glpi_entities_reminders`.`entities_id` IN ($all_entities)))"); |
92 | | - $this->assertSame( |
93 | | - $expected, |
94 | | - trim(preg_replace('/\s+/', ' ', \Reminder::addVisibilityRestrict())) |
95 | | - ); |
96 | | - |
97 | | - $bkp_groups = $_SESSION['glpigroups']; |
98 | | - $_SESSION['glpigroups'] = [42, 1337]; |
99 | | - $str = \Reminder::addVisibilityRestrict(); |
100 | | - $_SESSION['glpigroups'] = $bkp_groups; |
101 | | - $expected = preg_replace('/\s+/', ' ', "(`glpi_reminders`.`users_id` = '4' |
102 | | - OR `glpi_reminders_users`.`users_id` = '4' |
103 | | - OR (`glpi_groups_reminders`.`groups_id` IN ('42', '1337') |
104 | | - AND (`glpi_groups_reminders`.`no_entity_restriction` = '1' |
105 | | - OR (`glpi_groups_reminders`.`entities_id` IN ($all_entities)))) |
106 | | - OR (`glpi_profiles_reminders`.`profiles_id` = '6' |
107 | | - AND (`glpi_profiles_reminders`.`no_entity_restriction` = '1' |
108 | | - OR (`glpi_profiles_reminders`.`entities_id` IN ($all_entities)))) |
109 | | - OR (`glpi_entities_reminders`.`entities_id` IN ($all_entities)))"); |
110 | | - $this->assertSame( |
111 | | - $expected, |
112 | | - trim(preg_replace('/\s+/', ' ', $str)) |
113 | | - ); |
114 | | - } |
115 | | - |
116 | 43 | public function testGetListCriteriaIsValid(): void |
117 | 44 | { |
118 | 45 | global $DB; |
|
0 commit comments