Files
roundcubemail/tests/Framework/Rcube.php
Michael Voříšek 600bbf608e Run unit tests in CI on Windows too (#9251)
* Run unit tests in CI on Windows too
* Install::test_check_mime_extensions() has no mime.types on Windows
* Fix sqlite test DB path and unlink for Windows
* Fix rcube::exec() testing for Windows
* Prevent git EOL conversion for tests/
* Fix test_rtf2text test for text with CRLF
* run E2E tests on one php version only
2023-12-10 16:18:04 +01:00

84 lines
2.0 KiB
PHP

<?php
/**
* Test class to test rcube class
*
* @package Tests
*/
class Framework_Rcube extends PHPUnit\Framework\TestCase
{
/**
* Class constructor
*/
function test_class()
{
$object = rcube::get_instance();
$this->assertInstanceOf('rcube', $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);
// The following tests fail quite often, therefore we disable them
$this->markTestSkipped();
// Test AEAD cipher method
$rcube->config->set('cipher_method', 'aes-256-gcm');
$result = $rcube->decrypt($rcube->encrypt('test'));
$this->assertSame('test', $result);
// Back to the default
$rcube->config->set('cipher_method', 'DES-EDE3-CBC');
}
/**
* rcube::exec()
*/
function test_exec()
{
if (PHP_OS_FAMILY === 'Windows') {
$this->assertSame('', rcube::exec('where.exe unknown-command-123 2> nul'));
$this->assertSame('12', rcube::exec('set /a 10 + {v}', ['v' => '2']));
return;
}
$this->assertSame('', rcube::exec('which unknown-command-123'));
$this->assertSame("2038\n", rcube::exec('date --date={date} +%Y', ['date' => '@2147483647']));
// TODO: More cases
}
}