diff options
author | Tristan Darricau <github@nicofuma.fr> | 2014-08-02 19:09:42 +0200 |
---|---|---|
committer | Tristan Darricau <github@nicofuma.fr> | 2014-08-09 16:13:22 +0200 |
commit | 192b8e2568f499aa2ead98a24d8dd5541b1f315a (patch) | |
tree | 0371c204bba34dd9eb480292de6144dbc021fa50 /tests | |
parent | 56ca276dcf080972ad2c5ae411b37c392ffed24d (diff) | |
download | forums-192b8e2568f499aa2ead98a24d8dd5541b1f315a.tar forums-192b8e2568f499aa2ead98a24d8dd5541b1f315a.tar.gz forums-192b8e2568f499aa2ead98a24d8dd5541b1f315a.tar.bz2 forums-192b8e2568f499aa2ead98a24d8dd5541b1f315a.tar.xz forums-192b8e2568f499aa2ead98a24d8dd5541b1f315a.zip |
[ticket/11649] Expose Twig through the container
PHPBB3-11649
Diffstat (limited to 'tests')
-rw-r--r-- | tests/controller/helper_route_test.php | 23 | ||||
-rw-r--r-- | tests/extension/metadata_manager_test.php | 38 | ||||
-rw-r--r-- | tests/template/template_events_test.php | 23 | ||||
-rw-r--r-- | tests/template/template_test_case.php | 22 | ||||
-rw-r--r-- | tests/template/template_test_case_with_tree.php | 22 |
5 files changed, 112 insertions, 16 deletions
diff --git a/tests/controller/helper_route_test.php b/tests/controller/helper_route_test.php index 206c3a4f0b..8113bd0018 100644 --- a/tests/controller/helper_route_test.php +++ b/tests/controller/helper_route_test.php @@ -31,7 +31,28 @@ class phpbb_controller_helper_route_test extends phpbb_test_case $phpEx ); $this->config = new \phpbb\config\config(array('enable_mod_rewrite' => '0')); - $this->template = new phpbb\template\twig\twig($phpbb_path_helper, $this->config, $this->user, new \phpbb\template\context()); + + $container = new phpbb_mock_container_builder(); + $cache_path = $phpbb_root_path . 'cache/twig'; + $context = new \phpbb\template\context(); + $loader = new \phpbb\template\twig\loader(''); + $twig = new \phpbb\template\twig\environment( + $this->config, + $phpbb_path_helper, + $container, + $cache_path, + null, + $loader, + array( + 'cache' => false, + 'debug' => false, + 'auto_reload' => true, + 'autoescape' => false, + ) + ); + $this->template = new phpbb\template\twig\twig($phpbb_path_helper, $this->config, $this->user, $context, $twig, $cache_path, array(new \phpbb\template\twig\extension($context, $this->user))); + $container->set('template.twig.lexer', new \phpbb\template\twig\lexer($twig)); + $this->extension_manager = new phpbb_mock_extension_manager( dirname(__FILE__) . '/', array( diff --git a/tests/extension/metadata_manager_test.php b/tests/extension/metadata_manager_test.php index 535e4fe0d5..fdb9deda53 100644 --- a/tests/extension/metadata_manager_test.php +++ b/tests/extension/metadata_manager_test.php @@ -47,20 +47,35 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case $this->user = new \phpbb\user(); $this->table_prefix = 'phpbb_'; - $this->template = new \phpbb\template\twig\twig( - new \phpbb\path_helper( - new \phpbb\symfony_request( - new phpbb_mock_request() - ), - new \phpbb\filesystem(), - $this->getMock('\phpbb\request\request'), - $this->phpbb_root_path, - $this->phpEx + $container = new phpbb_mock_container_builder(); + $cache_path = $this->phpbb_root_path . 'cache/twig'; + $context = new \phpbb\template\context(); + $loader = new \phpbb\template\twig\loader(''); + $phpbb_path_helper =new \phpbb\path_helper( + new \phpbb\symfony_request( + new phpbb_mock_request() ), + new \phpbb\filesystem(), + $this->getMock('\phpbb\request\request'), + $this->phpbb_root_path, + $this->phpEx + ); + $twig = new \phpbb\template\twig\environment( $this->config, - $this->user, - new \phpbb\template\context() + $phpbb_path_helper, + $container, + $cache_path, + null, + $loader, + array( + 'cache' => false, + 'debug' => false, + 'auto_reload' => true, + 'autoescape' => false, + ) ); + $this->template = new phpbb\template\twig\twig($phpbb_path_helper, $this->config, $this->user, $context, $twig, $cache_path, array(new \phpbb\template\twig\extension($context, $this->user))); + $container->set('template.twig.lexer', new \phpbb\template\twig\lexer($twig)); $this->migrator = new \phpbb\db\migrator( $this->config, @@ -73,7 +88,6 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case array(), new \phpbb\db\migration\helper() ); - $container = new phpbb_mock_container_builder(); $container->set('migrator', $this->migrator); $this->extension_manager = new \phpbb\extension\manager( diff --git a/tests/template/template_events_test.php b/tests/template/template_events_test.php index c415c969fe..e8ffea8d11 100644 --- a/tests/template/template_events_test.php +++ b/tests/template/template_events_test.php @@ -147,7 +147,28 @@ Zeta test event in all', $phpbb_root_path, $phpEx ); - $this->template = new \phpbb\template\twig\twig($path_helper, $config, $user, new \phpbb\template\context, $this->extension_manager); + + $container = new phpbb_mock_container_builder(); + $cache_path = $phpbb_root_path . 'cache/twig'; + $context = new \phpbb\template\context(); + $loader = new \phpbb\template\twig\loader(''); + $twig = new \phpbb\template\twig\environment( + $config, + $path_helper, + $container, + $cache_path, + $this->extension_manager, + $loader, + array( + 'cache' => false, + 'debug' => false, + 'auto_reload' => true, + 'autoescape' => false, + ) + ); + $this->template = new \phpbb\template\twig\twig($path_helper, $config, $user, $context, $twig, $cache_path, array(new \phpbb\template\twig\extension($context, $this->user)), $this->extension_manager); + $container->set('template.twig.lexer', new \phpbb\template\twig\lexer($twig)); + $this->template->set_custom_style(((!empty($style_names)) ? $style_names : 'silver'), array($this->template_path)); } } diff --git a/tests/template/template_test_case.php b/tests/template/template_test_case.php index 83446b5352..1f46d6ff71 100644 --- a/tests/template/template_test_case.php +++ b/tests/template/template_test_case.php @@ -78,7 +78,27 @@ class phpbb_template_template_test_case extends phpbb_test_case ); $this->template_path = $this->test_path . '/templates'; - $this->template = new \phpbb\template\twig\twig($path_helper, $config, $this->user, new \phpbb\template\context()); + + $container = new phpbb_mock_container_builder(); + $cache_path = $phpbb_root_path . 'cache/twig'; + $context = new \phpbb\template\context(); + $loader = new \phpbb\template\twig\loader(''); + $twig = new \phpbb\template\twig\environment( + $config, + $path_helper, + $container, + $cache_path, + null, + $loader, + array( + 'cache' => false, + 'debug' => false, + 'auto_reload' => true, + 'autoescape' => false, + ) + ); + $this->template = new phpbb\template\twig\twig($path_helper, $config, $user, $context, $twig, $cache_path, array(new \phpbb\template\twig\extension($context, $this->user))); + $container->set('template.twig.lexer', new \phpbb\template\twig\lexer($twig)); $this->template->set_custom_style('tests', $this->template_path); } diff --git a/tests/template/template_test_case_with_tree.php b/tests/template/template_test_case_with_tree.php index 68ecc4b706..c634e2051a 100644 --- a/tests/template/template_test_case_with_tree.php +++ b/tests/template/template_test_case_with_tree.php @@ -34,7 +34,27 @@ class phpbb_template_template_test_case_with_tree extends phpbb_template_templat $this->template_path = $this->test_path . '/templates'; $this->parent_template_path = $this->test_path . '/parent_templates'; - $this->template = new phpbb\template\twig\twig($this->phpbb_path_helper, $config, $user, new phpbb\template\context()); + + $container = new phpbb_mock_container_builder(); + $cache_path = $phpbb_root_path . 'cache/twig'; + $context = new \phpbb\template\context(); + $loader = new \phpbb\template\twig\loader(''); + $twig = new \phpbb\template\twig\environment( + $config, + $this->phpbb_path_helper, + $container, + $cache_path, + null, + $loader, + array( + 'cache' => false, + 'debug' => false, + 'auto_reload' => true, + 'autoescape' => false, + ) + ); + $this->template = new phpbb\template\twig\twig($this->phpbb_path_helper, $config, $user, $context, $twig, $cache_path, array(new \phpbb\template\twig\extension($context, $this->user))); + $container->set('template.twig.lexer', new \phpbb\template\twig\lexer($twig)); $this->template->set_custom_style('tests', array($this->template_path, $this->parent_template_path)); } } |