Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F2397642
UpdateTest.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
UpdateTest.php
View Options
<?php
namespace
Tests\Feature\Jobs\Resource
;
use
App\Backends\LDAP
;
use
App\Resource
;
use
Illuminate\Support\Facades\Queue
;
use
Tests\TestCase
;
class
UpdateTest
extends
TestCase
{
/**
* {@inheritDoc}
*/
public
function
setUp
():
void
{
parent
::
setUp
();
$this
->
deleteTestResource
(
'resource-test@'
.
\config
(
'app.domain'
));
}
/**
* {@inheritDoc}
*/
public
function
tearDown
():
void
{
$this
->
deleteTestResource
(
'resource-test@'
.
\config
(
'app.domain'
));
parent
::
tearDown
();
}
/**
* Test job handle
*
* @group ldap
*/
public
function
testHandle
():
void
{
Queue
::
fake
();
// Test non-existing resource ID
$job
=
new
\App\Jobs\Resource\UpdateJob
(
123
);
$job
->
handle
();
$this
->
assertTrue
(
$job
->
hasFailed
());
$this
->
assertSame
(
"Resource 123 could not be found in the database."
,
$job
->
failureMessage
);
$resource
=
$this
->
getTestResource
(
'resource-test@'
.
\config
(
'app.domain'
));
// Create the resource in LDAP
$job
=
new
\App\Jobs\Resource\CreateJob
(
$resource
->
id
);
$job
->
handle
();
$resource
->
setConfig
([
'invitation_policy'
=>
'accept'
]);
$job
=
new
\App\Jobs\Resource\UpdateJob
(
$resource
->
id
);
$job
->
handle
();
$ldap_resource
=
LDAP
::
getResource
(
$resource
->
email
);
$this
->
assertSame
(
'ACT_ACCEPT'
,
$ldap_resource
[
'kolabinvitationpolicy'
]);
// Test that the job is being deleted if the resource is not ldap ready or is deleted
$resource
->
refresh
();
$resource
->
status
=
Resource
::
STATUS_NEW
|
Resource
::
STATUS_ACTIVE
;
$resource
->
save
();
$job
=
new
\App\Jobs\Resource\UpdateJob
(
$resource
->
id
);
$job
->
handle
();
$this
->
assertTrue
(
$job
->
isDeleted
());
$resource
->
status
=
Resource
::
STATUS_NEW
|
Resource
::
STATUS_ACTIVE
|
Resource
::
STATUS_LDAP_READY
|
Resource
::
STATUS_DELETED
;
$resource
->
save
();
$job
=
new
\App\Jobs\Resource\UpdateJob
(
$resource
->
id
);
$job
->
handle
();
$this
->
assertTrue
(
$job
->
isDeleted
());
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Mon, Nov 3, 2:38 PM (1 d, 8 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
361060
Default Alt Text
UpdateTest.php (2 KB)
Attached To
Mode
R2 kolab
Attached
Detach File
Event Timeline
Log In to Comment