3 namespace Org\Shipsimu\Hub\Cruncher\Template\Engine\Xml\TestUnit;
5 // Import application-specific stuff
7 // Import framework stuff
8 use Org\Mxchange\CoreFramework\Registry\Registerable;
9 use Org\Mxchange\CoreFramework\Template\Engine\Xml\BaseXmlTemplateEngine;
10 use Org\Mxchange\CoreFramework\Template\Xml\CompileableXmlTemplate;
13 * An TestUnit template engine class for XML templates
15 * @author Roland Haeder <webmaster@shipsimu.org>
17 * @copyright Copyright (c) 2011 - 2014 - 2018 Hub Developer Team
18 * @license GNU GPL 3.0 or any newer version
19 * @link http://www.shipsimu.org
20 * @todo This template engine does not make use of setTemplateType()
22 * This program is free software: you can redistribute it and/or modify
23 * it under the terms of the GNU General Public License as published by
24 * the Free Software Foundation, either version 3 of the License, or
25 * (at your option) any later version.
27 * This program is distributed in the hope that it will be useful,
28 * but WITHOUT ANY WARRANTY; without even the implied warranty of
29 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30 * GNU General Public License for more details.
32 * You should have received a copy of the GNU General Public License
33 * along with this program. If not, see <http://www.gnu.org/licenses/>.
35 class XmlCruncherTestUnitTemplateEngine extends BaseXmlTemplateEngine implements CompileableXmlTemplate, Registerable {
37 * Protected constructor
41 protected function __construct () {
42 // Call parent constructor
43 parent::__construct(__CLASS__);
46 $this->setSubNodes(array(
48 'global-project-identifier',
63 * Creates an instance of the class TemplateEngine and prepares it for usage
65 * @return $templateInstance An instance of TemplateEngine
66 * @throws BasePathIsEmptyException If the provided $templateBasePath is empty
67 * @throws InvalidBasePathStringException If $templateBasePath is no string
68 * @throws BasePathIsNoDirectoryException If $templateBasePath is no
69 * directory or not found
70 * @throws BasePathReadProtectedException If $templateBasePath is
73 public static final function createXmlCruncherTestUnitTemplateEngine () {
75 $templateInstance = new XmlCruncherTestUnitTemplateEngine();
77 // Init template instance
78 $templateInstance->initXmlTemplateEngine('cruncher', 'test_unit');
80 // Return the prepared instance
81 return $templateInstance;
87 * @param $resource XML parser resource (currently ignored)
88 * @param $characters Characters to handle
91 public function characterHandler ($resource, string $characters) {
92 // Trim all spaces away
93 $characters = trim($characters);
95 // Is this string empty?
96 if (empty($characters)) {
97 // Then skip it silently
101 // Assign the found characters to variable and use the last entry from
103 parent::assignVariable($this->getStackInstance()->getNamed('cruncher_test_unit'), $characters);
107 * Getter for cache file (FQFN)
109 * @return $fqfn Full-qualified file name of the menu cache
111 public function getCruncherTestUnitCacheFqfn () {
112 $this->partialStub('Please implement this method.');
116 * Starts the test-unit
120 protected function startTestUnit () {
121 // Push the node name on the stacker
122 $this->getStackInstance()->pushNamed('cruncher_test_unit', 'cruncher-test-unit');
126 * Starts the meta-data
130 protected function startMetaData () {
131 // Push the node name on the stacker
132 $this->getStackInstance()->pushNamed('cruncher_test_unit', 'meta-data');
136 * Starts the global-project-identifier
140 protected function startGlobalProjectIdentifier () {
141 // Push the node name on the stacker
142 $this->getStackInstance()->pushNamed('cruncher_test_unit', 'global-project-identifier');
146 * Finishes the global-project-identifier
150 protected function finishGlobalProjectIdentifier () {
151 // Pop the last entry
152 $this->getStackInstance()->popNamed('cruncher_test_unit');
156 * Starts the test-unit-created
160 protected function startTestUnitCreated () {
161 // Push the node name on the stacker
162 $this->getStackInstance()->pushNamed('cruncher_test_unit', 'test-unit-created');
166 * Finishes the test-unit-created
170 protected function finishTestUnitCreated () {
171 // Pop the last entry
172 $this->getStackInstance()->popNamed('cruncher_test_unit');
180 protected function startCipher () {
181 // Push the node name on the stacker
182 $this->getStackInstance()->pushNamed('cruncher_test_unit', 'cipher');
186 * Starts the cipher-function
190 protected function startCipherFunction () {
191 // Push the node name on the stacker
192 $this->getStackInstance()->pushNamed('cruncher_test_unit', 'cipher-function');
196 * Finishes the cipher-function
200 protected function finishCipherFunction () {
201 // Pop the last entry
202 $this->getStackInstance()->popNamed('cruncher_test_unit');
206 * Starts the cipher-name
210 protected function startCipherName () {
211 // Push the node name on the stacker
212 $this->getStackInstance()->pushNamed('cruncher_test_unit', 'cipher-name');
216 * Finishes the cipher-name
220 protected function finishCipherName () {
221 // Pop the last entry
222 $this->getStackInstance()->popNamed('cruncher_test_unit');
226 * Finishes the cipher
230 protected function finishCipher () {
231 // Pop the last entry
232 $this->getStackInstance()->popNamed('cruncher_test_unit');
236 * Finishes the meta-data
240 protected function finishMetaData () {
241 // Pop the last entry
242 $this->getStackInstance()->popNamed('cruncher_test_unit');
246 * Starts the unprocessed-data
250 protected function startUnprocessedData () {
251 // Push the node name on the stacker
252 $this->getStackInstance()->pushNamed('cruncher_test_unit', 'unprocessed-data');
256 * Starts the encrypted-message
260 protected function startEncryptedMessage () {
261 // Push the node name on the stacker
262 $this->getStackInstance()->pushNamed('cruncher_test_unit', 'encrypted-message');
266 * Finishes the encrypted-message
270 protected function finishEncryptedMessage () {
271 // Pop the last entry
272 $this->getStackInstance()->popNamed('cruncher_test_unit');
276 * Starts the cruncher-key-list
278 * @param $keyCount Count of keys in this test unit
280 * @todo Handle $keyCount
282 protected function startCruncherKeyList ($keyCount) {
283 // Push the node name on the stacker
284 $this->getStackInstance()->pushNamed('cruncher_test_unit', 'cruncher-key-list');
288 * Starts the cruncher-key
292 protected function startCruncherKey () {
293 // Push the node name on the stacker
294 $this->getStackInstance()->pushNamed('cruncher_test_unit', 'cruncher-key');
302 protected function startKeyId () {
303 // Push the node name on the stacker
304 $this->getStackInstance()->pushNamed('cruncher_test_unit', 'key-id');
308 * Finishes the key-id
312 protected function finishKeyId () {
313 // Pop the last entry
314 $this->getStackInstance()->popNamed('cruncher_test_unit');
318 * Starts the key-value
322 protected function startKeyValue () {
323 // Push the node name on the stacker
324 $this->getStackInstance()->pushNamed('cruncher_test_unit', 'key-value');
328 * Finishes the key-value
332 protected function finishKeyValue () {
333 // Pop the last entry
334 $this->getStackInstance()->popNamed('cruncher_test_unit');
338 * Finishes the cruncher-key
342 protected function finishCruncherKey () {
343 // Pop the last entry
344 $this->getStackInstance()->popNamed('cruncher_test_unit');
348 * Finishes the cruncher-key-list
352 protected function finishCruncherKeyList () {
353 // Pop the last entry
354 $this->getStackInstance()->popNamed('cruncher_test_unit');
358 * Finishes the unprocessed-data
362 protected function finishUnprocessedData () {
363 // Pop the last entry
364 $this->getStackInstance()->popNamed('cruncher_test_unit');
368 * Finishes the test-unit
372 protected function finishTestUnit () {
373 // Pop the last entry
374 $this->getStackInstance()->popNamed('cruncher_test_unit');