ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
ilSkinFactoryTest Class Reference
+ Inheritance diagram for ilSkinFactoryTest:
+ Collaboration diagram for ilSkinFactoryTest:

Public Member Functions

 testSkinFromXML ()
 
 testSkinStyleContainerFromId ()
 
 testCopySkin ()
 
 testCopySkinWithInjectedName ()
 
 testImportSkin ()
 

Protected Member Functions

 setUp ()
 
- Protected Member Functions inherited from ilSystemStyleBaseFS
 setUp ()
 
 getAllContentOfFolder (string $directory)
 
 tearDown ()
 

Protected Attributes

ilSkin $skin
 
ilSkinStyle $style1
 
ilSkinStyle $style2
 
ilSkinFactory $factory
 
- Protected Attributes inherited from ilSystemStyleBaseFS
ilSystemStyleConfigMock $system_style_config
 
ilSkinStyleContainer $container
 
ilSkinStyle $style
 
ilFileSystemHelper $file_system
 
ILIAS DI Container $save_dic = null
 
ilLanguage $lng
 
ilSystemStyleMessageStack $message_stack
 

Detailed Description

Definition at line 23 of file ilSkinFactoryTest.php.

Member Function Documentation

◆ setUp()

ilSkinFactoryTest::setUp ( )
protected

Definition at line 30 of file ilSkinFactoryTest.php.

References $DIC, $ini, and ILIAS\Repository\lng().

30  : void
31  {
32  parent::setUp();
33 
34  if (!defined('PATH_TO_SCSS')) {
35  if (file_exists('ilias.ini.php')) {
36  $ini = parse_ini_file('ilias.ini.php', true);
37  define('PATH_TO_SCSS', $ini['tools']['lessc'] ?? '');
38  } else {
39  define('PATH_TO_SCSS', '');
40  }
41  }
42 
43  $this->skin = new ilSkin('skin1', 'skin 1');
44 
45  $this->style1 = new ilSkinStyle('style1', 'Style 1');
46  $this->style1->setCssFile('style1');
47  $this->style1->setImageDirectory('style1image');
48  $this->style1->setSoundDirectory('style1sound');
49  $this->style1->setFontDirectory('style1font');
50 
51  $this->style2 = new ilSkinStyle('style2', 'Style 2');
52  $this->style2->setCssFile('style2');
53  $this->style2->setImageDirectory('style2image');
54  $this->style2->setSoundDirectory('style2sound');
55  $this->style2->setFontDirectory('style2font');
56 
57  $this->factory = new ilSkinFactory($this->lng, $this->system_style_config);
58 
59  global $DIC;
60 
61  $DIC = new ilSystemStyleDICMock();
62  $DIC['tpl'] = $this->getMockBuilder(ilGlobalTemplateInterface::class)->getMock();
63  }
Factory to create Skin classes holds an manages the basic data of a skin as provide by the template o...
global $DIC
Definition: feed.php:28
$ini
Definition: raiseError.php:4
ilSkin holds an manages the basic data of a skin as provide by the template of the skin...
+ Here is the call graph for this function:

◆ testCopySkin()

ilSkinFactoryTest::testCopySkin ( )

Definition at line 85 of file ilSkinFactoryTest.php.

References ilSystemStyleBaseFS\$container, ilSystemStyleBaseFS\$message_stack, ilSkin\getId(), ilSkin\getName(), and ilSkinStyleContainer\getSkin().

