3 * An TestUnit template engine class for XML templates
5 * @author Roland Haeder <webmaster@shipsimu.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.shipsimu.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;
77 * @param $resource XML parser resource (currently ignored)
78 * @param $characters Characters to handle
81 public function characterHandler ($resource, $characters) {
82 // Trim all spaces away
83 $characters = trim($characters);
85 // Is this string empty?
86 if (empty($characters)) {
87 // Then skip it silently
91 // Assign the found characters to variable and use the last entry from
93 parent::assignVariable($this->getStackerInstance()->getNamed('cruncher_test_unit'), $characters);
97 * Getter for cache file (FQFN)
99 * @return $fqfn Full-qualified file name of the menu cache
101 public function getCruncherTestUnitCacheFqfn () {
102 $this->partialStub('Please implement this method.');
106 * Starts the test-unit
110 protected function startTestUnit () {
111 // Push the node name on the stacker
112 $this->getStackerInstance()->pushNamed('cruncher_test_unit', 'cruncher-test-unit');
116 * Starts the meta-data
120 protected function startMetaData () {
121 // Push the node name on the stacker
122 $this->getStackerInstance()->pushNamed('cruncher_test_unit', 'meta-data');
126 * Starts the global-project-identifier
130 protected function startGlobalProjectIdentifier () {
131 // Push the node name on the stacker
132 $this->getStackerInstance()->pushNamed('cruncher_test_unit', 'global-project-identifier');
136 * Finishes the global-project-identifier
140 protected function finishGlobalProjectIdentifier () {
141 // Pop the last entry
142 $this->getStackerInstance()->popNamed('cruncher_test_unit');
146 * Starts the test-unit-created
150 protected function startTestUnitCreated () {
151 // Push the node name on the stacker
152 $this->getStackerInstance()->pushNamed('cruncher_test_unit', 'test-unit-created');
156 * Finishes the test-unit-created
160 protected function finishTestUnitCreated () {
161 // Pop the last entry
162 $this->getStackerInstance()->popNamed('cruncher_test_unit');
170 protected function startCipher () {
171 // Push the node name on the stacker
172 $this->getStackerInstance()->pushNamed('cruncher_test_unit', 'cipher');
176 * Starts the cipher-function
180 protected function startCipherFunction () {
181 // Push the node name on the stacker
182 $this->getStackerInstance()->pushNamed('cruncher_test_unit', 'cipher-function');
186 * Finishes the cipher-function
190 protected function finishCipherFunction () {
191 // Pop the last entry
192 $this->getStackerInstance()->popNamed('cruncher_test_unit');
196 * Starts the cipher-name
200 protected function startCipherName () {
201 // Push the node name on the stacker
202 $this->getStackerInstance()->pushNamed('cruncher_test_unit', 'cipher-name');
206 * Finishes the cipher-name
210 protected function finishCipherName () {
211 // Pop the last entry
212 $this->getStackerInstance()->popNamed('cruncher_test_unit');
216 * Finishes the cipher
220 protected function finishCipher () {
221 // Pop the last entry
222 $this->getStackerInstance()->popNamed('cruncher_test_unit');
226 * Finishes the meta-data
230 protected function finishMetaData () {
231 // Pop the last entry
232 $this->getStackerInstance()->popNamed('cruncher_test_unit');
236 * Starts the unprocessed-data
240 protected function startUnprocessedData () {
241 // Push the node name on the stacker
242 $this->getStackerInstance()->pushNamed('cruncher_test_unit', 'unprocessed-data');
246 * Starts the encrypted-message
250 protected function startEncryptedMessage () {
251 // Push the node name on the stacker
252 $this->getStackerInstance()->pushNamed('cruncher_test_unit', 'encrypted-message');
256 * Finishes the encrypted-message
260 protected function finishEncryptedMessage () {
261 // Pop the last entry
262 $this->getStackerInstance()->popNamed('cruncher_test_unit');
266 * Starts the cruncher-key-list
268 * @param $keyCount Count of keys in this test unit
270 * @todo Handle $keyCount
272 protected function startCruncherKeyList ($keyCount) {
273 // Push the node name on the stacker
274 $this->getStackerInstance()->pushNamed('cruncher_test_unit', 'cruncher-key-list');
278 * Starts the cruncher-key
282 protected function startCruncherKey () {
283 // Push the node name on the stacker
284 $this->getStackerInstance()->pushNamed('cruncher_test_unit', 'cruncher-key');
292 protected function startKeyId () {
293 // Push the node name on the stacker
294 $this->getStackerInstance()->pushNamed('cruncher_test_unit', 'key-id');
298 * Finishes the key-id
302 protected function finishKeyId () {
303 // Pop the last entry
304 $this->getStackerInstance()->popNamed('cruncher_test_unit');
308 * Starts the key-value
312 protected function startKeyValue () {
313 // Push the node name on the stacker
314 $this->getStackerInstance()->pushNamed('cruncher_test_unit', 'key-value');
318 * Finishes the key-value
322 protected function finishKeyValue () {
323 // Pop the last entry
324 $this->getStackerInstance()->popNamed('cruncher_test_unit');
328 * Finishes the cruncher-key
332 protected function finishCruncherKey () {
333 // Pop the last entry
334 $this->getStackerInstance()->popNamed('cruncher_test_unit');
338 * Finishes the cruncher-key-list
342 protected function finishCruncherKeyList () {
343 // Pop the last entry
344 $this->getStackerInstance()->popNamed('cruncher_test_unit');
348 * Finishes the unprocessed-data
352 protected function finishUnprocessedData () {
353 // Pop the last entry
354 $this->getStackerInstance()->popNamed('cruncher_test_unit');
358 * Finishes the test-unit
362 protected function finishTestUnit () {
363 // Pop the last entry
364 $this->getStackerInstance()->popNamed('cruncher_test_unit');