3 * An TestUnit template engine class for XML templates
5 * @author Roland Haeder <webmaster@ship-simu.org>
7 * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Core Developer Team
8 * @license GNU GPL 3.0 or any newer version
9 * @link http://www.ship-simu.org
10 * @todo This template engine does not make use of setTemplateType()
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.
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.
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/>.
25 class XmlCruncherTestUnitTemplateEngine extends BaseXmlTemplateEngine implements CompileableTemplate, Registerable {
27 * Protected constructor
31 protected function __construct () {
32 // Call parent constructor
33 parent::__construct(__CLASS__);
36 $this->subNodes = array(
38 'global-project-identifier',
53 * Creates an instance of the class TemplateEngine and prepares it for usage
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
63 public static final function createXmlCruncherTestUnitTemplateEngine () {
65 $templateInstance = new XmlCruncherTestUnitTemplateEngine();
67 // Init template instance
68 $templateInstance->initXmlTemplateEngine('cruncher', 'test_unit');
70 // Return the prepared instance
71 return $templateInstance;
75 * Load a specified cruncher_test_unit template into the engine
77 * @param $template The cruncher_test_unit template we shall load which is
78 * located in 'cruncher_test_unit' by default
81 public function loadCruncherTestUnitTemplate ($template) {
83 $this->setTemplateType($this->getConfigInstance()->getConfigEntry('cruncher_test_unit_template_type'));
85 // Load the special template
86 $this->loadTemplate($template);
92 * @param $resource XML parser resource (currently ignored)
93 * @param $characters Characters to handle
96 public function characterHandler ($resource, $characters) {
97 // Trim all spaces away
98 $characters = trim($characters);
100 // Is this string empty?
101 if (empty($characters)) {
102 // Then skip it silently
106 // Assign the found characters to variable and use the last entry from
108 parent::assignVariable($this->getStackerInstance()->getNamed('cruncher_test_unit'), $characters);
112 * Getter for cache file (FQFN)
114 * @return $fqfn Full-qualified file name of the menu cache
116 public function getCruncherTestUnitCacheFqfn () {
117 $this->partialStub('Please implement this method.');
121 * Starts the test-unit
125 protected function startCruncherTestUnit () {
126 // Push the node name on the stacker
127 $this->getStackerInstance()->pushNamed('cruncher_test_unit', 'cruncher-test-unit');
131 * Starts the meta-data
135 protected function startMetaData () {
136 // Push the node name on the stacker
137 $this->getStackerInstance()->pushNamed('cruncher_test_unit', 'meta-data');
141 * Starts the global-project-identifier
145 protected function startGlobalProjectIdentifier () {
146 // Push the node name on the stacker
147 $this->getStackerInstance()->pushNamed('cruncher_test_unit', 'global-project-identifier');
151 * Finishes the global-project-identifier
155 protected function finishGlobalProjectIdentifier () {
156 // Pop the last entry
157 $this->getStackerInstance()->popNamed('cruncher_test_unit');
161 * Starts the test-unit-created
165 protected function startTestUnitCreated () {
166 // Push the node name on the stacker
167 $this->getStackerInstance()->pushNamed('cruncher_test_unit', 'test-unit-created');
171 * Finishes the test-unit-created
175 protected function finishTestUnitCreated () {
176 // Pop the last entry
177 $this->getStackerInstance()->popNamed('cruncher_test_unit');
185 protected function startCipher () {
186 // Push the node name on the stacker
187 $this->getStackerInstance()->pushNamed('cruncher_test_unit', 'cipher');
191 * Starts the cipher-function
195 protected function startCipherFunction () {
196 // Push the node name on the stacker
197 $this->getStackerInstance()->pushNamed('cruncher_test_unit', 'cipher-function');
201 * Finishes the cipher-function
205 protected function finishCipherFunction () {
206 // Pop the last entry
207 $this->getStackerInstance()->popNamed('cruncher_test_unit');
211 * Starts the cipher-name
215 protected function startCipherName () {
216 // Push the node name on the stacker
217 $this->getStackerInstance()->pushNamed('cruncher_test_unit', 'cipher-name');
221 * Finishes the cipher-name
225 protected function finishCipherName () {
226 // Pop the last entry
227 $this->getStackerInstance()->popNamed('cruncher_test_unit');
231 * Finishes the cipher
235 protected function finishCipher () {
236 // Pop the last entry
237 $this->getStackerInstance()->popNamed('cruncher_test_unit');
241 * Finishes the meta-data
245 protected function finishMetaData () {
246 // Pop the last entry
247 $this->getStackerInstance()->popNamed('cruncher_test_unit');
251 * Starts the unprocessed-data
255 protected function startUnprocessedData () {
256 // Push the node name on the stacker
257 $this->getStackerInstance()->pushNamed('cruncher_test_unit', 'unprocessed-data');
261 * Starts the encrypted-message
265 protected function startEncryptedMessage () {
266 // Push the node name on the stacker
267 $this->getStackerInstance()->pushNamed('cruncher_test_unit', 'encrypted-message');
271 * Finishes the encrypted-message
275 protected function finishEncryptedMessage () {
276 // Pop the last entry
277 $this->getStackerInstance()->popNamed('cruncher_test_unit');
281 * Starts the cruncher-key-list
283 * @param $keyCount Count of keys in this test unit
285 * @todo Handle $keyCount
287 protected function startCruncherKeyList ($keyCount) {
288 // Push the node name on the stacker
289 $this->getStackerInstance()->pushNamed('cruncher_test_unit', 'cruncher-key-list');
293 * Starts the cruncher-key
297 protected function startCruncherKey () {
298 // Push the node name on the stacker
299 $this->getStackerInstance()->pushNamed('cruncher_test_unit', 'cruncher-key');
307 protected function startKeyId () {
308 // Push the node name on the stacker
309 $this->getStackerInstance()->pushNamed('cruncher_test_unit', 'key-id');
313 * Finishes the key-id
317 protected function finishKeyId () {
318 // Pop the last entry
319 $this->getStackerInstance()->popNamed('cruncher_test_unit');
323 * Starts the key-value
327 protected function startKeyValue () {
328 // Push the node name on the stacker
329 $this->getStackerInstance()->pushNamed('cruncher_test_unit', 'key-value');
333 * Finishes the key-value
337 protected function finishKeyValue () {
338 // Pop the last entry
339 $this->getStackerInstance()->popNamed('cruncher_test_unit');
343 * Finishes the cruncher-key
347 protected function finishCruncherKey () {
348 // Pop the last entry
349 $this->getStackerInstance()->popNamed('cruncher_test_unit');
353 * Finishes the cruncher-key-list
357 protected function finishCruncherKeyList () {
358 // Pop the last entry
359 $this->getStackerInstance()->popNamed('cruncher_test_unit');
363 * Finishes the unprocessed-data
367 protected function finishUnprocessedData () {
368 // Pop the last entry
369 $this->getStackerInstance()->popNamed('cruncher_test_unit');
373 * Finishes the test-unit
377 protected function finishaCruncherTestUnit () {
378 // Pop the last entry
379 $this->getStackerInstance()->popNamed('cruncher_test_unit');