Skip to content

Commit 2aae2bd

Browse files
test: adjust UserGroup model creation during tests
1 parent a7751d6 commit 2aae2bd

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Tests/APIModelsUserGroupTestCase.inc

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -129,15 +129,12 @@ class APIModelsUserGroupTestCase extends TestCase {
129129
* the 'system' scope.
130130
*/
131131
public function test_cannot_create_or_update_user_groups_with_system_scope(): void {
132-
# Create a UserGroup to test with
133-
$user_group = new UserGroup();
134-
135132
# Ensure attempts to create UserGroups with the system scope are rejected
136133
$this->assert_throws_response(
137134
response_id: 'USER_GROUP_SCOPE_CANNOT_BE_SET_TO_SYSTEM',
138135
code: 422,
139-
callable: function () use ($user_group) {
140-
$user_group->scope->value = 'system';
136+
callable: function () {
137+
$user_group = new UserGroup(name: 'testgroup', scope: 'system');
141138
$user_group->create();
142139
},
143140
);
@@ -146,7 +143,7 @@ class APIModelsUserGroupTestCase extends TestCase {
146143
$this->assert_throws_response(
147144
response_id: 'USER_GROUP_SCOPE_CANNOT_BE_SET_TO_SYSTEM',
148145
code: 422,
149-
callable: function () use ($user_group) {
146+
callable: function () {
150147
# Create a local UserGroup to test with
151148
$user_group = new UserGroup(data: ['name' => 'testgroup', 'scope' => 'local']);
152149
$user_group->create();
@@ -157,9 +154,6 @@ class APIModelsUserGroupTestCase extends TestCase {
157154
},
158155
);
159156

160-
# Delete the test UserGroup
161-
$user_group->delete();
162-
163157
# Ensure we CAN update an existing UserGroup with the system scope to still have the system scope
164158
$this->assert_does_not_throw(
165159
callable: function () {

0 commit comments

Comments
 (0)