ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilSkinXMLTest Class Reference
+ Inheritance diagram for ilSkinXMLTest:
+ Collaboration diagram for ilSkinXMLTest:

Public Member Functions

 testSkinNameAndId ()
 
 testAddStyle ()
 
 testGetStyles ()
 
 testRemoveStyles ()
 
 testRemoveTestTwice ()
 
 testAsXML ()
 
 testWriteXML ()
 
 testReadXML ()
 

Protected Member Functions

 setUp ()
 
 tearDown ()
 

Protected Attributes

 $skin
 
 $style1 = null
 
 $style2 = null
 
 $system_style_config
 

Detailed Description

Author
Timon Amstutz timon.nosp@m..ams.nosp@m.tutz@.nosp@m.ilub.nosp@m..unib.nosp@m.e.ch
Version
$Id$*

Definition at line 14 of file ilSkinXMLTest.php.

Member Function Documentation

◆ setUp()

ilSkinXMLTest::setUp ( )
protected

Definition at line 38 of file ilSkinXMLTest.php.

39 {
40 $this->skin = new ilSkinXML("skin1", "skin 1");
41
42 $this->style1 = new ilSkinStyleXML("style1", "Style 1");
43 $this->style1->setCssFile("style1css");
44 $this->style1->setImageDirectory("style1image");
45 $this->style1->setSoundDirectory("style1sound");
46 $this->style1->setFontDirectory("style1font");
47
48 $this->style2 = new ilSkinStyleXML("style2", "Style 2");
49 $this->style2->setCssFile("style2css");
50 $this->style2->setImageDirectory("style2image");
51 $this->style2->setSoundDirectory("style2sound");
52 $this->style2->setFontDirectory("style2font");
53
54 $this->system_style_config = new ilSystemStyleConfigMock();
55
56 mkdir($this->system_style_config->test_skin_temp_path);
57 ilSystemStyleSkinContainer::xCopy($this->system_style_config->test_skin_original_path, $this->system_style_config->test_skin_temp_path);
58 }
ilSkinXml holds an manages the basic data of a skin as provide by the template of the skin.
ilSystemStyleConfig wraps all 'constants' to ensure the testability of all classes using those 'const...
static xCopy($src, $dest)
Recursive copy of a folder.

References ilSystemStyleSkinContainer\xCopy().

+ Here is the call graph for this function:

◆ tearDown()

ilSkinXMLTest::tearDown ( )
protected

Definition at line 60 of file ilSkinXMLTest.php.

61 {
62 ilSystemStyleSkinContainer::recursiveRemoveDir($this->system_style_config->test_skin_temp_path);
63 }
static recursiveRemoveDir($dir)
Recursive delete of a folder.

References ilSystemStyleSkinContainer\recursiveRemoveDir().

+ Here is the call graph for this function:

◆ testAddStyle()

ilSkinXMLTest::testAddStyle ( )

Definition at line 71 of file ilSkinXMLTest.php.

72 {
73 $this->assertEquals(count($this->skin), 0);
74 $this->assertEquals(count($this->skin->getStyles()), 0);
75 $this->skin->addStyle($this->style1);
76 $this->assertEquals(count($this->skin), 1);
77 $this->assertEquals(count($this->skin->getStyles()), 1);
78 $this->skin->addStyle($this->style1);
79 $this->assertEquals(count($this->skin), 2);
80 $this->assertEquals(count($this->skin->getStyles()), 2);
81 $this->skin->addStyle($this->style2);
82 $this->assertEquals(count($this->skin), 3);
83 $this->assertEquals(count($this->skin->getStyles()), 3);
84 }

◆ testAsXML()

ilSkinXMLTest::testAsXML ( )

Definition at line 123 of file ilSkinXMLTest.php.

124 {
125 $this->skin->addStyle($this->style1);
126 $this->skin->addStyle($this->style2);
127 $this->assertEquals($this->skin->asXML(), file_get_contents($this->system_style_config->getCustomizingSkinPath() . "skin1/template.xml"));
128 }

