mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-10 21:38:54 +00:00
adjust tests a little bit to let them work again in trunk (not adjusted template/bbcode yet)
git-svn-id: file:///svn/phpbb/trunk@10212 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
parent
2e17e448de
commit
8243e9a372
14 changed files with 82 additions and 123 deletions
|
@ -8,8 +8,6 @@
|
|||
*
|
||||
*/
|
||||
|
||||
define('IN_PHPBB', true);
|
||||
|
||||
if (!defined('PHPUnit_MAIN_METHOD'))
|
||||
{
|
||||
define('PHPUnit_MAIN_METHOD', 'phpbb_all_tests::main');
|
||||
|
@ -18,11 +16,11 @@ if (!defined('PHPUnit_MAIN_METHOD'))
|
|||
require_once 'test_framework/framework.php';
|
||||
require_once 'PHPUnit/TextUI/TestRunner.php';
|
||||
|
||||
require_once 'bbcode/all_tests.php';
|
||||
require_once 'utf/all_tests.php';
|
||||
require_once 'request/all_tests.php';
|
||||
require_once 'security/all_tests.php';
|
||||
require_once 'template/all_tests.php';
|
||||
#require_once 'template/all_tests.php';
|
||||
#require_once 'bbcode/all_tests.php';
|
||||
require_once 'text_processing/all_tests.php';
|
||||
|
||||
// exclude the test directory from code coverage reports
|
||||
|
@ -39,12 +37,12 @@ class phpbb_all_tests
|
|||
{
|
||||
$suite = new PHPUnit_Framework_TestSuite('phpBB');
|
||||
|
||||
$suite->addTest(phpbb_bbcode_all_tests::suite());
|
||||
$suite->addTest(phpbb_utf_all_tests::suite());
|
||||
$suite->addTest(phpbb_request_all_tests::suite());
|
||||
$suite->addTest(phpbb_security_all_tests::suite());
|
||||
$suite->addTest(phpbb_template_all_tests::suite());
|
||||
# $suite->addTest(phpbb_template_all_tests::suite());
|
||||
# $suite->addTest(phpbb_bbcode_all_tests::suite());
|
||||
$suite->addTest(phpbb_text_processing_all_tests::suite());
|
||||
$suite->addTest(phpbb_utf_all_tests::suite());
|
||||
|
||||
return $suite;
|
||||
}
|
||||
|
@ -54,5 +52,3 @@ if (PHPUnit_MAIN_METHOD == 'phpbb_all_tests::main')
|
|||
{
|
||||
phpbb_all_tests::main();
|
||||
}
|
||||
|
||||
?>
|
|
@ -8,8 +8,6 @@
|
|||
*
|
||||
*/
|
||||
|
||||
define('IN_PHPBB', true);
|
||||
|
||||
if (!defined('PHPUnit_MAIN_METHOD'))
|
||||
{
|
||||
define('PHPUnit_MAIN_METHOD', 'phpbb_request_all_tests::main');
|
||||
|
@ -19,7 +17,6 @@ require_once 'test_framework/framework.php';
|
|||
require_once 'PHPUnit/TextUI/TestRunner.php';
|
||||
|
||||
require_once 'request/request_var.php';
|
||||
require_once 'request/request_class.php';
|
||||
|
||||
class phpbb_request_all_tests
|
||||
{
|
||||
|
@ -32,7 +29,6 @@ class phpbb_request_all_tests
|
|||
{
|
||||
$suite = new PHPUnit_Framework_TestSuite('phpBB Request Parameter Handling');
|
||||
|
||||
$suite->addTestSuite('phpbb_request_request_class_test');
|
||||
$suite->addTestSuite('phpbb_request_request_var_test');
|
||||
|
||||
return $suite;
|
||||
|
|
|
@ -8,10 +8,7 @@
|
|||
*
|
||||
*/
|
||||
|
||||
define('IN_PHPBB', true);
|
||||
|
||||
require_once 'test_framework/framework.php';
|
||||
|
||||
require_once '../phpBB/includes/functions.php';
|
||||
|
||||
class phpbb_request_request_var_test extends phpbb_test_case
|
||||
|
@ -22,13 +19,11 @@ class phpbb_request_request_var_test extends phpbb_test_case
|
|||
public function test_post($variable_value, $default, $multibyte, $expected)
|
||||
{
|
||||
$variable_name = 'name';
|
||||
$this->unset_variables($variable_name);
|
||||
|
||||
$_POST[$variable_name] = $variable_value;
|
||||
$_REQUEST[$variable_name] = $variable_value;
|
||||
|
||||
// reread data from super globals
|
||||
request::reset();
|
||||
|
||||
$result = request_var($variable_name, $default, $multibyte);
|
||||
|
||||
$label = 'Requesting POST variable, converting from ' . gettype($variable_value) . ' to ' . gettype($default) . (($multibyte) ? ' multibyte' : '');
|
||||
|
@ -41,13 +36,11 @@ class phpbb_request_request_var_test extends phpbb_test_case
|
|||
public function test_get($variable_value, $default, $multibyte, $expected)
|
||||
{
|
||||
$variable_name = 'name';
|
||||
$this->unset_variables($variable_name);
|
||||
|
||||
$_GET[$variable_name] = $variable_value;
|
||||
$_REQUEST[$variable_name] = $variable_value;
|
||||
|
||||
// reread data from super globals
|
||||
request::reset();
|
||||
|
||||
$result = request_var($variable_name, $default, $multibyte);
|
||||
|
||||
$label = 'Requesting GET variable, converting from ' . gettype($variable_value) . ' to ' . gettype($default) . (($multibyte) ? ' multibyte' : '');
|
||||
|
@ -55,10 +48,39 @@ class phpbb_request_request_var_test extends phpbb_test_case
|
|||
}
|
||||
|
||||
/**
|
||||
* @dataProvider deep_access
|
||||
* @dataProvider request_variables
|
||||
*/
|
||||
public function test_cookie($variable_value, $default, $multibyte, $expected)
|
||||
{
|
||||
$variable_name = 'name';
|
||||
$this->unset_variables($variable_name);
|
||||
|
||||
$_GET[$variable_name] = false;
|
||||
$_POST[$variable_name] = false;
|
||||
$_REQUEST[$variable_name] = false;
|
||||
$_COOKIE[$variable_name] = $variable_value;
|
||||
|
||||
$result = request_var($variable_name, $default, $multibyte, true);
|
||||
|
||||
$label = 'Requesting COOKIE variable, converting from ' . gettype($variable_value) . ' to ' . gettype($default) . (($multibyte) ? ' multibyte' : '');
|
||||
$this->assertEquals($expected, $result, $label);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper for unsetting globals
|
||||
*/
|
||||
private function unset_variables($var)
|
||||
{
|
||||
unset($_GET[$var], $_POST[$var], $_REQUEST[$var], $_COOKIE[$var]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider deep_access
|
||||
* Only possible with 3.1.x (later)
|
||||
public function test_deep_multi_dim_array_access($path, $default, $expected)
|
||||
{
|
||||
$this->unset_variables('var');
|
||||
|
||||
$_REQUEST['var'] = array(
|
||||
0 => array(
|
||||
'b' => array(
|
||||
|
@ -75,9 +97,6 @@ class phpbb_request_request_var_test extends phpbb_test_case
|
|||
),
|
||||
);
|
||||
|
||||
// reread data from super globals
|
||||
request::reset();
|
||||
|
||||
$result = request_var($path, $default);
|
||||
$this->assertEquals($expected, $result, 'Testing deep access to multidimensional input arrays: ' . $path);
|
||||
}
|
||||
|
@ -92,7 +111,7 @@ class phpbb_request_request_var_test extends phpbb_test_case
|
|||
array(array('var', 0, 'b', true), array(0 => ''), array(5 => 'c', 6 => 'd')),
|
||||
);
|
||||
}
|
||||
|
||||
*/
|
||||
public static function request_variables()
|
||||
{
|
||||
return array(
|
||||
|
@ -193,6 +212,7 @@ class phpbb_request_request_var_test extends phpbb_test_case
|
|||
'abc' => array()
|
||||
)
|
||||
),
|
||||
/* 3-dimensional (not supported atm!
|
||||
array(
|
||||
// input:
|
||||
array(
|
||||
|
@ -237,6 +257,7 @@ class phpbb_request_request_var_test extends phpbb_test_case
|
|||
'ä' => array(4 => array('a' => 2, 'ö' => 3)),
|
||||
)
|
||||
),
|
||||
*/
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -8,8 +8,6 @@
|
|||
*
|
||||
*/
|
||||
|
||||
define('IN_PHPBB', true);
|
||||
|
||||
if (!defined('PHPUnit_MAIN_METHOD'))
|
||||
{
|
||||
define('PHPUnit_MAIN_METHOD', 'phpbb_security_all_tests::main');
|
||||
|
@ -28,7 +26,7 @@ class phpbb_security_all_tests extends PHPUnit_Framework_TestSuite
|
|||
*/
|
||||
protected function setUp()
|
||||
{
|
||||
global $user;
|
||||
global $user, $phpbb_root_path;
|
||||
|
||||
// Put this into a global function being run by every test to init a proper user session
|
||||
$_SERVER['HTTP_HOST'] = 'localhost';
|
||||
|
@ -57,7 +55,7 @@ class phpbb_security_all_tests extends PHPUnit_Framework_TestSuite
|
|||
$user->referer = (!empty($_SERVER['HTTP_REFERER'])) ? htmlspecialchars((string) $_SERVER['HTTP_REFERER']) : '';
|
||||
$user->forwarded_for = (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) ? (string) $_SERVER['HTTP_X_FORWARDED_FOR'] : '';
|
||||
$user->host = (!empty($_SERVER['HTTP_HOST'])) ? (string) strtolower($_SERVER['HTTP_HOST']) : ((!empty($_SERVER['SERVER_NAME'])) ? $_SERVER['SERVER_NAME'] : getenv('SERVER_NAME'));
|
||||
$user->page = session::extract_current_page(PHPBB_ROOT_PATH);
|
||||
$user->page = session::extract_current_page($phpbb_root_path);
|
||||
}
|
||||
|
||||
protected function tearDown()
|
||||
|
|
|
@ -8,8 +8,6 @@
|
|||
*
|
||||
*/
|
||||
|
||||
define('IN_PHPBB', true);
|
||||
|
||||
require_once 'test_framework/framework.php';
|
||||
|
||||
require_once '../phpBB/includes/functions.php';
|
||||
|
@ -53,5 +51,3 @@ class phpbb_security_extract_current_page_test extends phpbb_test_case
|
|||
$this->assertEquals($expected, $result['query_string'], $label);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
|
@ -8,13 +8,8 @@
|
|||
*
|
||||
*/
|
||||
|
||||
define('IN_PHPBB', true);
|
||||
|
||||
require_once 'test_framework/framework.php';
|
||||
|
||||
define('PHPBB_ROOT_PATH', './../phpBB/');
|
||||
define('PHP_EXT', 'php');
|
||||
|
||||
require_once '../phpBB/includes/functions.php';
|
||||
require_once '../phpBB/includes/session.php';
|
||||
|
||||
|
@ -36,7 +31,7 @@ class phpbb_security_redirect_test extends phpbb_test_case
|
|||
protected function setUp()
|
||||
{
|
||||
$GLOBALS['config'] = array(
|
||||
'force_server_vars' => 0,
|
||||
'force_server_vars' => '0',
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -61,5 +56,3 @@ class phpbb_security_redirect_test extends phpbb_test_case
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
|
@ -8,8 +8,6 @@
|
|||
*
|
||||
*/
|
||||
|
||||
define('IN_PHPBB', true);
|
||||
|
||||
if (!defined('PHPUnit_MAIN_METHOD'))
|
||||
{
|
||||
define('PHPUnit_MAIN_METHOD', 'phpbb_template_all_tests::main');
|
||||
|
@ -40,5 +38,4 @@ class phpbb_template_all_tests
|
|||
if (PHPUnit_MAIN_METHOD == 'phpbb_template_all_tests::main')
|
||||
{
|
||||
phpbb_template_all_tests::main();
|
||||
}
|
||||
?>
|
||||
}
|
|
@ -8,13 +8,9 @@
|
|||
*
|
||||
*/
|
||||
|
||||
define('IN_PHPBB', true);
|
||||
define('PHP_EXT', 'php');
|
||||
define('PHPBB_ROOT_PATH', '../phpBB/');
|
||||
|
||||
require_once 'test_framework/framework.php';
|
||||
|
||||
require_once '../phpBB/includes/core/bootstrap.php';
|
||||
require_once '../phpBB/includes/template.php';
|
||||
|
||||
class phpbb_template_template_test extends phpbb_test_case
|
||||
{
|
||||
|
@ -22,7 +18,7 @@ class phpbb_template_template_test extends phpbb_test_case
|
|||
private $template_path;
|
||||
|
||||
// Keep the contents of the cache for debugging?
|
||||
const PRESERVE_CACHE = true;
|
||||
const PRESERVE_CACHE = false;
|
||||
|
||||
private function display($handle)
|
||||
{
|
||||
|
@ -39,7 +35,7 @@ class phpbb_template_template_test extends phpbb_test_case
|
|||
private function setup_engine()
|
||||
{
|
||||
$this->template_path = dirname(__FILE__) . '/templates';
|
||||
$this->template = new phpbb_template;
|
||||
$this->template = new template();
|
||||
$this->template->set_custom_template($this->template_path, 'tests');
|
||||
}
|
||||
|
||||
|
@ -58,7 +54,7 @@ class phpbb_template_template_test extends phpbb_test_case
|
|||
unlink($file);
|
||||
}
|
||||
|
||||
phpbb::$config = array(
|
||||
$GLOBALS['config'] = array(
|
||||
'load_tplcompile' => true,
|
||||
'tpl_allow_php' => false,
|
||||
);
|
||||
|
@ -269,61 +265,25 @@ class phpbb_template_template_test extends phpbb_test_case
|
|||
$this->assertFileNotExists($this->template_path . '/' . $filename, 'Testing missing file, file cannot exist');
|
||||
|
||||
$expecting = sprintf('template->_tpl_load_file(): File %s does not exist or is empty', realpath($this->template_path) . '/' . $filename);
|
||||
$this->setExpectedTriggerError(E_USER_ERROR, $expecting);
|
||||
|
||||
try
|
||||
{
|
||||
$this->display('test');
|
||||
}
|
||||
catch (ErrorException $e)
|
||||
{
|
||||
$this->assertEquals($expecting, $e->getMessage());
|
||||
|
||||
if ($expecting != $e->getMessage())
|
||||
{
|
||||
// Unrelated error message throw it out
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
$this->display('test');
|
||||
}
|
||||
|
||||
public function test_empty_file()
|
||||
{
|
||||
$expecting = 'template->set_filenames: Empty filename specified for test';
|
||||
|
||||
try
|
||||
{
|
||||
$this->template->set_filenames(array('test' => ''));
|
||||
}
|
||||
catch (ErrorException $e)
|
||||
{
|
||||
$this->assertEquals($expecting, $e->getMessage());
|
||||
|
||||
if ($expecting != $e->getMessage())
|
||||
{
|
||||
// Unrelated error message throw it out
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
$this->setExpectedTriggerError(E_USER_ERROR, $expecting);
|
||||
$this->template->set_filenames(array('test' => ''));
|
||||
}
|
||||
|
||||
public function test_invalid_handle()
|
||||
{
|
||||
$expecting = 'template->_tpl_load(): No file specified for handle test';
|
||||
$this->setExpectedTriggerError(E_USER_ERROR, $expecting);
|
||||
|
||||
try
|
||||
{
|
||||
$this->display('test');
|
||||
}
|
||||
catch (ErrorException $e)
|
||||
{
|
||||
$this->assertEquals($expecting, $e->getMessage());
|
||||
|
||||
if ($expecting != $e->getMessage())
|
||||
{
|
||||
// Unrelated error message throw it out
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
$this->display('test');
|
||||
}
|
||||
|
||||
private function run_template($file, array $vars, array $block_vars, array $destroy, $expected, $cache_file)
|
||||
|
@ -371,7 +331,8 @@ class phpbb_template_template_test extends phpbb_test_case
|
|||
*/
|
||||
public function test_template($file, array $vars, array $block_vars, array $destroy, $expected)
|
||||
{
|
||||
$cache_file = $this->template->cachepath . str_replace('/', '.', $file) . '.' . PHP_EXT;
|
||||
global $phpEx;
|
||||
$cache_file = $this->template->cachepath . str_replace('/', '.', $file) . '.' . $phpEx;
|
||||
|
||||
$this->assertFileNotExists($cache_file);
|
||||
|
||||
|
@ -385,7 +346,6 @@ class phpbb_template_template_test extends phpbb_test_case
|
|||
|
||||
/**
|
||||
* @dataProvider template_data
|
||||
*/
|
||||
public function test_assign_display($file, array $vars, array $block_vars, array $destroy, $expected)
|
||||
{
|
||||
$this->template->set_filenames(array(
|
||||
|
@ -415,16 +375,19 @@ class phpbb_template_template_test extends phpbb_test_case
|
|||
|
||||
public function test_php()
|
||||
{
|
||||
phpbb::$config['tpl_allow_php'] = true;
|
||||
global $phpEx;
|
||||
|
||||
$cache_file = $this->template->cachepath . 'php.html.' . PHP_EXT;
|
||||
$GLOBALS['config']['tpl_allow_php'] = true;
|
||||
|
||||
$cache_file = $this->template->cachepath . 'php.html.' . $phpEx;
|
||||
|
||||
$this->assertFileNotExists($cache_file);
|
||||
|
||||
$this->run_template('php.html', array(), array(), array(), 'test', $cache_file);
|
||||
|
||||
phpbb::$config['tpl_allow_php'] = false;
|
||||
$GLOBALS['config']['tpl_allow_php'] = false;
|
||||
}
|
||||
*/
|
||||
/*
|
||||
public function test_includephp()
|
||||
{
|
||||
|
@ -678,7 +641,6 @@ EOT
|
|||
|
||||
/**
|
||||
* @dataProvider alter_block_array_data
|
||||
*/
|
||||
public function test_alter_block_array($alter_block, array $vararray, $key, $mode, $expect, $description)
|
||||
{
|
||||
$this->template->set_filenames(array('test' => 'loop_nested.html'));
|
||||
|
@ -700,5 +662,5 @@ EOT
|
|||
$this->template->alter_block_array($alter_block, $vararray, $key, $mode);
|
||||
$this->assertEquals($expect, $this->display('test'), $description);
|
||||
}
|
||||
*/
|
||||
}
|
||||
?>
|
|
@ -1,5 +1,23 @@
|
|||
<?php
|
||||
|
||||
define('IN_PHPBB', true);
|
||||
$phpbb_root_path = '../phpBB/';
|
||||
$phpEx = 'php';
|
||||
$table_prefix = '';
|
||||
|
||||
// If we are on PHP >= 6.0.0 we do not need some code
|
||||
if (version_compare(PHP_VERSION, '6.0.0-dev', '>='))
|
||||
{
|
||||
define('STRIP', false);
|
||||
}
|
||||
else
|
||||
{
|
||||
@set_magic_quotes_runtime(0);
|
||||
define('STRIP', (get_magic_quotes_gpc()) ? true : false);
|
||||
}
|
||||
|
||||
require_once $phpbb_root_path . 'includes/constants.php';
|
||||
|
||||
// require at least PHPUnit 3.3.0
|
||||
require_once 'PHPUnit/Runner/Version.php';
|
||||
if (version_compare(PHPUnit_Runner_Version::id(), '3.3.0', '<'))
|
||||
|
|
|
@ -8,8 +8,6 @@
|
|||
*
|
||||
*/
|
||||
|
||||
define('IN_PHPBB', true);
|
||||
|
||||
if (!defined('PHPUnit_MAIN_METHOD'))
|
||||
{
|
||||
define('PHPUnit_MAIN_METHOD', 'phpbb_text_processing_all_tests::main');
|
||||
|
@ -41,4 +39,3 @@ if (PHPUnit_MAIN_METHOD == 'phpbb_text_processing_all_tests::main')
|
|||
{
|
||||
phpbb_text_processing_all_tests::main();
|
||||
}
|
||||
?>
|
|
@ -8,8 +8,6 @@
|
|||
*
|
||||
*/
|
||||
|
||||
define('IN_PHPBB', true);
|
||||
|
||||
require_once 'test_framework/framework.php';
|
||||
|
||||
require_once '../phpBB/includes/functions.php';
|
||||
|
@ -66,7 +64,7 @@ class phpbb_text_processing_make_clickable_test extends phpbb_test_case
|
|||
{
|
||||
foreach ($urls as $url => $url_type)
|
||||
{
|
||||
$input = $prefix . $schema . $url . $suffix;
|
||||
$input = $prefix . $url . $suffix;
|
||||
// no valid url => no change
|
||||
$output = $input;
|
||||
|
||||
|
@ -106,4 +104,3 @@ class phpbb_text_processing_make_clickable_test extends phpbb_test_case
|
|||
}
|
||||
|
||||
}
|
||||
?>
|
|
@ -8,8 +8,6 @@
|
|||
*
|
||||
*/
|
||||
|
||||
define('IN_PHPBB', true);
|
||||
|
||||
if (!defined('PHPUnit_MAIN_METHOD'))
|
||||
{
|
||||
define('PHPUnit_MAIN_METHOD', 'phpbb_utf_all_tests::main');
|
||||
|
@ -43,4 +41,3 @@ if (PHPUnit_MAIN_METHOD == 'phpbb_utf_all_tests::main')
|
|||
{
|
||||
phpbb_utf_all_tests::main();
|
||||
}
|
||||
?>
|
|
@ -8,12 +8,7 @@
|
|||
*
|
||||
*/
|
||||
|
||||
define('IN_PHPBB', true);
|
||||
|
||||
require_once 'test_framework/framework.php';
|
||||
|
||||
define(PHPBB_ROOT_PATH, '../phpBB/');
|
||||
define(PHP_EXT, 'php');
|
||||
require_once '../phpBB/includes/utf/utf_tools.php';
|
||||
|
||||
class phpbb_utf_utf8_clean_string_test extends phpbb_test_case
|
||||
|
@ -35,4 +30,3 @@ class phpbb_utf_utf8_clean_string_test extends phpbb_test_case
|
|||
$this->assertEquals($output, utf8_clean_string($input), $label);
|
||||
}
|
||||
}
|
||||
?>
|
|
@ -8,8 +8,6 @@
|
|||
*
|
||||
*/
|
||||
|
||||
define('IN_PHPBB', true);
|
||||
|
||||
require_once 'test_framework/framework.php';
|
||||
require_once '../phpBB/includes/utf/utf_tools.php';
|
||||
|
||||
|
@ -84,4 +82,3 @@ class phpbb_utf_utf8_wordwrap_test extends phpbb_test_case
|
|||
$this->assertEquals($expected, $phpbb_utf8_wordwrap, 'Checking UTF-8 cutting long words');
|
||||
}
|
||||
}
|
||||
?>
|
Loading…
Add table
Reference in a new issue