Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F120835022
UsersTest.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
2 KB
Referenced Files
None
Subscribers
None
UsersTest.php
View Options
<?php
namespace
Tests\Feature\Console\User
;
use
App\Sku
;
use
Illuminate\Support\Facades\Queue
;
use
Tests\TestCase
;
class
UsersTest
extends
TestCase
{
protected
function
setUp
():
void
{
parent
::
setUp
();
$this
->
deleteTestUser
(
'user@force-delete.com'
);
}
protected
function
tearDown
():
void
{
$this
->
deleteTestUser
(
'user@force-delete.com'
);
parent
::
tearDown
();
}
/**
* Test command runs
*/
public
function
testHandle
():
void
{
$code
=
\Artisan
::
call
(
"user:users unknown"
);
$output
=
trim
(
\Artisan
::
output
());
$this
->
assertSame
(
1
,
$code
);
$this
->
assertSame
(
"No such user unknown"
,
$output
);
$code
=
\Artisan
::
call
(
"user:users john@kolab.org --attr=email"
);
$output
=
trim
(
\Artisan
::
output
());
$this
->
assertSame
(
0
,
$code
);
$this
->
assertCount
(
4
,
explode
(
"
\n
"
,
$output
));
$this
->
assertStringContainsString
(
"john@kolab.org"
,
$output
);
$this
->
assertStringContainsString
(
"ned@kolab.org"
,
$output
);
$this
->
assertStringContainsString
(
"joe@kolab.org"
,
$output
);
$this
->
assertStringContainsString
(
"jack@kolab.org"
,
$output
);
// Test behaviour with deleted users
Queue
::
fake
();
// Note: User:users() uses entitlements to get the owned users,
// so we add a single entitlement, then we can soft-delete the user
$user
=
$this
->
getTestUser
(
'user@force-delete.com'
);
$storage
=
Sku
::
withEnvTenantContext
()->
where
(
'title'
,
'storage'
)->
first
();
$user
->
assignSku
(
$storage
,
1
);
$user
->
delete
();
$code
=
\Artisan
::
call
(
"user:users {$user->email} --attr=email"
);
$output
=
trim
(
\Artisan
::
output
());
$this
->
assertSame
(
0
,
$code
);
$this
->
assertSame
(
''
,
trim
(
$output
));
$code
=
\Artisan
::
call
(
"user:users {$user->email} --with-deleted --attr=email"
);
$output
=
trim
(
\Artisan
::
output
());
$this
->
assertSame
(
0
,
$code
);
$this
->
assertSame
(
"{$user->id} {$user->email}"
,
trim
(
$output
));
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Fri, Apr 24, 1:12 PM (6 d, 8 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
18859047
Default Alt Text
UsersTest.php (2 KB)
Attached To
Mode
rK kolab
Attached
Detach File
Event Timeline