Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F120825503
UserForceDeleteTest.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
UserForceDeleteTest.php
View Options
<?php
namespace
Tests\Feature\Console
;
use
Illuminate\Support\Facades\Queue
;
use
Tests\TestCase
;
class
UserForceDeleteTest
extends
TestCase
{
/**
* {@inheritDoc}
*/
public
function
setUp
():
void
{
parent
::
setUp
();
$this
->
deleteTestUser
(
'user@force-delete.com'
);
$this
->
deleteTestDomain
(
'force-delete.com'
);
}
/**
* {@inheritDoc}
*/
public
function
tearDown
():
void
{
$this
->
deleteTestUser
(
'user@force-delete.com'
);
$this
->
deleteTestDomain
(
'force-delete.com'
);
parent
::
tearDown
();
}
/**
* Test the command
*/
public
function
testHandle
():
void
{
// Non-existing user
$this
->
artisan
(
'user:force-delete unknown@unknown.org'
)
->
assertExitCode
(
1
);
Queue
::
fake
();
$user
=
$this
->
getTestUser
(
'user@force-delete.com'
);
$domain
=
$this
->
getTestDomain
(
'force-delete.com'
,
[
'status'
=>
\App\Domain
::
STATUS_NEW
,
'type'
=>
\App\Domain
::
TYPE_HOSTED
,
]);
$package_kolab
=
\App\Package
::
withEnvTenantContext
()->
where
(
'title'
,
'kolab'
)->
first
();
$package_domain
=
\App\Package
::
withEnvTenantContext
()->
where
(
'title'
,
'domain-hosting'
)->
first
();
$user
->
assignPackage
(
$package_kolab
);
$domain
->
assignPackage
(
$package_domain
,
$user
);
$wallet
=
$user
->
wallets
()->
first
();
$entitlements
=
$wallet
->
entitlements
->
pluck
(
'id'
)->
all
();
$this
->
assertCount
(
8
,
$entitlements
);
// Non-deleted user
$this
->
artisan
(
'user:force-delete user@force-delete.com'
)
->
assertExitCode
(
1
);
$user
->
delete
();
$this
->
assertTrue
(
$user
->
trashed
());
$this
->
assertTrue
(
$domain
->
fresh
()->
trashed
());
// Deleted user
$this
->
artisan
(
'user:force-delete user@force-delete.com'
)
->
assertExitCode
(
0
);
$this
->
assertCount
(
0
,
\App\User
::
withTrashed
()->
where
(
'email'
,
'user@force-delete.com'
)->
get
()
);
$this
->
assertCount
(
0
,
\App\Domain
::
withTrashed
()->
where
(
'namespace'
,
'force-delete.com'
)->
get
()
);
$this
->
assertCount
(
0
,
\App\Wallet
::
where
(
'id'
,
$wallet
->
id
)->
get
()
);
$this
->
assertCount
(
0
,
\App\Entitlement
::
withTrashed
()->
where
(
'wallet_id'
,
$wallet
->
id
)->
get
()
);
$this
->
assertCount
(
0
,
\App\Entitlement
::
withTrashed
()->
where
(
'entitleable_id'
,
$user
->
id
)->
get
()
);
$this
->
assertCount
(
0
,
\App\Transaction
::
whereIn
(
'object_id'
,
$entitlements
)
->
where
(
'object_type'
,
\App\Entitlement
::
class
)
->
get
()
);
// TODO: Test that it also deletes users in a group account
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Fri, Apr 24, 10:40 AM (2 h, 23 m ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
18826917
Default Alt Text
UserForceDeleteTest.php (2 KB)
Attached To
Mode
rK kolab
Attached
Detach File
Event Timeline