◆ testGetStyles()

ilSkinXMLTest::testGetStyles ( )

Definition at line 86 of file ilSkinXMLTest.php.

87 {
88 $this->skin->addStyle($this->style1);
89 $this->skin->addStyle($this->style2);
90
91 $this->assertNotEquals($this->skin->getStyle("style2"), $this->style1);
92 $this->assertEquals($this->skin->getStyle("style2"), $this->style2);
93 }

◆ testReadXML()

ilSkinXMLTest::testReadXML ( )

Definition at line 139 of file ilSkinXMLTest.php.

140 {
141 $skin = ilSkinXML::parseFromXML($this->system_style_config->getCustomizingSkinPath() . "skin1/template.xml");
142 $this->assertEquals($skin->asXML(), file_get_contents($this->system_style_config->getCustomizingSkinPath() . "skin1/template.xml"));
143 }

References $skin.

◆ testRemoveStyles()

ilSkinXMLTest::testRemoveStyles ( )

Definition at line 95 of file ilSkinXMLTest.php.

96 {
97 $this->skin->addStyle($this->style1);
98 $this->skin->addStyle($this->style2);
99 $this->assertEquals(count($this->skin), 2);
100 $this->skin->removeStyle("style1");
101 $this->assertEquals(count($this->skin), 1);
102 $this->skin->removeStyle("style2");
103 $this->assertEquals(count($this->skin), 0);
104 }

◆ testRemoveTestTwice()

ilSkinXMLTest::testRemoveTestTwice ( )

Definition at line 106 of file ilSkinXMLTest.php.

107 {
108 $this->skin->addStyle($this->style1);
109 $this->skin->addStyle($this->style2);
110 $this->assertEquals(count($this->skin), 2);
111 $this->skin->removeStyle("style1");
112 $this->assertEquals(count($this->skin), 1);
113 $this->skin->removeStyle("style2");
114 $this->assertEquals(count($this->skin), 0);
115 try {
116 $this->skin->removeStyle("style2");
117 $this->assertTrue(false);
118 } catch (ilSystemStyleException $e) {
119 $this->assertEquals($e->getCode(), ilSystemStyleException::INVALID_ID);
120 }
121 }
Class for advanced editing exception handling in ILIAS.

References ilSystemStyleException\INVALID_ID.

◆ testSkinNameAndId()

ilSkinXMLTest::testSkinNameAndId ( )

Definition at line 65 of file ilSkinXMLTest.php.

66 {
67 $this->assertEquals("skin1", $this->skin->getId());
68 $this->assertEquals("skin 1", $this->skin->getName());
69 }

◆ testWriteXML()

ilSkinXMLTest::testWriteXML ( )

Definition at line 130 of file ilSkinXMLTest.php.

131 {
132 $this->skin->addStyle($this->style1);
133 $this->skin->addStyle($this->style2);
134 $this->skin->writeToXMLFile($this->system_style_config->getCustomizingSkinPath() . "skin1/template-copy.xml");
135 $this->assertEquals(file_get_contents($this->system_style_config->getCustomizingSkinPath() . "skin1/template-copy.xml"), file_get_contents($this->system_style_config->getCustomizingSkinPath() . "skin1/template.xml"));
136 unlink($this->system_style_config->getCustomizingSkinPath() . "skin1/template-copy.xml");
137 }

Field Documentation

◆ $skin

ilSkinXMLTest::$skin
protected

Definition at line 21 of file ilSkinXMLTest.php.

Referenced by testReadXML().

◆ $style1

ilSkinXMLTest::$style1 = null
protected

Definition at line 26 of file ilSkinXMLTest.php.

◆ $style2

ilSkinXMLTest::$style2 = null
protected

Definition at line 31 of file ilSkinXMLTest.php.

◆ $system_style_config

ilSkinXMLTest::$system_style_config
protected

Definition at line 36 of file ilSkinXMLTest.php.


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