Updated 'core'.
[hub.git] / application / hub / main / template / producer / test_units / class_XmlCruncherTestUnitTemplateEngine.php
1 <?php
2 /**
3  * An TestUnit template engine class for XML templates
4  *
5  * @author              Roland Haeder <webmaster@shipsimu.org>
6  * @version             0.0.0
7  * @copyright   Copyright (c) 2011 - 2014 Cruncher Developer Team
8  * @license             GNU GPL 3.0 or any newer version
9  * @link                http://www.shipsimu.org
10  * @todo                This template engine does not make use of setTemplateType()
11  *
12  * This program is free software: you can redistribute it and/or modify
13  * it under the terms of the GNU General Public License as published by
14  * the Free Software Foundation, either version 3 of the License, or
15  * (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with this program. If not, see <http://www.gnu.org/licenses/>.
24  */
25 class XmlCruncherTestUnitTemplateEngine extends BaseXmlTemplateEngine implements CompileableTemplate, Registerable {
26         /**
27          * Protected constructor
28          *
29          * @return      void
30          */
31         protected function __construct () {
32                 // Call parent constructor
33                 parent::__construct(__CLASS__);
34
35                 // Init sub nodes
36                 $this->setSubNodes(array(
37                         'meta-data',
38                         'global-project-identifier',
39                         'test-unit-created',
40                         'cipher',
41                         'cipher-function',
42                         'cipher-name',
43                         'unprocessed-data',
44                         'encrypted-message',
45                         'cruncher-key-list',
46                         'cruncher-key',
47                         'key-id',
48                         'key-value'
49                 ));
50         }
51
52         /**
53          * Creates an instance of the class TemplateEngine and prepares it for usage
54          *
55          * @return      $templateInstance               An instance of TemplateEngine
56          * @throws      BasePathIsEmptyException                If the provided $templateBasePath is empty
57          * @throws      InvalidBasePathStringException  If $templateBasePath is no string
58          * @throws      BasePathIsNoDirectoryException  If $templateBasePath is no
59          *                                                                                      directory or not found
60          * @throws      BasePathReadProtectedException  If $templateBasePath is
61          *                                                                                      read-protected
62          */
63         public static final function createXmlCruncherTestUnitTemplateEngine () {
64                 // Get a new instance
65                 $templateInstance = new XmlCruncherTestUnitTemplateEngine();
66
67                 // Init template instance
68                 $templateInstance->initXmlTemplateEngine('cruncher', 'test_unit');
69
70                 // Return the prepared instance
71                 return $templateInstance;
72         }
73
74         /**
75          * Currently not used
76          *
77          * @param       $resource               XML parser resource (currently ignored)
78          * @param       $characters             Characters to handle
79          * @return      void
80          */
81         public function characterHandler ($resource, $characters) {
82                 // Trim all spaces away
83                 $characters = trim($characters);
84
85                 // Is this string empty?
86                 if (empty($characters)) {
87                         // Then skip it silently
88                         return;
89                 } // END - if
90
91                 // Assign the found characters to variable and use the last entry from
92                 // stack as the name
93                 parent::assignVariable($this->getStackInstance()->getNamed('cruncher_test_unit'), $characters);
94         }
95
96         /**
97          * Getter for cache file (FQFN)
98          *
99          * @return      $fqfn   Full-qualified file name of the menu cache
100          */
101         public function getCruncherTestUnitCacheFqfn () {
102                 $this->partialStub('Please implement this method.');
103         }
104
105         /**
106          * Starts the test-unit
107          *
108          * @return      void
109          */
110         protected function startTestUnit () {
111                 // Push the node name on the stacker
112                 $this->getStackInstance()->pushNamed('cruncher_test_unit', 'cruncher-test-unit');
113         }
114
115         /**
116          * Starts the meta-data
117          *
118          * @return      void
119          */
120         protected function startMetaData () {
121                 // Push the node name on the stacker
122                 $this->getStackInstance()->pushNamed('cruncher_test_unit', 'meta-data');
123         }
124
125         /**
126          * Starts the global-project-identifier
127          *
128          * @return      void
129          */
130         protected function startGlobalProjectIdentifier () {
131                 // Push the node name on the stacker
132                 $this->getStackInstance()->pushNamed('cruncher_test_unit', 'global-project-identifier');
133         }
134
135         /**
136          * Finishes the global-project-identifier
137          *
138          * @return      void
139          */
140         protected function finishGlobalProjectIdentifier () {
141                 // Pop the last entry
142                 $this->getStackInstance()->popNamed('cruncher_test_unit');
143         }
144
145         /**
146          * Starts the test-unit-created
147          *
148          * @return      void
149          */
150         protected function startTestUnitCreated () {
151                 // Push the node name on the stacker
152                 $this->getStackInstance()->pushNamed('cruncher_test_unit', 'test-unit-created');
153         }
154
155         /**
156          * Finishes the test-unit-created
157          *
158          * @return      void
159          */
160         protected function finishTestUnitCreated () {
161                 // Pop the last entry
162                 $this->getStackInstance()->popNamed('cruncher_test_unit');
163         }
164
165         /**
166          * Starts the cipher
167          *
168          * @return      void
169          */
170         protected function startCipher () {
171                 // Push the node name on the stacker
172                 $this->getStackInstance()->pushNamed('cruncher_test_unit', 'cipher');
173         }
174
175         /**
176          * Starts the cipher-function
177          *
178          * @return      void
179          */
180         protected function startCipherFunction () {
181                 // Push the node name on the stacker
182                 $this->getStackInstance()->pushNamed('cruncher_test_unit', 'cipher-function');
183         }
184
185         /**
186          * Finishes the cipher-function
187          *
188          * @return      void
189          */
190         protected function finishCipherFunction () {
191                 // Pop the last entry
192                 $this->getStackInstance()->popNamed('cruncher_test_unit');
193         }
194
195         /**
196          * Starts the cipher-name
197          *
198          * @return      void
199          */
200         protected function startCipherName () {
201                 // Push the node name on the stacker
202                 $this->getStackInstance()->pushNamed('cruncher_test_unit', 'cipher-name');
203         }
204
205         /**
206          * Finishes the cipher-name
207          *
208          * @return      void
209          */
210         protected function finishCipherName () {
211                 // Pop the last entry
212                 $this->getStackInstance()->popNamed('cruncher_test_unit');
213         }
214
215         /**
216          * Finishes the cipher
217          *
218          * @return      void
219          */
220         protected function finishCipher () {
221                 // Pop the last entry
222                 $this->getStackInstance()->popNamed('cruncher_test_unit');
223         }
224
225         /**
226          * Finishes the meta-data
227          *
228          * @return      void
229          */
230         protected function finishMetaData () {
231                 // Pop the last entry
232                 $this->getStackInstance()->popNamed('cruncher_test_unit');
233         }
234
235         /**
236          * Starts the unprocessed-data
237          *
238          * @return      void
239          */
240         protected function startUnprocessedData () {
241                 // Push the node name on the stacker
242                 $this->getStackInstance()->pushNamed('cruncher_test_unit', 'unprocessed-data');
243         }
244
245         /**
246          * Starts the encrypted-message
247          *
248          * @return      void
249          */
250         protected function startEncryptedMessage () {
251                 // Push the node name on the stacker
252                 $this->getStackInstance()->pushNamed('cruncher_test_unit', 'encrypted-message');
253         }
254
255         /**
256          * Finishes the encrypted-message
257          *
258          * @return      void
259          */
260         protected function finishEncryptedMessage () {
261                 // Pop the last entry
262                 $this->getStackInstance()->popNamed('cruncher_test_unit');
263         }
264
265         /**
266          * Starts the cruncher-key-list
267          *
268          * @param       $keyCount       Count of keys in this test unit
269          * @return      void
270          * @todo        Handle $keyCount
271          */
272         protected function startCruncherKeyList ($keyCount) {
273                 // Push the node name on the stacker
274                 $this->getStackInstance()->pushNamed('cruncher_test_unit', 'cruncher-key-list');
275         }
276
277         /**
278          * Starts the cruncher-key
279          *
280          * @return      void
281          */
282         protected function startCruncherKey () {
283                 // Push the node name on the stacker
284                 $this->getStackInstance()->pushNamed('cruncher_test_unit', 'cruncher-key');
285         }
286
287         /**
288          * Starts the key-id
289          *
290          * @return      void
291          */
292         protected function startKeyId () {
293                 // Push the node name on the stacker
294                 $this->getStackInstance()->pushNamed('cruncher_test_unit', 'key-id');
295         }
296
297         /**
298          * Finishes the key-id
299          *
300          * @return      void
301          */
302         protected function finishKeyId () {
303                 // Pop the last entry
304                 $this->getStackInstance()->popNamed('cruncher_test_unit');
305         }
306
307         /**
308          * Starts the key-value
309          *
310          * @return      void
311          */
312         protected function startKeyValue () {
313                 // Push the node name on the stacker
314                 $this->getStackInstance()->pushNamed('cruncher_test_unit', 'key-value');
315         }
316
317         /**
318          * Finishes the key-value
319          *
320          * @return      void
321          */
322         protected function finishKeyValue () {
323                 // Pop the last entry
324                 $this->getStackInstance()->popNamed('cruncher_test_unit');
325         }
326
327         /**
328          * Finishes the cruncher-key
329          *
330          * @return      void
331          */
332         protected function finishCruncherKey () {
333                 // Pop the last entry
334                 $this->getStackInstance()->popNamed('cruncher_test_unit');
335         }
336
337         /**
338          * Finishes the cruncher-key-list
339          *
340          * @return      void
341          */
342         protected function finishCruncherKeyList () {
343                 // Pop the last entry
344                 $this->getStackInstance()->popNamed('cruncher_test_unit');
345         }
346
347         /**
348          * Finishes the unprocessed-data
349          *
350          * @return      void
351          */
352         protected function finishUnprocessedData () {
353                 // Pop the last entry
354                 $this->getStackInstance()->popNamed('cruncher_test_unit');
355         }
356
357         /**
358          * Finishes the test-unit
359          *
360          * @return      void
361          */
362         protected function finishTestUnit () {
363                 // Pop the last entry
364                 $this->getStackInstance()->popNamed('cruncher_test_unit');
365         }
366 }
367
368 // [EOF]
369 ?>