mirror of
https://github.com/phpbb/phpbb.git
synced 2025-02-24 20:13:22 +01:00
* github-noxwizard/ticket/10678: [ticket/10678] Typo and formatting [ticket/10678] Add port handling for MSSQL tests [ticket/10678] Move config changes to new location [ticket/10678] Rename helper class file [ticket/10678] Lowercase class name, adjust comment width [ticket/10678] More formatting and docblocks [ticket/10678] More formatting requests [ticket/10678] Fix formatting [ticket/10678] Add better support for Firebird, Oracle, and MSSQL Conflicts: tests/RUNNING_TESTS.txt
114 lines
2.9 KiB
PHP
114 lines
2.9 KiB
PHP
<?php
|
|
/**
|
|
*
|
|
* @package testing
|
|
* @copyright (c) 2008 phpBB Group
|
|
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
|
*
|
|
*/
|
|
|
|
class phpbb_test_case_helpers
|
|
{
|
|
protected $expectedTriggerError = false;
|
|
|
|
protected $test_case;
|
|
|
|
public function __construct($test_case)
|
|
{
|
|
$this->test_case = $test_case;
|
|
}
|
|
|
|
public function setExpectedTriggerError($errno, $message = '')
|
|
{
|
|
$exceptionName = '';
|
|
switch ($errno)
|
|
{
|
|
case E_NOTICE:
|
|
case E_STRICT:
|
|
PHPUnit_Framework_Error_Notice::$enabled = true;
|
|
$exceptionName = 'PHPUnit_Framework_Error_Notice';
|
|
break;
|
|
|
|
case E_WARNING:
|
|
PHPUnit_Framework_Error_Warning::$enabled = true;
|
|
$exceptionName = 'PHPUnit_Framework_Error_Warning';
|
|
break;
|
|
|
|
default:
|
|
$exceptionName = 'PHPUnit_Framework_Error';
|
|
break;
|
|
}
|
|
$this->expectedTriggerError = true;
|
|
$this->test_case->setExpectedException($exceptionName, (string) $message, $errno);
|
|
}
|
|
|
|
static public function get_test_config()
|
|
{
|
|
$config = array();
|
|
|
|
if (extension_loaded('sqlite') && version_compare(PHPUnit_Runner_Version::id(), '3.4.15', '>='))
|
|
{
|
|
$config = array_merge($config, array(
|
|
'dbms' => 'sqlite',
|
|
'dbhost' => dirname(__FILE__) . '/../phpbb_unit_tests.sqlite2', // filename
|
|
'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';
|
|
}
|
|
|
|
if (file_exists($test_config))
|
|
{
|
|
include($test_config);
|
|
|
|
$config = array_merge($config, array(
|
|
'dbms' => $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($_SERVER['PHPBB_TEST_DBMS']))
|
|
{
|
|
$config = array_merge($config, array(
|
|
'dbms' => isset($_SERVER['PHPBB_TEST_DBMS']) ? $_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'] : '',
|
|
));
|
|
}
|
|
|
|
return $config;
|
|
}
|
|
}
|