-
Notifications
You must be signed in to change notification settings - Fork 133
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add tests for invalid group name to
addgroup
/removegroup
co…
…mmand
- Loading branch information
Showing
1 changed file
with
44 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -595,6 +595,24 @@ public function testAddgroup(): void | |
$this->assertTrue($user->inGroup('admin')); | ||
} | ||
|
||
public function testAddgroupWithInvalidGroup(): void | ||
{ | ||
$this->createUser([ | ||
'username' => 'user10', | ||
'email' => '[email protected]', | ||
'password' => 'secret123', | ||
]); | ||
|
||
$this->setMockIo(['y']); | ||
|
||
command('shield:user addgroup -n user10 -g invalid'); | ||
|
||
$this->assertStringContainsString( | ||
'Invalid group: "invalid"', | ||
$this->io->getLastOutput() | ||
); | ||
} | ||
|
||
public function testAddgroupCancel(): void | ||
{ | ||
$this->createUser([ | ||
|
@@ -643,6 +661,32 @@ public function testRemovegroup(): void | |
$this->assertFalse($user->inGroup('admin')); | ||
} | ||
|
||
public function testRemovegroupWithInvalidGroup(): void | ||
{ | ||
$this->createUser([ | ||
'username' => 'user11', | ||
'email' => '[email protected]', | ||
'password' => 'secret123', | ||
]); | ||
$users = model(UserModel::class); | ||
$user = $users->findByCredentials(['email' => '[email protected]']); | ||
$user->addGroup('admin'); | ||
$this->assertTrue($user->inGroup('admin')); | ||
|
||
$this->setMockIo(['y']); | ||
|
||
command('shield:user removegroup -n user11 -g invalid'); | ||
|
||
$this->assertStringContainsString( | ||
'Invalid group: "invalid"', | ||
$this->io->getLastOutput() | ||
); | ||
|
||
$users = model(UserModel::class); | ||
$user = $users->findByCredentials(['email' => '[email protected]']); | ||
$this->assertTrue($user->inGroup('admin')); | ||
} | ||
|
||
public function testRemovegroupCancel(): void | ||
{ | ||
$this->createUser([ | ||
|