1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-07-30 21:40:43 +02:00

[ticket/13904] Modify files for changes in ini wrapper

PHPBB3-13904
This commit is contained in:
Marc Alexander
2015-08-27 10:51:10 +02:00
parent b2957b9d65
commit 16f3b8c2b9
16 changed files with 60 additions and 66 deletions

View File

@@ -34,14 +34,14 @@ class phpbb_cache_apc_driver_test extends phpbb_cache_common_test_case
self::markTestSkipped('APC extension is not loaded');
}
$php_ini = new \phpbb\php\ini;
$php_ini = new \bantu\IniGetWrapper\IniGetWrapper;
if (!$php_ini->get_bool('apc.enabled'))
if (!$php_ini->getBool('apc.enabled'))
{
self::markTestSkipped('APC is not enabled. Make sure apc.enabled=1 in php.ini');
}
if (PHP_SAPI == 'cli' && !$php_ini->get_bool('apc.enable_cli'))
if (PHP_SAPI == 'cli' && !$php_ini->getBool('apc.enable_cli'))
{
self::markTestSkipped('APC is not enabled for CLI. Set apc.enable_cli=1 in php.ini');
}

View File

@@ -23,7 +23,7 @@ class phpbb_files_upload_test extends phpbb_test_case
/** @var \phpbb\files\factory */
protected $factory;
/** @var \phpbb\php\ini */
/** @var \bantu\IniGetWrapper\IniGetWrapper */
protected $php_ini;
/** @var \phpbb\language\language */
@@ -52,7 +52,7 @@ class phpbb_files_upload_test extends phpbb_test_case
$this->filesystem = new \phpbb\filesystem\filesystem();
$this->language = new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx));
$this->php_ini = new \phpbb\php\ini;
$this->php_ini = new \bantu\IniGetWrapper\IniGetWrapper;
$this->container = new phpbb_mock_container_builder($phpbb_root_path, $phpEx);
$this->container->set('files.filespec', new \phpbb\files\filespec(

View File

@@ -22,7 +22,7 @@ class phpbb_functional_fileupload_remote_test extends phpbb_functional_test_case
/** @var \phpbb\files\factory */
protected $factory;
/** @var \phpbb\php\ini */
/** @var \bantu\IniGetWrapper\IniGetWrapper */
protected $php_ini;
/** @var \phpbb\language\language */
@@ -54,7 +54,7 @@ class phpbb_functional_fileupload_remote_test extends phpbb_functional_test_case
$this->filesystem = new \phpbb\filesystem\filesystem();
$this->language = new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx));
$this->request = $this->getMock('\phpbb\request\request');
$this->php_ini = new \phpbb\php\ini;
$this->php_ini = new \bantu\IniGetWrapper\IniGetWrapper;
$container = new phpbb_mock_container_builder();
$container->set('files.filespec', new \phpbb\files\filespec($this->filesystem, $this->language, $this->php_ini, $this->phpbb_root_path));

View File

@@ -24,11 +24,11 @@ class phpbb_installer_config_test extends phpbb_test_case
{
$phpbb_root_path = __DIR__ . './../../phpBB/';
$filesystem = $this->getMock('\phpbb\filesystem\filesystem');
$php_ini = $this->getMockBuilder('\phpbb\php\ini')
$php_ini = $this->getMockBuilder('\bantu\IniGetWrapper\IniGetWrapper')
->getMock();
$php_ini->method('get_int')
$php_ini->method('getInt')
->willReturn(-1);
$php_ini->method('get_bytes')
$php_ini->method('getBytes')
->willReturn(-1);
$this->config = new config($filesystem, $php_ini, $phpbb_root_path);

View File

@@ -43,7 +43,7 @@ class module_base_test extends phpbb_test_case
$this->module = new test_installer_module($module_collection, true, false);
$iohandler = $this->getMock('\phpbb\install\helper\iohandler\iohandler_interface');
$config = new \phpbb\install\helper\config(new \phpbb\filesystem\filesystem(), new \phpbb\php\ini(), '', 'php');
$config = new \phpbb\install\helper\config(new \phpbb\filesystem\filesystem(), new \bantu\IniGetWrapper\IniGetWrapper(), '', 'php');
$this->module->setup($config, $iohandler);
}

