mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-07 20:08:53 +00:00
[ticket/15214] Fix rebasing and some other issues
PHPBB3-15214
This commit is contained in:
parent
0a31489ed2
commit
67afc0a1e2
10 changed files with 65 additions and 60 deletions
|
@ -35,30 +35,36 @@ class event extends \Twig\TokenParser\AbstractTokenParser
|
|||
$this->phpbb_dispatcher = $phpbb_dispatcher;
|
||||
|
||||
$template_event_priority_array = [];
|
||||
|
||||
/**
|
||||
* Allow assigning priority to template events
|
||||
*f
|
||||
* @event core.twig_tokenparser_constructor
|
||||
* @var array template_event_priority_array Array with template event priority assignments per extension namespace
|
||||
* Usage:
|
||||
* '<author>_<extension_name>' => array(
|
||||
* 'event/<template_event_name>' => priority_number,
|
||||
* ),
|
||||
* Example:
|
||||
* 'phpbb_viglink' => array(
|
||||
* 'event/acp_help_phpbb_stats_after' => 80,
|
||||
* 'event/overall_footer_after' => 100,
|
||||
* ),
|
||||
* @since 3.3.12-RC1
|
||||
*/
|
||||
* Allow assigning priority to template events
|
||||
*
|
||||
* The higher number - the higher tempate event listener priority value is.
|
||||
* In case of equal priority values, corresponding template event listeners will be handled in default compilation order.
|
||||
* If not set, template event listener priority will be assigned to the value of 0.
|
||||
*
|
||||
* @event core.twig_tokenparser_constructor
|
||||
* @var array template_event_priority_array Array with template event priority assignments per extension namespace
|
||||
* Usage:
|
||||
* '<author>_<extension_name>' => [
|
||||
* 'event/<template_event_name>' => priority_number,
|
||||
* ],
|
||||
*
|
||||
* Example:
|
||||
* 'phpbb_viglink' => [
|
||||
* 'event/acp_help_phpbb_stats_after' => 80,
|
||||
* 'event/overall_footer_after' => 100,
|
||||
* ],
|
||||
*
|
||||
* @since 4.0.0-a1
|
||||
*/
|
||||
if ($this->phpbb_dispatcher)
|
||||
{
|
||||
$vars = array('template_event_priority_array');
|
||||
$vars = ['template_event_priority_array'];
|
||||
extract($this->phpbb_dispatcher->trigger_event('core.twig_tokenparser_constructor', compact($vars)));
|
||||
}
|
||||
|
||||
$this->template_event_priority_array = $template_event_priority_array;
|
||||
unset($template_event_priority_array);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -190,7 +190,7 @@ abstract class phpbb_console_user_base extends phpbb_database_test_case
|
|||
'autoescape' => false,
|
||||
]
|
||||
);
|
||||
$twig_extension = new \phpbb\template\twig\extension($context, $twig, $this->language);
|
||||
$twig_extension = new \phpbb\template\twig\extension($context, $twig, $this->language, $phpbb_dispatcher);
|
||||
$phpbb_container->set('template.twig.extensions.phpbb', $twig_extension);
|
||||
|
||||
$twig_extensions_collection = new \phpbb\di\service_collection($phpbb_container);
|
||||
|
|
|
@ -16,8 +16,6 @@
|
|||
*/
|
||||
class phpbb_functional_extension_controller_test extends phpbb_functional_test_case
|
||||
{
|
||||
protected $phpbb_extension_manager;
|
||||
|
||||
private static $helper;
|
||||
|
||||
protected static $fixtures = array(
|
||||
|
|
|
@ -16,8 +16,6 @@
|
|||
*/
|
||||
class phpbb_functional_extension_global_lang_test extends phpbb_functional_test_case
|
||||
{
|
||||
protected $phpbb_extension_manager;
|
||||
|
||||
private static $helper;
|
||||
|
||||
protected static $fixtures = array(
|
||||
|
@ -47,10 +45,20 @@ class phpbb_functional_extension_global_lang_test extends phpbb_functional_test_
|
|||
$this->purge_cache();
|
||||
}
|
||||
|
||||
protected function tearDown(): void
|
||||
{
|
||||
$this->uninstall_ext('foo/bar');
|
||||
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
protected static function setup_extensions()
|
||||
{
|
||||
return ['foo/bar'];
|
||||
}
|
||||
|
||||
public function test_load_extension_lang_globally()
|
||||
{
|
||||
$this->phpbb_extension_manager->enable('foo/bar');
|
||||
|
||||
// The board index, which should contain an overwritten translation
|
||||
$crawler = self::request('GET', 'index.php');
|
||||
|
||||
|
@ -59,7 +67,5 @@ class phpbb_functional_extension_global_lang_test extends phpbb_functional_test_
|
|||
|
||||
// language from ext/foo/bar/language/en/foo_global.php
|
||||
$this->assertStringContainsString('Overwritten by foo', $crawler->filter('.skiplink')->text());
|
||||
|
||||
$this->phpbb_extension_manager->purge('foo/bar');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,8 +17,6 @@ require_once __DIR__ . '/../../phpBB/includes/acp/acp_modules.php';
|
|||
*/
|
||||
class phpbb_functional_extension_module_test extends phpbb_functional_test_case
|
||||
{
|
||||
protected $phpbb_extension_manager;
|
||||
|
||||
private static $helper;
|
||||
|
||||
protected static $fixtures = array(
|
||||
|
|
|
@ -16,8 +16,6 @@
|
|||
*/
|
||||
class phpbb_functional_extension_permission_lang_test extends phpbb_functional_test_case
|
||||
{
|
||||
protected $phpbb_extension_manager;
|
||||
|
||||
private static $helper;
|
||||
|
||||
protected static $fixtures = array(
|
||||
|
@ -76,7 +74,5 @@ class phpbb_functional_extension_permission_lang_test extends phpbb_functional_t
|
|||
|
||||
// language from ext/foo/bar/language/en/permissions_foo.php
|
||||
$this->assertStringContainsString('Can view foobar', $crawler->filter('body')->text());
|
||||
|
||||
$this->phpbb_extension_manager->purge('foo/bar');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,8 +16,6 @@
|
|||
*/
|
||||
class phpbb_functional_extension_template_event_order_test extends phpbb_functional_test_case
|
||||
{
|
||||
protected $phpbb_extension_manager;
|
||||
|
||||
static private $helper;
|
||||
|
||||
static protected $fixtures = [
|
||||
|
@ -43,11 +41,22 @@ class phpbb_functional_extension_template_event_order_test extends phpbb_functio
|
|||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->phpbb_extension_manager = $this->get_extension_manager();
|
||||
|
||||
$this->purge_cache();
|
||||
}
|
||||
|
||||
protected function tearDown(): void
|
||||
{
|
||||
$this->uninstall_ext('foo/bar');
|
||||
$this->uninstall_ext('foo/foo');
|
||||
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
protected static function setup_extensions()
|
||||
{
|
||||
return ['foo/bar', 'foo/foo'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Check a controller for extension foo/bar.
|
||||
*/
|
||||
|
@ -55,32 +64,28 @@ class phpbb_functional_extension_template_event_order_test extends phpbb_functio
|
|||
{
|
||||
global $phpbb_root_path;
|
||||
|
||||
$this->phpbb_extension_manager->enable('foo/bar');
|
||||
$this->phpbb_extension_manager->enable('foo/foo');
|
||||
$crawler = self::request('GET', 'index.php');
|
||||
$quick_links_menu = $crawler->filter('ul[role="menu"]')->eq(0);
|
||||
$quick_links_menu_nodes_count = (int) $quick_links_menu->filter('li')->count();
|
||||
// Ensure foo/foo template event goes before foo/bar one
|
||||
$this->assertStringContainsString('FOO_FOO_QUICK_LINK', $quick_links_menu->filter('li')->eq($quick_links_menu_nodes_count - 2)->filter('span')->text());
|
||||
$this->assertStringContainsString('FOO_BAR_QUICK_LINK', $quick_links_menu->filter('li')->eq($quick_links_menu_nodes_count - 1)->filter('span')->text());
|
||||
$this->assertStringContainsString('FOO_FOO_QUICK_LINK', $quick_links_menu->filter('li')->eq($quick_links_menu_nodes_count - 4)->filter('span')->text());
|
||||
$this->assertStringContainsString('FOO_BAR_QUICK_LINK', $quick_links_menu->filter('li')->eq($quick_links_menu_nodes_count - 3)->filter('span')->text());
|
||||
|
||||
// Change template events order to default, put foo/bar event before foo/foo one
|
||||
$this->phpbb_extension_manager->disable('foo/bar');
|
||||
$this->phpbb_extension_manager->disable('foo/foo');
|
||||
$this->disable_ext('foo/bar');
|
||||
$this->disable_ext('foo/foo');
|
||||
|
||||
$this->assertTrue(copy(__DIR__ . '/fixtures/ext/foo/bar/event/template_event_order_higher.php', $phpbb_root_path . 'ext/foo/bar/event/template_event_order.php'));
|
||||
$this->assertTrue(copy(__DIR__ . '/fixtures/ext/foo/foo/event/template_event_order_lower.php', $phpbb_root_path . 'ext/foo/foo/event/template_event_order.php'));
|
||||
$this->phpbb_extension_manager->enable('foo/bar');
|
||||
$this->phpbb_extension_manager->enable('foo/foo');
|
||||
$this->purge_cache();
|
||||
sleep(3);
|
||||
|
||||
$this->install_ext('foo/bar');
|
||||
$this->install_ext('foo/foo');
|
||||
|
||||
$crawler = self::request('GET', 'index.php');
|
||||
$quick_links_menu = $crawler->filter('ul[role="menu"]')->eq(0);
|
||||
$quick_links_menu_nodes_count = (int) $quick_links_menu->filter('li')->count();
|
||||
// Ensure foo/foo template event goes before foo/bar one
|
||||
$this->assertStringContainsString('FOO_BAR_QUICK_LINK', $quick_links_menu->filter('li')->eq($quick_links_menu_nodes_count - 2)->filter('span')->text());
|
||||
$this->assertStringContainsString('FOO_FOO_QUICK_LINK', $quick_links_menu->filter('li')->eq($quick_links_menu_nodes_count - 1)->filter('span')->text());
|
||||
|
||||
$this->phpbb_extension_manager->purge('foo/bar');
|
||||
$this->phpbb_extension_manager->purge('foo/foo');
|
||||
$this->assertStringContainsString('FOO_BAR_QUICK_LINK', $quick_links_menu->filter('li')->eq($quick_links_menu_nodes_count - 4)->filter('span')->text());
|
||||
$this->assertStringContainsString('FOO_FOO_QUICK_LINK', $quick_links_menu->filter('li')->eq($quick_links_menu_nodes_count - 3)->filter('span')->text());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,8 +16,6 @@
|
|||
*/
|
||||
class phpbb_functional_metadata_manager_test extends phpbb_functional_test_case
|
||||
{
|
||||
protected $phpbb_extension_manager;
|
||||
|
||||
private static $helper;
|
||||
|
||||
protected static $fixtures = array(
|
||||
|
|
|
@ -65,6 +65,7 @@ class twig_test extends \phpbb_test_case
|
|||
$loader = new \phpbb\template\twig\loader('');
|
||||
$log = new \phpbb\log\dummy();
|
||||
$assets_bag = new \phpbb\template\assets_bag();
|
||||
$dispatcher = new \phpbb\event\dispatcher();
|
||||
$twig = new \phpbb\template\twig\environment(
|
||||
$assets_bag,
|
||||
$config,
|
||||
|
@ -73,7 +74,7 @@ class twig_test extends \phpbb_test_case
|
|||
$cache_path,
|
||||
null,
|
||||
$loader,
|
||||
new \phpbb\event\dispatcher(),
|
||||
$dispatcher,
|
||||
[
|
||||
'cache' => false,
|
||||
'debug' => false,
|
||||
|
@ -81,7 +82,7 @@ class twig_test extends \phpbb_test_case
|
|||
'autoescape' => false,
|
||||
]
|
||||
);
|
||||
$this->template = new \phpbb\template\twig\twig($path_helper, $config, $context, $twig, $cache_path, $this->user, array(new \phpbb\template\twig\extension($context, $twig, $this->user)));
|
||||
$this->template = new \phpbb\template\twig\twig($path_helper, $config, $context, $twig, $cache_path, $this->user, array(new \phpbb\template\twig\extension($context, $twig, $this->user, $dispatcher)));
|
||||
$twig->setLexer(new \phpbb\template\twig\lexer($twig));
|
||||
}
|
||||
|
||||
|
|
|
@ -146,9 +146,6 @@ class phpbb_functional_test_case extends phpbb_test_case
|
|||
// Close the database connections again this test
|
||||
$this->db->sql_close();
|
||||
}
|
||||
|
||||
$this->purge_cache();
|
||||
sleep(3); // Give it some time to delete all the files correctly
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -410,7 +407,7 @@ class phpbb_functional_test_case extends phpbb_test_case
|
|||
'autoescape' => false,
|
||||
]
|
||||
);
|
||||
$twig_extension = new \phpbb\template\twig\extension($context, $twig, $lang);
|
||||
$twig_extension = new \phpbb\template\twig\extension($context, $twig, $lang, $phpbb_dispatcher);
|
||||
$container->set('template.twig.extensions.phpbb', $twig_extension);
|
||||
|
||||
$twig_extensions_collection = new \phpbb\di\service_collection($container);
|
||||
|
@ -647,7 +644,7 @@ class phpbb_functional_test_case extends phpbb_test_case
|
|||
|
||||
$meta_refresh = $crawler->filter('meta[http-equiv="refresh"]');
|
||||
|
||||
// Wait for extension to be fully enabled
|
||||
// Wait for extension to be fully disabled
|
||||
while (count($meta_refresh))
|
||||
{
|
||||
preg_match('#url=.+/(adm+.+)#', $meta_refresh->attr('content'), $match);
|
||||
|
|
Loading…
Add table
Reference in a new issue