forked from phpbb-extensions/phpbb-ext-skeleton
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtemplate_test.php
More file actions
139 lines (128 loc) · 3.12 KB
/
template_test.php
File metadata and controls
139 lines (128 loc) · 3.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
<?php
/**
*
* This file is part of the phpBB Forum Software package.
*
* @copyright (c) phpBB Limited <https://www.phpbb.com>
* @license GNU General Public License, version 2 (GPL-2.0)
*
* For full copyright and license information, please see
* the docs/CREDITS.txt file.
*
*/
namespace phpbb\skeleton\tests\template;
require_once __DIR__ . '/../../../../../../tests/template/template_test_case.php';
class template_test extends \phpbb_template_template_test_case
{
protected $test_path = __DIR__;
protected function setup_engine(array $new_config = array(), string $template_path = '')
{
global $phpbb_root_path, $phpEx;
$defaults = $this->config_defaults();
$config = new \phpbb\config\config(array_merge($defaults, $new_config));
$lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx);
$this->lang = $lang = new \phpbb\language\language($lang_loader);
$user = new \phpbb\user($lang, '\phpbb\datetime');
$this->user = $user;
$filesystem = new \phpbb\filesystem\filesystem();
$path_helper = new \phpbb\path_helper(
new \phpbb\symfony_request(
new \phpbb_mock_request()
),
$filesystem,
$this->createMock('\phpbb\request\request'),
$phpbb_root_path,
$phpEx
);
$this->template_path = $this->test_path . '/templates';
$cache_path = $phpbb_root_path . 'cache/twig';
$context = new \phpbb\template\context();
$loader = new \phpbb\template\twig\loader(new \phpbb\filesystem\filesystem(), '');
$twig = new \phpbb\template\twig\environment(
$config,
$filesystem,
$path_helper,
$cache_path,
null,
$loader,
new \phpbb\event\dispatcher(),
[
'cache' => false,
'debug' => false,
'auto_reload' => true,
'autoescape' => false,
]
);
$this->template = new \phpbb\template\twig\twig(
$path_helper,
$config,
$context,
$twig,
$cache_path,
$this->user,
[
new \phpbb\template\twig\extension($context, $twig, $this->lang),
new \phpbb\skeleton\template\twig\extension\skeleton_version_compare(),
]
);
$twig->setLexer(new \phpbb\template\twig\lexer($twig));
$this->template->set_custom_style('tests', $this->template_path);
}
public function data_template_version_check()
{
return [
[
'skeleton_version_compare.html',
[
'ver1' => '3.1.0',
'ver2' => '3.3.0',
'operator' => '<',
],
'true',
],
[
'skeleton_version_compare.html',
[
'ver1' => '3.1.0-rc5',
'ver2' => '4.0.0@dev',
'operator' => '<',
],
'true',
],
[
'skeleton_version_compare.html',
[
'ver1' => '3.1.0',
'ver2' => '3.3.0',
'operator' => '>',
],
'false',
],
[
'skeleton_version_compare.html',
[
'ver1' => '3.1.0',
'ver2' => '3.3.0',
'operator' => null,
],
'false',
],
[
'skeleton_version_compare.html',
[
'ver1' => null,
'ver2' => '3.3.0',
'operator' => '<',
],
'false',
],
];
}
/**
* @dataProvider data_template_version_check
*/
public function test_skeleton_version_compare($file, $vars, $expected)
{
$this->run_template($file, $vars, [], [], $expected, []);
}
}