View File

@@ -48,7 +48,7 @@ class phpbb_plupload_test extends phpbb_test_case
$config,
new phpbb_mock_request,
new \phpbb\user($lang, '\phpbb\datetime'),
new \phpbb\php\ini,
new \bantu\IniGetWrapper\IniGetWrapper,
new \phpbb\mimetype\guesser(array(new \phpbb\mimetype\extension_guesser))
);

View File

@@ -93,7 +93,7 @@ class phpbb_filespec_test extends phpbb_test_case
'error' => '',
);
$filespec = new \phpbb\files\filespec($this->filesystem, $this->language, new \phpbb\php\ini, $this->phpbb_root_path, $this->mimetype_guesser);
$filespec = new \phpbb\files\filespec($this->filesystem, $this->language, new \bantu\IniGetWrapper\IniGetWrapper, $this->phpbb_root_path, $this->mimetype_guesser);
return $filespec->set_upload_ary(array_merge($upload_ary, $override));
}
@@ -114,7 +114,7 @@ class phpbb_filespec_test extends phpbb_test_case
public function test_empty_upload_ary()
{
$filespec = new \phpbb\files\filespec($this->filesystem, $this->language, new \phpbb\php\ini, $this->phpbb_root_path, $this->mimetype_guesser);
$filespec = new \phpbb\files\filespec($this->filesystem, $this->language, new \bantu\IniGetWrapper\IniGetWrapper, $this->phpbb_root_path, $this->mimetype_guesser);
$this->assertInstanceOf('\phpbb\files\filespec', $filespec->set_upload_ary(array()));
$this->assertTrue($filespec->init_error());
}
@@ -262,7 +262,7 @@ class phpbb_filespec_test extends phpbb_test_case
*/
public function test_clean_filename_avatar($filename, $expected, $mode, $prefix = '', $user_id = '')
{
$filespec = new \phpbb\files\filespec($this->filesystem, $this->language, new \phpbb\php\ini, $this->phpbb_root_path, $this->mimetype_guesser);
$filespec = new \phpbb\files\filespec($this->filesystem, $this->language, new \bantu\IniGetWrapper\IniGetWrapper, $this->phpbb_root_path, $this->mimetype_guesser);
if ($filename)
{
@@ -419,7 +419,7 @@ class phpbb_filespec_test extends phpbb_test_case
public function test_is_uploaded()
{
$filespec = new \phpbb\files\filespec($this->filesystem, $this->language, new \phpbb\php\ini, $this->phpbb_root_path, null);
$filespec = new \phpbb\files\filespec($this->filesystem, $this->language, new \bantu\IniGetWrapper\IniGetWrapper, $this->phpbb_root_path, null);
$reflection_filespec = new ReflectionClass($filespec);
$plupload_property = $reflection_filespec->getProperty('plupload');
$plupload_property->setAccessible(true);

View File

@@ -27,7 +27,7 @@ class phpbb_fileupload_test extends phpbb_test_case
/** @var \phpbb\files\factory */
protected $factory;
/** @var \phpbb\php\ini */
/** @var \bantu\IniGetWrapper\IniGetWrapper */
protected $php_ini;
/** @var \phpbb\language\language */
@@ -53,7 +53,7 @@ class phpbb_fileupload_test extends phpbb_test_case
$config['rand_seed_last_update'] = time() + 600;
$this->request = $this->getMock('\phpbb\request\request');
$this->php_ini = new \phpbb\php\ini;
$this->php_ini = new \bantu\IniGetWrapper\IniGetWrapper;
$this->filesystem = new \phpbb\filesystem\filesystem();
$this->language = new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx));

View File

@@ -11,7 +11,7 @@
*
*/
class phpbb_php_ini_fake extends \phpbb\php\ini
class phpbb_php_ini_fake extends \bantu\IniGetWrapper\IniGetWrapper
{
function get($varname)
{

View File

@@ -16,6 +16,7 @@ require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
class phpbb_wrapper_phpbb_php_ini_test extends phpbb_test_case
{
/** @var \phpbb_php_ini_fake php_ini */
protected $php_ini;
public function setUp()
@@ -25,44 +26,37 @@ class phpbb_wrapper_phpbb_php_ini_test extends phpbb_test_case
public function test_get_string()
{
$this->assertSame(false, $this->php_ini->get_string(false));
$this->assertSame('phpbb', $this->php_ini->get_string(' phpbb '));
$this->assertSame('', $this->php_ini->getString(false));
$this->assertSame('phpbb', $this->php_ini->getString(' phpbb '));
}
public function test_get_bool()
{
$this->assertSame(true, $this->php_ini->get_bool('ON'));
$this->assertSame(true, $this->php_ini->get_bool('on'));
$this->assertSame(true, $this->php_ini->get_bool('1'));
$this->assertSame(true, $this->php_ini->getBool('ON'));
$this->assertSame(true, $this->php_ini->getBool('on'));
$this->assertSame(true, $this->php_ini->getBool('1'));
$this->assertSame(false, $this->php_ini->get_bool('OFF'));
$this->assertSame(false, $this->php_ini->get_bool('off'));
$this->assertSame(false, $this->php_ini->get_bool('0'));
$this->assertSame(false, $this->php_ini->get_bool(''));
$this->assertSame(false, $this->php_ini->getBool('OFF'));
$this->assertSame(false, $this->php_ini->getBool('off'));
$this->assertSame(false, $this->php_ini->getBool('0'));
$this->assertSame(false, $this->php_ini->getBool(''));
}
public function test_get_int()
{
$this->assertSame(1234, $this->php_ini->get_int('1234'));
$this->assertSame(-12345, $this->php_ini->get_int('-12345'));
$this->assertSame(false, $this->php_ini->get_int('phpBB'));
}
public function test_get_float()
{
$this->assertSame(1234.0, $this->php_ini->get_float('1234'));
$this->assertSame(-12345.0, $this->php_ini->get_float('-12345'));
$this->assertSame(false, $this->php_ini->get_float('phpBB'));
$this->assertSame(1234, $this->php_ini->getNumeric('1234'));
$this->assertSame(-12345, $this->php_ini->getNumeric('-12345'));
$this->assertSame(null, $this->php_ini->getNumeric('phpBB'));
}
public function test_get_bytes_invalid()
{
$this->assertSame(false, $this->php_ini->get_bytes(false));
$this->assertSame(false, $this->php_ini->get_bytes('phpBB'));
$this->assertSame(false, $this->php_ini->get_bytes('k'));
$this->assertSame(false, $this->php_ini->get_bytes('-k'));
$this->assertSame(false, $this->php_ini->get_bytes('M'));
$this->assertSame(false, $this->php_ini->get_bytes('-M'));
$this->assertSame(null, $this->php_ini->getBytes(false));
$this->assertSame(null, $this->php_ini->getBytes('phpBB'));
$this->assertSame(null, $this->php_ini->getBytes('k'));
$this->assertSame(null, $this->php_ini->getBytes('-k'));
$this->assertSame(null, $this->php_ini->getBytes('M'));
$this->assertSame(null, $this->php_ini->getBytes('-M'));
}
/**
@@ -70,7 +64,7 @@ class phpbb_wrapper_phpbb_php_ini_test extends phpbb_test_case
*/
public function test_get_bytes($expected, $value)
{
$actual = $this->php_ini->get_bytes($value);
$actual = $this->php_ini->getBytes($value);
$this->assertTrue(is_float($actual) || is_int($actual));
$this->assertEquals($expected, $actual);