ILIAS  trunk Revision v11.0_alpha-1843-g9e1fad99175
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilTemplateTest Class Reference
+ Inheritance diagram for ilTemplateTest:
+ Collaboration diagram for ilTemplateTest:

Public Member Functions

 setUp ()
 
 testGetTemplatePath (string $skin, string $style, bool $file_exists, string $tpl_filename, string $component, string $expected)
 templatePathDataProvider More...
 

Static Public Member Functions

static templatePathDataProvider ()
 

Protected Attributes

ilTemplate $il_template
 
string $il_root
 

Detailed Description

Definition at line 23 of file ilTemplateTest.php.

Member Function Documentation

◆ setUp()

ilTemplateTest::setUp ( )

Definition at line 28 of file ilTemplateTest.php.

References $path, ILIAS\GlobalScreen\Provider\__construct(), and null.

28  : void
29  {
30  $this->il_template = new class () extends ilTemplate {
31  protected string $style = 'delos';
32  protected string $skin = 'default';
33  protected bool $file_exists = true;
34  public function __construct()
35  {
36  }
37  public function _getTemplatePath(string $a_tplname, ?string $a_in_module = null): string
38  {
39  return $this->getTemplatePath($a_tplname, $a_in_module);
40  }
41  protected function getCurrentStyle(): ?string
42  {
43  return $this->style;
44  }
45  public function withStyle(string $style)
46  {
47  $clone = clone $this;
48  $clone->style = $style;
49  return $clone;
50  }
51  public function withSkin(string $skin)
52  {
53  $clone = clone $this;
54  $clone->skin = $skin;
55  return $clone;
56  }
57  protected function getCurrentSkin(): ?string
58  {
59  return $this->skin;
60  }
61  protected function fileExistsInSkin(string $path): bool
62  {
63  return $this->file_exists;
64  }
65  public function withFileExists(bool $file_exists)
66  {
67  $clone = clone $this;
68  $clone->file_exists = $file_exists;
69  return $clone;
70  }
71  };
72  $this->il_root = realpath(__DIR__ . '/../../../../');
73 
74  }
$path
Definition: ltiservices.php:29
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
__construct(Container $dic, ilPlugin $plugin)
+ Here is the call graph for this function:

◆ templatePathDataProvider()

static ilTemplateTest::templatePathDataProvider ( )
static

Definition at line 77 of file ilTemplateTest.php.

77  : array
78  {
79  $il_root = realpath(__DIR__ . '/../../../../');
80  return [
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'
86  ],
87  'plugin template' => [
88  'skin' => 'default', 'style' => 'delos', 'file_exists' => true,
89  'tpl_filename' => 'tpl.test.html',
90  //ilPlugin::getDirectory() will return something like this:
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',
93  ],
94  'custom skin' => [
95  'skin' => 'mySkin', 'style' => 'myStyle', 'file_exists' => true,
96  'tpl_filename' => 'tpl.external_settings.html',
97  'component' => 'components/ILIAS/Administration',
98  'expected' => $il_root . '/public/Customizing/skin/mySkin/myStyle/components/ILIAS/Administration/tpl.external_settings.html',
99  ],
100  'custom skin, unaltered file' => [
101  'skin' => 'mySkin', 'style' => 'myStyle', 'file_exists' => false,
102  'tpl_filename' => 'tpl.external_settings.html',
103  'component' => 'components/ILIAS/Administration',
104  'expected' => $il_root . '/components/ILIAS/Administration/templates/default/tpl.external_settings.html',
105  ],
106  'ui template' => [
107  'skin' => 'default', 'style' => 'delos', 'file_exists' => true,
108  'tpl_filename' => 'components/ILIAS/UI/src/templates/default/Input/tpl.standard.html',
109  'component' => '',
110  'expected' => $il_root . '/components/ILIAS/UI/src/templates/default/Input/tpl.standard.html',
111  ],
112  'ui template from skin' => [
113  'skin' => 'mySkin', 'style' => 'myStyle', 'file_exists' => true,
114  'tpl_filename' => 'components/ILIAS/UI/src/templates/default/Input/tpl.standard.html',
115  'component' => '',
116  'expected' => $il_root . '/public/Customizing/skin/mySkin/myStyle/UI/Input/tpl.standard.html',
117  ],
118  'ui template from skin, unaltered' => [
119  'skin' => 'mySkin', 'style' => 'myStyle', 'file_exists' => false,
120  'tpl_filename' => 'components/ILIAS/UI/src/templates/default/Input/tpl.standard.html',
121  'component' => '',
122  'expected' => $il_root . '/components/ILIAS/UI/src/templates/default/Input/tpl.standard.html',
123  ],
124  'trailing slash' => [
125  'skin' => 'default', 'style' => 'delos', 'file_exists' => true,
126  'tpl_filename' => 'tpl.test.html',
127  'component' => 'components/ILIAS/Test/',
128  'expected' => $il_root . '/components/ILIAS/Test/templates/default/tpl.test.html',
129  ],
130 
131  ];
132  }

◆ testGetTemplatePath()

ilTemplateTest::testGetTemplatePath ( string  $skin,
string  $style,
bool  $file_exists,
string  $tpl_filename,
string  $component,
string  $expected 
)

templatePathDataProvider

Definition at line 137 of file ilTemplateTest.php.

References $path.

144  : void {
145  $path = $this->il_template
146  ->withSkin($skin)
147  ->withStyle($style)
148  ->withFileExists($file_exists)
149  ->_getTemplatePath($tpl_filename, $component);
150 
151  $this->assertEquals($expected, $path);
152  }
$path
Definition: ltiservices.php:29

Field Documentation

◆ $il_root

string ilTemplateTest::$il_root
protected

Definition at line 26 of file ilTemplateTest.php.

◆ $il_template

ilTemplate ilTemplateTest::$il_template
protected

Definition at line 25 of file ilTemplateTest.php.


The documentation for this class was generated from the following file: