|
| 1 | +<?php |
| 2 | +/** |
| 3 | + * |
| 4 | + * Ideas extension for the phpBB Forum Software package. |
| 5 | + * |
| 6 | + * @copyright (c) phpBB Limited <https://www.phpbb.com> |
| 7 | + * @license GNU General Public License, version 2 (GPL-2.0) |
| 8 | + * |
| 9 | + */ |
| 10 | + |
| 11 | +namespace phpbb\ideas\tests\template; |
| 12 | + |
| 13 | +require_once __DIR__ . '/../../../../../../tests/template/template_test_case.php'; |
| 14 | + |
| 15 | +class status_icon_test extends \phpbb_template_template_test_case |
| 16 | +{ |
| 17 | + protected $test_path = __DIR__; |
| 18 | + |
| 19 | + protected function setup_engine(array $new_config = array()) |
| 20 | + { |
| 21 | + global $phpbb_root_path, $phpEx; |
| 22 | + |
| 23 | + $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'); |
| 28 | + $this->user = $user; |
| 29 | + |
| 30 | + $filesystem = new \phpbb\filesystem\filesystem(); |
| 31 | + |
| 32 | + $path_helper = new \phpbb\path_helper( |
| 33 | + new \phpbb\symfony_request( |
| 34 | + new \phpbb_mock_request() |
| 35 | + ), |
| 36 | + $filesystem, |
| 37 | + $this->createMock('\phpbb\request\request'), |
| 38 | + $phpbb_root_path, |
| 39 | + $phpEx |
| 40 | + ); |
| 41 | + |
| 42 | + $this->template_path = $this->test_path . '/templates'; |
| 43 | + |
| 44 | + $container = new \phpbb_mock_container_builder(); |
| 45 | + $cache_path = $phpbb_root_path . 'cache/twig'; |
| 46 | + $context = new \phpbb\template\context(); |
| 47 | + $loader = new \phpbb\template\twig\loader(new \phpbb\filesystem\filesystem(), ''); |
| 48 | + $twig = new \phpbb\template\twig\environment( |
| 49 | + $config, |
| 50 | + $filesystem, |
| 51 | + $path_helper, |
| 52 | + $cache_path, |
| 53 | + null, |
| 54 | + $loader, |
| 55 | + new \phpbb\event\dispatcher($container), |
| 56 | + [ |
| 57 | + 'cache' => false, |
| 58 | + 'debug' => false, |
| 59 | + 'auto_reload' => true, |
| 60 | + 'autoescape' => false, |
| 61 | + ] |
| 62 | + ); |
| 63 | + $this->template = new \phpbb\template\twig\twig( |
| 64 | + $path_helper, |
| 65 | + $config, |
| 66 | + $context, |
| 67 | + $twig, |
| 68 | + $cache_path, |
| 69 | + $this->user, |
| 70 | + [ |
| 71 | + new \phpbb\template\twig\extension($context, $twig, $this->lang), |
| 72 | + new \phpbb\ideas\template\twig\extension\ideas_status_icon(), |
| 73 | + ] |
| 74 | + ); |
| 75 | + $twig->setLexer(new \phpbb\template\twig\lexer($twig)); |
| 76 | + $this->template->set_custom_style('tests', $this->template_path); |
| 77 | + } |
| 78 | + |
| 79 | + public function data_template_status_icons() |
| 80 | + { |
| 81 | + return [ |
| 82 | + [0, ''], |
| 83 | + [1, 'fa-lightbulb-o'], |
| 84 | + [2, 'fa-code-fork'], |
| 85 | + [3, 'fa-check'], |
| 86 | + [4, 'fa-files-o'], |
| 87 | + [5, 'fa-ban'], |
| 88 | + ]; |
| 89 | + } |
| 90 | + |
| 91 | + /** |
| 92 | + * @dataProvider data_template_status_icons |
| 93 | + */ |
| 94 | + public function test_ideas_status_icon($var, $expected) |
| 95 | + { |
| 96 | + $this->run_template('status_icon.html', ['id' => $var], [], [], $expected, []); |
| 97 | + } |
| 98 | +} |
0 commit comments