mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-29 06:38:52 +00:00
[ticket/14323] Set up global objects required during testing
PHPBB3-14323
This commit is contained in:
parent
9a8fb2e1df
commit
f9d8866aee
3 changed files with 33 additions and 17 deletions
|
@ -315,7 +315,7 @@ class phpbb_test_case_helpers
|
||||||
public function set_s9e_services(ContainerInterface $container = null, $fixture = null, $styles_path = null)
|
public function set_s9e_services(ContainerInterface $container = null, $fixture = null, $styles_path = null)
|
||||||
{
|
{
|
||||||
static $first_run;
|
static $first_run;
|
||||||
global $phpbb_container, $phpbb_dispatcher, $phpbb_root_path, $phpEx, $request, $user;
|
global $config, $phpbb_container, $phpbb_dispatcher, $phpbb_root_path, $phpEx, $request, $user;
|
||||||
|
|
||||||
$cache_dir = __DIR__ . '/../tmp/';
|
$cache_dir = __DIR__ . '/../tmp/';
|
||||||
|
|
||||||
|
@ -469,6 +469,8 @@ class phpbb_test_case_helpers
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set up the a minimum config
|
// Set up the a minimum config
|
||||||
|
if (!isset($config))
|
||||||
|
{
|
||||||
if ($container->has('config'))
|
if ($container->has('config'))
|
||||||
{
|
{
|
||||||
$config = $container->get('config');
|
$config = $container->get('config');
|
||||||
|
@ -477,9 +479,14 @@ class phpbb_test_case_helpers
|
||||||
{
|
{
|
||||||
$config = new \phpbb\config\config(array());
|
$config = new \phpbb\config\config(array());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
$default_config = array(
|
$default_config = array(
|
||||||
'allow_nocensors' => false,
|
'allow_nocensors' => false,
|
||||||
'allowed_schemes_links' => 'http,https,ftp',
|
'allowed_schemes_links' => 'http,https,ftp',
|
||||||
|
'script_path' => '/phpbb',
|
||||||
|
'server_name' => 'localhost',
|
||||||
|
'server_port' => 80,
|
||||||
|
'server_protocol' => 'http://',
|
||||||
'smilies_path' => 'images/smilies',
|
'smilies_path' => 'images/smilies',
|
||||||
);
|
);
|
||||||
foreach ($default_config as $config_name => $config_value)
|
foreach ($default_config as $config_name => $config_value)
|
||||||
|
@ -519,7 +526,6 @@ class phpbb_test_case_helpers
|
||||||
->will($this->test_case->returnCallback(__CLASS__ . '::format_date'));
|
->will($this->test_case->returnCallback(__CLASS__ . '::format_date'));
|
||||||
|
|
||||||
$user->date_format = 'Y-m-d H:i:s';
|
$user->date_format = 'Y-m-d H:i:s';
|
||||||
$user->host = 'localhost';
|
|
||||||
$user->optionset('viewcensors', true);
|
$user->optionset('viewcensors', true);
|
||||||
$user->optionset('viewflash', true);
|
$user->optionset('viewflash', true);
|
||||||
$user->optionset('viewimg', true);
|
$user->optionset('viewimg', true);
|
||||||
|
|
|
@ -236,12 +236,12 @@ class phpbb_textformatter_s9e_default_formatting_test extends phpbb_test_case
|
||||||
'<a href="http://www.phpbb.com/community/path/to/long/url/file.ext#section" class="postlink">http://www.phpbb.com/community/path/to/ ... xt#section</a>'
|
'<a href="http://www.phpbb.com/community/path/to/long/url/file.ext#section" class="postlink">http://www.phpbb.com/community/path/to/ ... xt#section</a>'
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'http://localhost/ http://localhost/viewforum.php?f=1',
|
'http://localhost/ http://localhost/phpbb/ http://localhost/phpbb/viewforum.php?f=1',
|
||||||
'<a href="http://localhost/" class="postlink">http://localhost/</a> <a href="http://localhost/viewforum.php?f=1" class="postlink">viewforum.php?f=1</a>'
|
'<a href="http://localhost/" class="postlink">http://localhost/</a> <a href="http://localhost/phpbb/" class="postlink">http://localhost/phpbb/</a> <a href="http://localhost/phpbb/viewforum.php?f=1" class="postlink">viewforum.php?f=1</a>'
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'http://localhost/viewforum.php?f=1#xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
|
'http://localhost/phpbb/viewforum.php?f=1#xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
|
||||||
'<a href="http://localhost/viewforum.php?f=1#xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" class="postlink">viewforum.php?f=1#xxxxxxxxxxxxxxxxxxxxx ... xxxxxxxxxx</a>'
|
'<a href="http://localhost/phpbb/viewforum.php?f=1#xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" class="postlink">viewforum.php?f=1#xxxxxxxxxxxxxxxxxxxxx ... xxxxxxxxxx</a>'
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'[quote="[url=http://example.org]xxx[/url]"]...[/quote]',
|
'[quote="[url=http://example.org]xxx[/url]"]...[/quote]',
|
||||||
|
|
|
@ -35,7 +35,7 @@ class phpbb_textformatter_s9e_factory_test extends phpbb_database_test_case
|
||||||
|
|
||||||
public function get_factory()
|
public function get_factory()
|
||||||
{
|
{
|
||||||
global $phpbb_root_path;
|
global $config, $phpbb_root_path, $request, $user;
|
||||||
$this->cache = new phpbb_mock_cache;
|
$this->cache = new phpbb_mock_cache;
|
||||||
$dal = new \phpbb\textformatter\data_access(
|
$dal = new \phpbb\textformatter\data_access(
|
||||||
$this->new_dbal(),
|
$this->new_dbal(),
|
||||||
|
@ -55,6 +55,16 @@ class phpbb_textformatter_s9e_factory_test extends phpbb_database_test_case
|
||||||
'_foo_renderer'
|
'_foo_renderer'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Global objects required by generate_board_url()
|
||||||
|
$config = new \phpbb\config\config(array(
|
||||||
|
'script_path' => '/phpbb',
|
||||||
|
'server_name' => 'localhost',
|
||||||
|
'server_port' => 80,
|
||||||
|
'server_protocol' => 'http://',
|
||||||
|
));
|
||||||
|
$request = new phpbb_mock_request;
|
||||||
|
$user = new phpbb_mock_user;
|
||||||
|
|
||||||
return $factory;
|
return $factory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -128,14 +138,14 @@ class phpbb_textformatter_s9e_factory_test extends phpbb_database_test_case
|
||||||
public function test_local_url()
|
public function test_local_url()
|
||||||
{
|
{
|
||||||
global $config, $user, $request;
|
global $config, $user, $request;
|
||||||
$config = array(
|
$config = new \phpbb\config\config(array(
|
||||||
'force_server_vars' => true,
|
'force_server_vars' => true,
|
||||||
'server_protocol' => 'http://',
|
'server_protocol' => 'http://',
|
||||||
'server_name' => 'path',
|
'server_name' => 'path',
|
||||||
'server_port' => 80,
|
'server_port' => 80,
|
||||||
'script_path' => '/to',
|
'script_path' => '/to',
|
||||||
'cookie_secure' => false
|
'cookie_secure' => false
|
||||||
);
|
));
|
||||||
$user = new phpbb_mock_user;
|
$user = new phpbb_mock_user;
|
||||||
$request = new phpbb_mock_request;
|
$request = new phpbb_mock_request;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue