|
10 | 10 |
|
11 | 11 | namespace phpbb\ideas\tests\template; |
12 | 12 |
|
| 13 | +use phpbb\config\config; |
| 14 | +use phpbb\event\dispatcher; |
| 15 | +use phpbb\filesystem\filesystem; |
| 16 | +use phpbb\ideas\template\twig\extension\ideas_status_icon; |
| 17 | +use phpbb\language\language; |
| 18 | +use phpbb\language\language_file_loader; |
| 19 | +use phpbb\path_helper; |
| 20 | +use phpbb\symfony_request; |
| 21 | +use phpbb\template\assets_bag; |
| 22 | +use phpbb\template\context; |
| 23 | +use phpbb\template\twig\environment; |
| 24 | +use phpbb\template\twig\extension; |
| 25 | +use phpbb\template\twig\lexer; |
| 26 | +use phpbb\template\twig\loader; |
| 27 | +use phpbb\template\twig\twig; |
| 28 | +use phpbb\user; |
| 29 | +use phpbb_mock_request; |
| 30 | +use phpbb_template_template_test_case; |
| 31 | +use phpbb\datetime; |
| 32 | +use phpbb\request\request; |
| 33 | + |
13 | 34 | require_once __DIR__ . '/../../../../../../tests/template/template_test_case.php'; |
14 | 35 |
|
15 | | -class status_icon_test extends \phpbb_template_template_test_case |
| 36 | +class status_icon_test extends phpbb_template_template_test_case |
16 | 37 | { |
17 | 38 | protected $test_path = __DIR__; |
18 | 39 |
|
19 | | - protected function setup_engine(array $new_config = array()) |
| 40 | + public function setup_engine(array $new_config = [], string $template_path = ''): void |
20 | 41 | { |
21 | 42 | global $phpbb_root_path, $phpEx; |
22 | 43 |
|
23 | 44 | $defaults = $this->config_defaults(); |
24 | | - $config = new \phpbb\config\config(array_merge($defaults, $new_config)); |
25 | | - $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx); |
26 | | - $this->lang = $lang = new \phpbb\language\language($lang_loader); |
27 | | - $user = new \phpbb\user($lang, '\phpbb\datetime'); |
| 45 | + $config = new config(array_merge($defaults, $new_config)); |
| 46 | + $lang_loader = new language_file_loader($phpbb_root_path, $phpEx); |
| 47 | + $this->lang = $lang = new language($lang_loader); |
| 48 | + $user = new user($lang, datetime::class); |
28 | 49 | $this->user = $user; |
29 | 50 |
|
30 | | - $filesystem = new \phpbb\filesystem\filesystem(); |
| 51 | + $filesystem = new filesystem(); |
31 | 52 |
|
32 | | - $path_helper = new \phpbb\path_helper( |
33 | | - new \phpbb\symfony_request( |
34 | | - new \phpbb_mock_request() |
| 53 | + $path_helper = new path_helper( |
| 54 | + new symfony_request( |
| 55 | + new phpbb_mock_request() |
35 | 56 | ), |
36 | | - $this->createMock('\phpbb\request\request'), |
| 57 | + $this->createMock(request::class), |
37 | 58 | $phpbb_root_path, |
38 | 59 | $phpEx |
39 | 60 | ); |
40 | 61 |
|
41 | 62 | $this->template_path = $this->test_path . '/templates'; |
42 | 63 |
|
43 | 64 | $cache_path = $phpbb_root_path . 'cache/twig'; |
44 | | - $context = new \phpbb\template\context(); |
45 | | - $loader = new \phpbb\template\twig\loader(); |
46 | | - $assets_bag = new \phpbb\template\assets_bag(); |
47 | | - $twig = new \phpbb\template\twig\environment( |
| 65 | + $context = new context(); |
| 66 | + $loader = new loader(); |
| 67 | + $assets_bag = new assets_bag(); |
| 68 | + $twig = new environment( |
48 | 69 | $assets_bag, |
49 | 70 | $config, |
50 | 71 | $filesystem, |
51 | 72 | $path_helper, |
52 | 73 | $cache_path, |
53 | 74 | null, |
54 | 75 | $loader, |
55 | | - new \phpbb\event\dispatcher(), |
| 76 | + new dispatcher(), |
56 | 77 | [ |
57 | 78 | 'cache' => false, |
58 | 79 | 'debug' => false, |
59 | 80 | 'auto_reload' => true, |
60 | 81 | 'autoescape' => false, |
61 | 82 | ] |
62 | 83 | ); |
63 | | - $this->template = new \phpbb\template\twig\twig( |
| 84 | + $this->template = new twig( |
64 | 85 | $path_helper, |
65 | 86 | $config, |
66 | 87 | $context, |
67 | 88 | $twig, |
68 | 89 | $cache_path, |
69 | 90 | $this->user, |
70 | 91 | [ |
71 | | - new \phpbb\template\twig\extension($context, $twig, $this->lang), |
72 | | - new \phpbb\ideas\template\twig\extension\ideas_status_icon(), |
| 92 | + new extension($context, $twig, $this->lang), |
| 93 | + new ideas_status_icon(), |
73 | 94 | ] |
74 | 95 | ); |
75 | | - $twig->setLexer(new \phpbb\template\twig\lexer($twig)); |
| 96 | + $twig->setLexer(new lexer($twig)); |
76 | 97 | $this->template->set_custom_style('tests', $this->template_path); |
77 | 98 | } |
78 | 99 |
|
79 | | - public function data_template_status_icons() |
| 100 | + public function data_template_status_icons(): array |
80 | 101 | { |
81 | 102 | return [ |
82 | 103 | [0, ''], |
|
0 commit comments