85  : void
86  {
87  $container = $this->factory->skinStyleContainerFromId($this->skin->getId(), $this->message_stack);
89 
90  $this->assertFalse(is_dir($this->system_style_config->getCustomizingSkinPath() . $skin->getId() . 'Copy'));
91 
92  $container_copy = $this->factory->copyFromSkinStyleContainer($container, $this->file_system, $this->message_stack);
93  $skin_copy = $container_copy->getSkin();
94 
95  $this->assertTrue(is_dir($this->system_style_config->getCustomizingSkinPath() . $skin->getId() . 'Copy'));
96  $this->assertTrue(is_dir($this->system_style_config->getCustomizingSkinPath() . $skin_copy->getId()));
97  $this->assertTrue(is_dir($this->system_style_config->getCustomizingSkinPath() . $skin_copy->getId() . '/style1/style1image'));
98  $this->assertTrue(is_dir($this->system_style_config->getCustomizingSkinPath() . $skin_copy->getId() . '/style1/style1sound'));
99  $this->assertTrue(is_dir($this->system_style_config->getCustomizingSkinPath() . $skin_copy->getId() . '/style1/style1font'));
100  $this->assertTrue(is_file($this->system_style_config->getCustomizingSkinPath() . $skin_copy->getId() . '/style1/style1.css'));
101  $this->assertTrue(is_file($this->system_style_config->getCustomizingSkinPath() . $skin_copy->getId() . '/style1/style1.scss'));
102  $this->assertTrue(is_file($this->system_style_config->getCustomizingSkinPath() . $skin_copy->getId() . '/style1/010-settings/variables1.scss'));
103  $this->assertTrue(is_file($this->system_style_config->getCustomizingSkinPath() . $skin_copy->getId() . '/style1/010-settings/variables2.scss'));
104 
105  $this->assertEquals($skin->getName() . ' Copy', $skin_copy->getName());
106  $this->assertEquals('0.1', $skin_copy->getVersion());
107  }
ilSystemStyleMessageStack $message_stack
ilSkinStyleContainer $container
+ Here is the call graph for this function:

◆ testCopySkinWithInjectedName()

ilSkinFactoryTest::testCopySkinWithInjectedName ( )

Definition at line 109 of file ilSkinFactoryTest.php.

References ilSystemStyleBaseFS\$container, ilSystemStyleBaseFS\$message_stack, ilSkin\getId(), ilSkin\getName(), and ilSkinStyleContainer\getSkin().

109  : void
110  {
111  $container = $this->factory->skinStyleContainerFromId($this->skin->getId(), $this->message_stack);
112  $skin = $container->getSkin();
113  $container_copy = $this->factory->copyFromSkinStyleContainer($container, $this->file_system, $this->message_stack, 'inject');
114  $skin_copy = $container_copy->getSkin();
115 
116  $this->assertTrue(is_dir($this->system_style_config->getCustomizingSkinPath() . $skin->getId() . 'inject'));
117  $this->assertEquals($skin->getName() . ' inject', $skin_copy->getName());
118  $this->assertEquals('0.1', $skin_copy->getVersion());
119  }
ilSystemStyleMessageStack $message_stack
ilSkinStyleContainer $container
+ Here is the call graph for this function:

◆ testImportSkin()

ilSkinFactoryTest::testImportSkin ( )

Definition at line 121 of file ilSkinFactoryTest.php.

References ilSystemStyleBaseFS\$container, $ini, ilSystemStyleBaseFS\$message_stack, ilSkinStyleContainer\createTempZip(), ilSkin\getId(), and ilSkinStyleContainer\getSkin().

