public function test_set_config_file() { $config_php = new \phpbb\config_php_file(dirname(__FILE__) . '/fixtures/', 'php'); $config_php->set_config_file(dirname(__FILE__) . '/fixtures/config_other.php'); $this->assertSame('foo', $config_php->get('bar')); $this->assertNull($config_php->get('foo')); $this->assertSame(array('bar' => 'foo', 'bar_bar' => 'foo foo'), $config_php->get_all()); }
public static function get_test_config() { $config = array(); if (extension_loaded('sqlite3')) { $config = array_merge($config, array('dbms' => 'phpbb\\db\\driver\\sqlite3', 'dbhost' => dirname(__FILE__) . '/../phpbb_unit_tests.sqlite3', 'dbport' => '', 'dbname' => '', 'dbuser' => '', 'dbpasswd' => '')); } if (isset($_SERVER['PHPBB_TEST_CONFIG'])) { // Could be an absolute path $test_config = $_SERVER['PHPBB_TEST_CONFIG']; } else { $test_config = dirname(__FILE__) . '/../test_config.php'; } $config_php_file = new \phpbb\config_php_file('', ''); if (file_exists($test_config)) { $config_php_file->set_config_file($test_config); extract($config_php_file->get_all()); $config = array_merge($config, array('dbms' => $config_php_file->convert_30_dbms_to_31($dbms), 'dbhost' => $dbhost, 'dbport' => $dbport, 'dbname' => $dbname, 'dbuser' => $dbuser, 'dbpasswd' => $dbpasswd, 'custom_dsn' => isset($custom_dsn) ? $custom_dsn : '')); if (isset($phpbb_functional_url)) { $config['phpbb_functional_url'] = $phpbb_functional_url; } if (isset($phpbb_redis_host)) { $config['redis_host'] = $phpbb_redis_host; } if (isset($phpbb_redis_port)) { $config['redis_port'] = $phpbb_redis_port; } if (isset($fulltext_sphinx_id)) { $config['fulltext_sphinx_id'] = $fulltext_sphinx_id; } } if (isset($_SERVER['PHPBB_TEST_DBMS'])) { $config = array_merge($config, array('dbms' => isset($_SERVER['PHPBB_TEST_DBMS']) ? $config_php_file->convert_30_dbms_to_31($_SERVER['PHPBB_TEST_DBMS']) : '', 'dbhost' => isset($_SERVER['PHPBB_TEST_DBHOST']) ? $_SERVER['PHPBB_TEST_DBHOST'] : '', 'dbport' => isset($_SERVER['PHPBB_TEST_DBPORT']) ? $_SERVER['PHPBB_TEST_DBPORT'] : '', 'dbname' => isset($_SERVER['PHPBB_TEST_DBNAME']) ? $_SERVER['PHPBB_TEST_DBNAME'] : '', 'dbuser' => isset($_SERVER['PHPBB_TEST_DBUSER']) ? $_SERVER['PHPBB_TEST_DBUSER'] : '', 'dbpasswd' => isset($_SERVER['PHPBB_TEST_DBPASSWD']) ? $_SERVER['PHPBB_TEST_DBPASSWD'] : '', 'custom_dsn' => isset($_SERVER['PHPBB_TEST_CUSTOM_DSN']) ? $_SERVER['PHPBB_TEST_CUSTOM_DSN'] : '')); } if (isset($_SERVER['PHPBB_FUNCTIONAL_URL'])) { $config = array_merge($config, array('phpbb_functional_url' => isset($_SERVER['PHPBB_FUNCTIONAL_URL']) ? $_SERVER['PHPBB_FUNCTIONAL_URL'] : '')); } if (isset($_SERVER['PHPBB_TEST_REDIS_HOST'])) { $config['redis_host'] = $_SERVER['PHPBB_TEST_REDIS_HOST']; } if (isset($_SERVER['PHPBB_TEST_REDIS_PORT'])) { $config['redis_port'] = $_SERVER['PHPBB_TEST_REDIS_PORT']; } return $config; }