Find this useful? Enter your email to receive occasional updates for securing PHP code.
Signing you up...
Thank you for signing up!
PHP Decode
<?php namespace Roundcube\Tests\Actions\Contacts; use Roundcube\Tests\ActionTestCase; us..
Decoded Output download
<?php
namespace Roundcube\Tests\Actions\Contacts;
use Roundcube\Tests\ActionTestCase;
use Roundcube\Tests\OutputJsonMock;
/**
* Test class to test rcmail_action_contacts_undo
*/
class UndoTest extends ActionTestCase
{
/**
* Test contact undelete
*/
public function test_undo()
{
$action = new
cmail_action_contacts_undo();
$output = $this->initOutput(
cmail_action::MODE_AJAX, 'contacts', 'undo');
$this->assertInstanceOf(
cmail_action::class, $action);
$this->assertTrue($action->checks());
self::initDB('contacts');
$db =
cmail::get_instance()->get_dbh();
$query = $db->query('SELECT `contact_id` FROM `contacts` WHERE `user_id` = 1 LIMIT 1');
$result = $db->fetch_assoc($query);
$cid = $result['contact_id'];
$db->query('UPDATE `contacts` SET `del` = 1 WHERE `contact_id` = ' . $cid);
$_SESSION['contact_undo'] = ['data' => [[$cid]]];
$this->runAndAssert($action, OutputJsonMock::E_EXIT);
$result = $output->getOutput();
$this->assertSame(['Content-Type: application/json; charset=UTF-8'], $output->headers);
$this->assertSame('undo', $result['action']);
$this->assertTrue(strpos($result['exec'], 'his.display_message("Contact(s) restored successfully.","confirmation",0);') !== false);
$this->assertTrue(strpos($result['exec'], 'this.list_contacts()') !== false);
$query = $db->query('SELECT * FROM `contacts` WHERE `contact_id` = ' . $cid);
$result = $db->fetch_assoc($query);
$this->assertTrue(!empty($result));
$this->assertTrue(empty($result['del']));
}
}
?>
Did this file decode correctly?
Original Code
<?php
namespace Roundcube\Tests\Actions\Contacts;
use Roundcube\Tests\ActionTestCase;
use Roundcube\Tests\OutputJsonMock;
/**
* Test class to test rcmail_action_contacts_undo
*/
class UndoTest extends ActionTestCase
{
/**
* Test contact undelete
*/
public function test_undo()
{
$action = new \rcmail_action_contacts_undo();
$output = $this->initOutput(\rcmail_action::MODE_AJAX, 'contacts', 'undo');
$this->assertInstanceOf(\rcmail_action::class, $action);
$this->assertTrue($action->checks());
self::initDB('contacts');
$db = \rcmail::get_instance()->get_dbh();
$query = $db->query('SELECT `contact_id` FROM `contacts` WHERE `user_id` = 1 LIMIT 1');
$result = $db->fetch_assoc($query);
$cid = $result['contact_id'];
$db->query('UPDATE `contacts` SET `del` = 1 WHERE `contact_id` = ' . $cid);
$_SESSION['contact_undo'] = ['data' => [[$cid]]];
$this->runAndAssert($action, OutputJsonMock::E_EXIT);
$result = $output->getOutput();
$this->assertSame(['Content-Type: application/json; charset=UTF-8'], $output->headers);
$this->assertSame('undo', $result['action']);
$this->assertTrue(strpos($result['exec'], 'his.display_message("Contact(s) restored successfully.","confirmation",0);') !== false);
$this->assertTrue(strpos($result['exec'], 'this.list_contacts()') !== false);
$query = $db->query('SELECT * FROM `contacts` WHERE `contact_id` = ' . $cid);
$result = $db->fetch_assoc($query);
$this->assertTrue(!empty($result));
$this->assertTrue(empty($result['del']));
}
}
Function Calls
None |
Stats
MD5 | 07bb5bd20941473323d78e924ddcee1e |
Eval Count | 0 |
Decode Time | 90 ms |