19 declare(strict_types=1);
30 $this->il_template =
new class () extends
ilTemplate {
31 protected string $style =
'delos';
32 protected string $skin =
'default';
33 protected bool $file_exists =
true;
37 public function _getTemplatePath(
string $a_tplname, ?
string $a_in_module =
null):
string 39 return $this->getTemplatePath($a_tplname, $a_in_module);
41 protected function getCurrentStyle(): ?
string 45 public function withStyle(
string $style)
48 $clone->style = $style;
51 public function withSkin(
string $skin)
57 protected function getCurrentSkin(): ?
string 61 protected function fileExistsInSkin(
string $path):
bool 63 return $this->file_exists;
65 public function withFileExists(
bool $file_exists)
68 $clone->file_exists = $file_exists;
72 $this->il_root = realpath(__DIR__ .
'/../../../../');
79 $il_root = realpath(__DIR__ .
'/../../../../');
81 'standard component template' => [
82 'skin' =>
'default',
'style' =>
'delos',
'file_exists' =>
true,
83 'tpl_filename' =>
'tpl.appointment_panel.html',
84 'component' =>
'components/ILIAS/Calendar',
85 'expected' => $il_root .
'/components/ILIAS/Calendar/templates/default/tpl.appointment_panel.html' 87 'plugin template' => [
88 'skin' =>
'default',
'style' =>
'delos',
'file_exists' =>
true,
89 'tpl_filename' =>
'tpl.test.html',
91 'component' => $il_root .
'/components/ILIAS/Component/classes/../../../../public/Customizing/global/plugins/Services/UIComponent/UserInterfaceHook/EditorAsMode',
92 'expected' => $il_root .
'/components/ILIAS/Component/classes/../../../../public/Customizing/global/plugins/Services/UIComponent/UserInterfaceHook/EditorAsMode/templates/default/tpl.test.html',
94 'plugin template_file_no_component' => [
95 'skin' =>
'default',
'style' =>
'delos',
'file_exists' =>
true,
96 'tpl_filename' => $il_root .
'/components/ILIAS/Component/classes/../../../../public/Customizing/global/plugins/Services/User/UDFDefinition/CascadingSelect/templates/tpl.prop_cascading_select.html',
98 'expected' => $il_root .
'/components/ILIAS/Component/classes/../../../../public/Customizing/global/plugins/Services/User/UDFDefinition/CascadingSelect/templates/tpl.prop_cascading_select.html',
101 'skin' =>
'mySkin',
'style' =>
'myStyle',
'file_exists' =>
true,
102 'tpl_filename' =>
'tpl.external_settings.html',
103 'component' =>
'components/ILIAS/Administration',
104 'expected' => $il_root .
'/public/Customizing/skin/mySkin/myStyle/components/ILIAS/Administration/tpl.external_settings.html',
106 'custom skin, unaltered file' => [
107 'skin' =>
'mySkin',
'style' =>
'myStyle',
'file_exists' =>
false,
108 'tpl_filename' =>
'tpl.external_settings.html',
109 'component' =>
'components/ILIAS/Administration',
110 'expected' => $il_root .
'/components/ILIAS/Administration/templates/default/tpl.external_settings.html',
113 'skin' =>
'default',
'style' =>
'delos',
'file_exists' =>
true,
114 'tpl_filename' =>
'components/ILIAS/UI/src/templates/default/Input/tpl.standard.html',
116 'expected' => $il_root .
'/components/ILIAS/UI/src/templates/default/Input/tpl.standard.html',
118 'ui template from skin' => [
119 'skin' =>
'mySkin',
'style' =>
'myStyle',
'file_exists' =>
true,
120 'tpl_filename' =>
'components/ILIAS/UI/src/templates/default/Input/tpl.standard.html',
122 'expected' => $il_root .
'/public/Customizing/skin/mySkin/myStyle/UI/Input/tpl.standard.html',
124 'ui template from skin, unaltered' => [
125 'skin' =>
'mySkin',
'style' =>
'myStyle',
'file_exists' =>
false,
126 'tpl_filename' =>
'components/ILIAS/UI/src/templates/default/Input/tpl.standard.html',
128 'expected' => $il_root .
'/components/ILIAS/UI/src/templates/default/Input/tpl.standard.html',
130 'trailing slash' => [
131 'skin' =>
'default',
'style' =>
'delos',
'file_exists' =>
true,
132 'tpl_filename' =>
'tpl.test.html',
133 'component' =>
'components/ILIAS/Test/',
134 'expected' => $il_root .
'/components/ILIAS/Test/templates/default/tpl.test.html',
140 #[\PHPUnit\Framework\Attributes\DataProvider('templatePathDataProvider')] 145 string $tpl_filename,
149 $path = $this->il_template
152 ->withFileExists($file_exists)
153 ->_getTemplatePath($tpl_filename, $component);
155 $this->assertEquals($expected,
$path);
testGetTemplatePath(string $skin, string $style, bool $file_exists, string $tpl_filename, string $component, string $expected)
static templatePathDataProvider()
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
__construct(Container $dic, ilPlugin $plugin)