mirror of
https://github.com/roundcube/roundcubemail.git
synced 2026-03-07 08:36:51 +01:00
* Check plugins composer.json using CI * Add "require-dev" and "config.allow-plugins" to plugins * fix composer.json format - rm invalid email * fix composer.json format - fix ext require * fix composer.json format - fix plugin name * tmp * Revert "tmp" * fix ext in ext install * disable plugin in plugin install until Roundcube is fully autoloadable * fix composer.json format - fix non-canonical license name * Revert "Add "require-dev" and "config.allow-plugins" to plugins" * no composer install for plugins needed * Revert "fix ext in ext install" * add standard "Test" suffix to phpunit files * rm unneeded "suffix" in phpunit config * simplify phpunit config * fix default "xhtml" doctype in unit testing * fix test_format_date test to not rely on other tests * even more phpunit config simplify * stricter/unify phpunit params for E2E tests * run E2E tests on maximal php version too with lowest deps * "repositories" in bundled plugins are useless as for root package only * add/unify missing plugin test
96 lines
3.4 KiB
PHP
96 lines
3.4 KiB
PHP
<?php
|
|
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
/**
|
|
* Test class to test rcube_config class
|
|
*/
|
|
class Framework_Config extends TestCase
|
|
{
|
|
/**
|
|
* Class constructor
|
|
*/
|
|
public function test_class()
|
|
{
|
|
$object = new rcube_config();
|
|
|
|
$this->assertInstanceOf('rcube_config', $object, 'Class constructor');
|
|
}
|
|
|
|
/**
|
|
* Test resolve_timezone_alias()
|
|
*/
|
|
public function test_resolve_timezone_alias()
|
|
{
|
|
$this->assertSame('UTC', rcube_config::resolve_timezone_alias('Etc/GMT'));
|
|
$this->assertSame('UTC', rcube_config::resolve_timezone_alias('Etc/Zulu'));
|
|
}
|
|
|
|
/**
|
|
* Test get() and set()
|
|
*/
|
|
public function test_get_and_set()
|
|
{
|
|
$object = new rcube_config();
|
|
|
|
$this->assertNull($object->get('test'));
|
|
$this->assertSame('def', $object->get('test', 'def'));
|
|
|
|
$object->set('test', 'val');
|
|
|
|
$this->assertSame('val', $object->get('test'));
|
|
|
|
putenv('ROUNDCUBE_TEST_INT=4190');
|
|
|
|
$this->assertSame(4190, $object->get('test_int'));
|
|
|
|
// TODO: test more code paths in get() and set()
|
|
}
|
|
|
|
/**
|
|
* Test guess_type()
|
|
*/
|
|
public function test_guess_type()
|
|
{
|
|
$object = new rcube_config();
|
|
|
|
$this->assertSame('bool', invokeMethod($object, 'guess_type', ['true']));
|
|
$this->assertSame('bool', invokeMethod($object, 'guess_type', ['false']));
|
|
$this->assertSame('bool', invokeMethod($object, 'guess_type', ['t']));
|
|
$this->assertSame('bool', invokeMethod($object, 'guess_type', ['f']));
|
|
$this->assertSame('bool', invokeMethod($object, 'guess_type', ['TRUE']));
|
|
$this->assertSame('bool', invokeMethod($object, 'guess_type', ['FALSE']));
|
|
$this->assertSame('bool', invokeMethod($object, 'guess_type', ['T']));
|
|
$this->assertSame('bool', invokeMethod($object, 'guess_type', ['F']));
|
|
|
|
$this->assertSame('float', invokeMethod($object, 'guess_type', ['1.5']));
|
|
$this->assertSame('float', invokeMethod($object, 'guess_type', ['1.0']));
|
|
$this->assertSame('float', invokeMethod($object, 'guess_type', ['1.2e3']));
|
|
$this->assertSame('float', invokeMethod($object, 'guess_type', ['7E-10']));
|
|
|
|
$this->assertSame('int', invokeMethod($object, 'guess_type', ['1']));
|
|
$this->assertSame('int', invokeMethod($object, 'guess_type', ['123456789']));
|
|
|
|
$this->assertSame('string', invokeMethod($object, 'guess_type', ['ON']));
|
|
$this->assertSame('string', invokeMethod($object, 'guess_type', ['1-0']));
|
|
}
|
|
|
|
/**
|
|
* Test parse_env()
|
|
*/
|
|
public function test_parse_env()
|
|
{
|
|
$object = new rcube_config();
|
|
|
|
$this->assertTrue(invokeMethod($object, 'parse_env', ['true']));
|
|
$this->assertSame(1, invokeMethod($object, 'parse_env', ['1']));
|
|
$this->assertSame(1.5, invokeMethod($object, 'parse_env', ['1.5']));
|
|
$this->assertTrue(invokeMethod($object, 'parse_env', ['1', 'bool']));
|
|
$this->assertSame(1.0, invokeMethod($object, 'parse_env', ['1', 'float']));
|
|
$this->assertSame(1, invokeMethod($object, 'parse_env', ['1', 'int']));
|
|
$this->assertSame('1', invokeMethod($object, 'parse_env', ['1', 'string']));
|
|
$this->assertSame([1], invokeMethod($object, 'parse_env', ['[1]', 'array']));
|
|
$this->assertSame(['test' => 1], (array) invokeMethod($object, 'parse_env', ['{"test":1}', 'object']));
|
|
}
|
|
}
|