Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F120834539
IdentityDelete.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
IdentityDelete.php
View Options
<?php
/**
* Test class to test rcmail_action_settings_identity_delete
*
* @package Tests
*/
class
Actions_Settings_IdentityDelete
extends
ActionTestCase
{
/**
* Test deleting an identity
*/
function
test_delete_identity
()
{
$action
=
new
rcmail_action_settings_identity_delete
;
$output
=
$this
->
initOutput
(
rcmail_action
::
MODE_AJAX
,
'settings'
,
'delete-identity'
);
$this
->
assertInstanceOf
(
'rcmail_action'
,
$action
);
$this
->
assertTrue
(
$action
->
checks
());
self
::
initDB
(
'identities'
);
$db
=
rcmail
::
get_instance
()->
get_dbh
();
$query
=
$db
->
query
(
'SELECT * FROM `identities` WHERE `email` = ?'
,
'test@example.org'
);
$result
=
$db
->
fetch_assoc
(
$query
);
$iid
=
$result
[
'identity_id'
];
$_POST
=
[
'_iid'
=>
$iid
];
$this
->
runAndAssert
(
$action
,
OutputJsonMock
::
E_EXIT
);
$result
=
$output
->
getOutput
();
$this
->
assertSame
([
'Content-Type: application/json; charset=UTF-8'
],
$output
->
headers
);
$this
->
assertSame
(
'delete-identity'
,
$result
[
'action'
]);
$this
->
assertTrue
(
strpos
(
$result
[
'exec'
],
'this.display_message("Successfully deleted.","confirmation",0);'
)
!==
false
);
$this
->
assertTrue
(
strpos
(
$result
[
'exec'
],
'this.remove_identity("'
.
$iid
.
'")'
)
!==
false
);
$query
=
$db
->
query
(
'SELECT * FROM `identities` WHERE `identity_id` = ?'
,
$iid
);
$result
=
$db
->
fetch_assoc
(
$query
);
$this
->
assertTrue
(!
empty
(
$result
[
'del'
]));
// Test error handling
$action
=
new
rcmail_action_settings_identity_delete
;
$output
=
$this
->
initOutput
(
rcmail_action
::
MODE_AJAX
,
'settings'
,
'delete-identity'
);
$_POST
=
[
'_iid'
=>
'unknown'
];
$this
->
runAndAssert
(
$action
,
OutputJsonMock
::
E_EXIT
);
$result
=
$output
->
getOutput
();
$this
->
assertSame
([
'Content-Type: application/json; charset=UTF-8'
],
$output
->
headers
);
$this
->
assertSame
(
'delete-identity'
,
$result
[
'action'
]);
$this
->
assertTrue
(
strpos
(
$result
[
'exec'
],
'this.display_message("An error occurred while saving.","error",0);'
)
!==
false
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Fri, Apr 24, 1:05 PM (1 w, 2 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
18809349
Default Alt Text
IdentityDelete.php (2 KB)
Attached To
Mode
R113 roundcubemail
Attached
Detach File
Event Timeline