Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F117756461
SetRoleTest.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
1 KB
Referenced Files
None
Subscribers
None
SetRoleTest.php
View Options
<?php
namespace
Tests\Feature\Console\User
;
use
App\User
;
use
Tests\TestCase
;
class
SetRoleTest
extends
TestCase
{
protected
function
setUp
():
void
{
parent
::
setUp
();
$this
->
deleteTestUser
(
'wallets-controller@kolabnow.com'
);
}
protected
function
tearDown
():
void
{
$this
->
deleteTestUser
(
'wallets-controller@kolabnow.com'
);
parent
::
tearDown
();
}
/**
* Test command runs
*/
public
function
testHandle
():
void
{
$user
=
$this
->
getTestUser
(
'wallets-controller@kolabnow.com'
);
$this
->
assertNull
(
$user
->
role
);
// Invalid user id
$code
=
\Artisan
::
call
(
"user:set-role 123 admin"
);
$output
=
trim
(
\Artisan
::
output
());
$this
->
assertSame
(
1
,
$code
);
$this
->
assertSame
(
'User not found.'
,
$output
);
// Invalid role
$code
=
\Artisan
::
call
(
"user:set-role {$user->id} 123"
);
$output
=
trim
(
\Artisan
::
output
());
$this
->
assertSame
(
1
,
$code
);
$this
->
assertSame
(
'Invalid role.'
,
$output
);
// Assign a role
$code
=
\Artisan
::
call
(
"user:set-role {$user->id} "
.
User
::
ROLE_ADMIN
);
$output
=
trim
(
\Artisan
::
output
());
$this
->
assertSame
(
0
,
$code
);
$this
->
assertSame
(
''
,
$output
);
$this
->
assertSame
(
User
::
ROLE_ADMIN
,
$user
->
fresh
()->
role
);
// Remove a role
$code
=
\Artisan
::
call
(
"user:set-role {$user->id} null"
);
$output
=
trim
(
\Artisan
::
output
());
$this
->
assertSame
(
0
,
$code
);
$this
->
assertSame
(
'Removing role.'
,
$output
);
$this
->
assertNull
(
$user
->
fresh
()->
role
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sat, Apr 4, 8:42 AM (2 w, 4 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
18823292
Default Alt Text
SetRoleTest.php (1 KB)
Attached To
Mode
rK kolab
Attached
Detach File
Event Timeline