121  : void
122  {
123  $this->markTestSkipped('This test is skipped, because it is not possible to create a zip file, which can be unzipped at the moment in Test-Context. The test is violating thr policy to access only directories which are known to the LegacyPathHelper.');
124 
125 
126  if (!defined('PATH_TO_ZIP')) {
127  if (file_exists('ilias.ini.php')) {
128  $ini = parse_ini_file('ilias.ini.php', true);
129  define('PATH_TO_ZIP', $ini['tools']['zip']);
130  } elseif (is_executable('/usr/bin/zip')) {
131  define('PATH_TO_ZIP', '/usr/bin/zip');
132  } else {
133  define('PATH_TO_ZIP', '');
134  }
135  }
136 
137  if (!defined('PATH_TO_UNZIP')) {
138  if (file_exists('ilias.ini.php')) {
139  $ini = parse_ini_file('ilias.ini.php', true);
140  define('PATH_TO_UNZIP', $ini['tools']['unzip']);
141  } elseif (is_executable('/usr/bin/unzip')) {
142  define('PATH_TO_UNZIP', '/usr/bin/unzip');
143  } else {
144  define('PATH_TO_UNZIP', '');
145  }
146  }
147 
148  //Only perform this test, if an unzip path has been found.
149  if (PATH_TO_UNZIP != '' && PATH_TO_ZIP != "") {
150  $container = $this->factory->skinStyleContainerFromId($this->skin->getId(), $this->message_stack);
151  $skin = $container->getSkin();
152 
153  $this->assertFalse(is_dir($this->system_style_config->getCustomizingSkinPath() . $skin->getId() . 'Copy'));
154 
155  $container_import = $this->factory->skinStyleContainerFromZip(
157  $this->skin->getId() . '.zip',
159  );
160  $skin_copy = $container_import->getSkin();
161 
162  $this->assertTrue(is_dir($this->system_style_config->getCustomizingSkinPath() . $skin->getId() . 'Copy'));
163  $this->assertTrue(is_dir($this->system_style_config->getCustomizingSkinPath() . $skin_copy->getId()));
164  $this->assertTrue(is_dir($this->system_style_config->getCustomizingSkinPath() . $skin_copy->getId() . '/style1image'));
165  $this->assertTrue(is_dir($this->system_style_config->getCustomizingSkinPath() . $skin_copy->getId() . '/style1sound'));
166  $this->assertTrue(is_dir($this->system_style_config->getCustomizingSkinPath() . $skin_copy->getId() . '/style1font'));
167  $this->assertTrue(is_file($this->system_style_config->getCustomizingSkinPath() . $skin_copy->getId() . '/style1css.css'));
168  $this->assertTrue(is_file($this->system_style_config->getCustomizingSkinPath() . $skin_copy->getId() . '/style1css.less'));
169  $this->assertTrue(is_file($this->system_style_config->getCustomizingSkinPath() . $skin_copy->getId() . '/style1css-variables.less'));
170  } else {
171  $this->markTestIncomplete('No unzip has been detected on the system');
172  }
173  }
ilSystemStyleMessageStack $message_stack
createTempZip()
Creates a temp zip file.
ilSkinStyleContainer $container
$ini
Definition: raiseError.php:4
+ Here is the call graph for this function:

◆ testSkinFromXML()

ilSkinFactoryTest::testSkinFromXML ( )

Definition at line 65 of file ilSkinFactoryTest.php.

References ilSkin\asXML(), and ILIAS\Repository\lng().

65  : void
66  {
67  $factory = new ilSkinFactory($this->lng);
68  $skin = $factory->skinFromXML($this->system_style_config->getCustomizingSkinPath() . 'skin1/template.xml');
69  $this->assertEquals(
70  $skin->asXML(),
71  file_get_contents($this->system_style_config->getCustomizingSkinPath() . 'skin1/template.xml')
72  );
73  }
Factory to create Skin classes holds an manages the basic data of a skin as provide by the template o...
asXML()
Stores the skin and all it's styles as xml.
ilSkinFactory $factory
+ Here is the call graph for this function:

◆ testSkinStyleContainerFromId()

ilSkinFactoryTest::testSkinStyleContainerFromId ( )

Definition at line 75 of file ilSkinFactoryTest.php.

References ilSystemStyleBaseFS\$container, ilSystemStyleBaseFS\$message_stack, and ilSkinStyleContainer\getSkin().

75  : void
76  {
77  $container = $this->factory->skinStyleContainerFromId($this->skin->getId(), $this->message_stack);
78  $this->assertEquals($container->getSkin()->getId(), $this->skin->getId());
79  $this->assertEquals($container->getSkin()->getName(), $this->skin->getName());
80 
81  $this->assertEquals($container->getSkin()->getStyle($this->style1->getId()), $this->style1);
82  $this->assertEquals($container->getSkin()->getStyle($this->style2->getId()), $this->style2);
83  }
ilSystemStyleMessageStack $message_stack
ilSkinStyleContainer $container
+ Here is the call graph for this function:

Field Documentation

◆ $factory

ilSkinFactory ilSkinFactoryTest::$factory
protected

Definition at line 28 of file ilSkinFactoryTest.php.

◆ $skin

ilSkin ilSkinFactoryTest::$skin
protected

Definition at line 25 of file ilSkinFactoryTest.php.

◆ $style1

ilSkinStyle ilSkinFactoryTest::$style1
protected

Definition at line 26 of file ilSkinFactoryTest.php.

◆ $style2

ilSkinStyle ilSkinFactoryTest::$style2
protected

Definition at line 27 of file ilSkinFactoryTest.php.


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