1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
|
<?php
namespace Roundcube\Tests\Framework;
use PHPUnit\Framework\TestCase;
/**
* Test class to test rcube class
*/
class Framework_Rcube extends TestCase
{
/**
* Class constructor
*/
function test_class()
{
$object = \rcube::get_instance();
$this->assertInstanceOf(\rcube::class, $object, "Class singleton");
}
/**
* rcube::read_localization()
*/
function test_read_localization()
{
$rcube = \rcube::get_instance();
$result = $rcube->read_localization(INSTALL_PATH . 'plugins/acl/localization', 'pl_PL');
$this->assertSame('Zapis', $result['aclwrite']);
}
/**
* rcube::list_languages()
*/
function test_list_languages()
{
$rcube = \rcube::get_instance();
$result = $rcube->list_languages();
$this->assertSame('English (US)', $result['en_US']);
}
/**
* rcube::encrypt() and rcube::decrypt()
*/
function test_encrypt_and_decrypt()
{
$rcube = \rcube::get_instance();
$result = $rcube->decrypt($rcube->encrypt('test'));
$this->assertSame('test', $result);
// Test AEAD cipher method
$defaultCipherMethod = $rcube->config->get('cipher_method');
$rcube->config->set('cipher_method', 'aes-256-gcm');
try {
$result = $rcube->decrypt($rcube->encrypt('test'));
$this->assertSame('test', $result);
} finally {
$rcube->config->set('cipher_method', $defaultCipherMethod);
}
}
}
|