mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-08 20:38:52 +00:00
Merge branch '3.2.x'
This commit is contained in:
commit
c9716a8b63
1 changed files with 43 additions and 32 deletions
|
@ -13,8 +13,10 @@
|
||||||
|
|
||||||
class phpbb_email_parsing_test extends phpbb_test_case
|
class phpbb_email_parsing_test extends phpbb_test_case
|
||||||
{
|
{
|
||||||
static protected $reflection;
|
/** @var \messenger */
|
||||||
protected $messenger;
|
protected $messenger;
|
||||||
|
|
||||||
|
/** @var \ReflectionProperty */
|
||||||
protected $reflection_template_property;
|
protected $reflection_template_property;
|
||||||
|
|
||||||
public function setUp()
|
public function setUp()
|
||||||
|
@ -23,20 +25,12 @@ class phpbb_email_parsing_test extends phpbb_test_case
|
||||||
|
|
||||||
$phpbb_container = new phpbb_mock_container_builder;
|
$phpbb_container = new phpbb_mock_container_builder;
|
||||||
|
|
||||||
$config = new \phpbb\config\config(array());
|
$config = new \phpbb\config\config(array(
|
||||||
$default_config = array(
|
|
||||||
'board_email_sig' => '-- Thanks, The Management',
|
'board_email_sig' => '-- Thanks, The Management',
|
||||||
'sitename' => 'yourdomain.com',
|
'sitename' => 'yourdomain.com',
|
||||||
'default_lang' => 'en',
|
'default_lang' => 'en',
|
||||||
);
|
));
|
||||||
foreach ($default_config as $config_name => $config_value)
|
$phpbb_container->set('config', $config);
|
||||||
{
|
|
||||||
if (!isset($config[$config_name]))
|
|
||||||
{
|
|
||||||
$config[$config_name] = $config_value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$phpbb_container->set('config', $config, phpbb_mock_container_builder::SCOPE_PROTOTYPE);
|
|
||||||
|
|
||||||
$request = new phpbb_mock_request;
|
$request = new phpbb_mock_request;
|
||||||
$symfony_request = new \phpbb\symfony_request(
|
$symfony_request = new \phpbb\symfony_request(
|
||||||
|
@ -50,16 +44,16 @@ class phpbb_email_parsing_test extends phpbb_test_case
|
||||||
$phpbb_root_path,
|
$phpbb_root_path,
|
||||||
$phpEx
|
$phpEx
|
||||||
);
|
);
|
||||||
$phpbb_container->set('path_helper', $phpbb_path_helper, phpbb_mock_container_builder::SCOPE_PROTOTYPE);
|
$phpbb_container->set('path_helper', $phpbb_path_helper);
|
||||||
$phpbb_container->set('filesystem', $filesystem, phpbb_mock_container_builder::SCOPE_PROTOTYPE);
|
$phpbb_container->set('filesystem', $filesystem);
|
||||||
|
|
||||||
$cache_path = 'cache/' . PHPBB_ENVIRONMENT . '/twig';
|
$cache_path = $phpbb_root_path . 'cache/' . PHPBB_ENVIRONMENT . '/twig';
|
||||||
$phpbb_container->setParameter('core.template.cache_path', $cache_path, phpbb_mock_container_builder::SCOPE_PROTOTYPE);
|
$phpbb_container->setParameter('core.template.cache_path', $cache_path);
|
||||||
|
|
||||||
$lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx);
|
$lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx);
|
||||||
$lang = new \phpbb\language\language($lang_loader);
|
$lang = new \phpbb\language\language($lang_loader);
|
||||||
$user = new \phpbb\user($lang, '\phpbb\datetime');
|
$user = new \phpbb\user($lang, '\phpbb\datetime');
|
||||||
$phpbb_container->set('user', $user, phpbb_mock_container_builder::SCOPE_PROTOTYPE);
|
$phpbb_container->set('user', $user);
|
||||||
$extension_manager = new phpbb_mock_extension_manager(
|
$extension_manager = new phpbb_mock_extension_manager(
|
||||||
dirname(__FILE__) . '/',
|
dirname(__FILE__) . '/',
|
||||||
array(
|
array(
|
||||||
|
@ -70,10 +64,15 @@ class phpbb_email_parsing_test extends phpbb_test_case
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
$phpbb_container->set('ext.manager', $extension_manager, phpbb_mock_container_builder::SCOPE_PROTOTYPE);
|
$phpbb_container->set('ext.manager', $extension_manager);
|
||||||
|
|
||||||
$context = new \phpbb\template\context();
|
$context = new \phpbb\template\context();
|
||||||
$phpbb_container->set('template.twig.extensions.collection', array(new \phpbb\template\twig\extension($context, $user)), phpbb_mock_container_builder::SCOPE_PROTOTYPE);
|
$twig_extension = new \phpbb\template\twig\extension($context, $lang);
|
||||||
|
$phpbb_container->set('template.twig.extensions.phpbb', $twig_extension);
|
||||||
|
|
||||||
|
$twig_extensions_collection = new \phpbb\di\service_collection($phpbb_container);
|
||||||
|
$twig_extensions_collection->add('template.twig.extensions.phpbb');
|
||||||
|
$phpbb_container->set('template.twig.extensions.collection', $twig_extensions_collection);
|
||||||
|
|
||||||
$twig = new \phpbb\template\twig\environment(
|
$twig = new \phpbb\template\twig\environment(
|
||||||
$config,
|
$config,
|
||||||
|
@ -89,7 +88,8 @@ class phpbb_email_parsing_test extends phpbb_test_case
|
||||||
'autoescape' => false,
|
'autoescape' => false,
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
$phpbb_container->set('template.twig.lexer', new \phpbb\template\twig\lexer($twig), phpbb_mock_container_builder::SCOPE_PROTOTYPE);
|
$twig->addExtension($twig_extension);
|
||||||
|
$phpbb_container->set('template.twig.lexer', new \phpbb\template\twig\lexer($twig));
|
||||||
|
|
||||||
if (!class_exists('messenger'))
|
if (!class_exists('messenger'))
|
||||||
{
|
{
|
||||||
|
@ -103,9 +103,20 @@ class phpbb_email_parsing_test extends phpbb_test_case
|
||||||
$this->reflection_template_property->setAccessible(true);
|
$this->reflection_template_property->setAccessible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_email_parsing()
|
public function email_parsing_data()
|
||||||
{
|
{
|
||||||
global $phpbb_container, $config, $phpbb_root_path, $phpEx, $user, $request;
|
return array(
|
||||||
|
array('Author username', 'Any forum', 'The topic title', 'Dear user'),
|
||||||
|
array('0', 'Any forum', 'The topic title', 'Dear user'),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dataProvider email_parsing_data
|
||||||
|
*/
|
||||||
|
public function test_email_parsing($author_name, $forum_name, $topic_title, $username)
|
||||||
|
{
|
||||||
|
global $config, $phpEx, $user;
|
||||||
|
|
||||||
$this->messenger->set_addresses($user->data);
|
$this->messenger->set_addresses($user->data);
|
||||||
|
|
||||||
|
@ -113,10 +124,10 @@ class phpbb_email_parsing_test extends phpbb_test_case
|
||||||
'EMAIL_SIG' => str_replace('<br />', "\n", "-- \n" . htmlspecialchars_decode($config['board_email_sig'])),
|
'EMAIL_SIG' => str_replace('<br />', "\n", "-- \n" . htmlspecialchars_decode($config['board_email_sig'])),
|
||||||
'SITENAME' => htmlspecialchars_decode($config['sitename']),
|
'SITENAME' => htmlspecialchars_decode($config['sitename']),
|
||||||
|
|
||||||
'AUTHOR_NAME' => 'Author username',
|
'AUTHOR_NAME' => $author_name,
|
||||||
'FORUM_NAME' => 'Any forum',
|
'FORUM_NAME' => $forum_name,
|
||||||
'TOPIC_TITLE' => 'The topic title',
|
'TOPIC_TITLE' => $topic_title,
|
||||||
'USERNAME' => 'Dear user',
|
'USERNAME' => $username,
|
||||||
|
|
||||||
'U_FORUM' => generate_board_url() . "/viewforum.{$phpEx}?f=1",
|
'U_FORUM' => generate_board_url() . "/viewforum.{$phpEx}?f=1",
|
||||||
'U_STOP_WATCHING_FORUM' => generate_board_url() . "/viewforum.{$phpEx}?uid=2&f=1&unwatch=forum",
|
'U_STOP_WATCHING_FORUM' => generate_board_url() . "/viewforum.{$phpEx}?uid=2&f=1&unwatch=forum",
|
||||||
|
@ -126,10 +137,10 @@ class phpbb_email_parsing_test extends phpbb_test_case
|
||||||
$reflection_template = $this->reflection_template_property->getValue($this->messenger);
|
$reflection_template = $this->reflection_template_property->getValue($this->messenger);
|
||||||
$msg = trim($reflection_template->assign_display('body'));
|
$msg = trim($reflection_template->assign_display('body'));
|
||||||
|
|
||||||
$this->assertContains('Author username', $msg);
|
$this->assertContains($author_name, $msg);
|
||||||
$this->assertContains('Any forum', $msg);
|
$this->assertContains($forum_name, $msg);
|
||||||
$this->assertContains('The topic title', $msg);
|
$this->assertContains($topic_title, $msg);
|
||||||
$this->assertContains('Dear user', $msg);
|
$this->assertContains($username, $msg);
|
||||||
$this->assertContains(htmlspecialchars_decode($config['sitename']), $msg);
|
$this->assertContains(htmlspecialchars_decode($config['sitename']), $msg);
|
||||||
$this->assertContains(str_replace('<br />', "\n", "-- \n" . htmlspecialchars_decode($config['board_email_sig'])), $msg);
|
$this->assertContains(str_replace('<br />', "\n", "-- \n" . htmlspecialchars_decode($config['board_email_sig'])), $msg);
|
||||||
$this->assertNotContains('EMAIL_SIG', $msg);
|
$this->assertNotContains('EMAIL_SIG', $msg);
|
||||||
|
|
Loading…
Add table
Reference in a new issue