StoreTest.php 17.6 KB
Newer Older
1
2
3
4
5
6
7
8
<?php
/**
 * Created by PhpStorm.
 * User: crose
 * Date: 1/2/16
 * Time: 9:16 PM
 */

Marc Egger's avatar
Marc Egger committed
9
namespace IMATHUZH\Qfq\Tests\Unit\Core\Store;
10

Marc Egger's avatar
Marc Egger committed
11
12
use IMATHUZH\Qfq\Core\Database\Database;
use IMATHUZH\Qfq\Core\Store\Store;
13
use PHPUnit\Framework\TestCase;
14

Carsten  Rose's avatar
Carsten Rose committed
15

16
17
18
19
20
/**
 * Class StoreTest
 * @package qfq
 */
class StoreTest extends TestCase {
21

22
23
24
    /**
     * @var Store
     */
25
    private $store = null;
26

27
    private $setUpDone = false;
28

Carsten  Rose's avatar
Carsten Rose committed
29
    /**
Marc Egger's avatar
Marc Egger committed
30
31
32
     * @throws \CodeException
     * @throws \UserFormException
     * @throws \UserReportException
Carsten  Rose's avatar
Carsten Rose committed
33
     */
34
    public function setUp() {
35
        // Client Variables has to setup before the first instantiation of 'Store'
Carsten  Rose's avatar
Carsten Rose committed
36
37
        $_GET[] = array();
        $_POST[] = array();
38
39
40
41
        $_GET[CLIENT_RECORD_ID] = '1234';
        $_GET['key01'] = '1234';
        $_POST['key02'] = '2345';
        $_POST['key03'] = '3456';
Carsten  Rose's avatar
Carsten Rose committed
42
        $_POST[CLIENT_FORM] = 'testformnameDoNotChange';
43
44
45
        $_GET['key04'] = '4567';
        $_POST['key04'] = '5678';

Carsten  Rose's avatar
Carsten Rose committed
46
        $this->store = Store::getInstance("\n; some comment\n" . TYPO3_FORM . "=testformnameDoNotChange\n", true, 'init');
47
48
49

    }

Carsten  Rose's avatar
Carsten Rose committed
50
    /**
Marc Egger's avatar
Marc Egger committed
51
52
53
     * @throws \CodeException
     * @throws \UserFormException
     * @throws \UserReportException
Carsten  Rose's avatar
Carsten Rose committed
54
     */
55
    public function testGetInstance() {
56
57
        $a = Store::getInstance('', true);
        $b = Store::getInstance('', true);
58
59
60
61
62
63

        $this->assertFalse($a === null, "There should be a class");

        $this->assertEquals($a, $b, "Both classes should be the same");
    }

Carsten  Rose's avatar
Carsten Rose committed
64
    /**
Marc Egger's avatar
Marc Egger committed
65
66
     * @throws \CodeException
     * @throws \UserFormException
Carsten  Rose's avatar
Carsten Rose committed
67
     */
68
    public function testGetVarStoreTypo3() {
69
        // T3 Bodytext
70
71
        $this->store->setVar(TYPO3_FORM, "testformnameDoNotChange", STORE_TYPO3);
        $this->assertEquals('testformnameDoNotChange', $this->store->getVar(TYPO3_FORM, STORE_TYPO3), "System: " . TYPO3_FORM);
72
73
74

    }

Carsten  Rose's avatar
Carsten Rose committed
75
    /**
Marc Egger's avatar
Marc Egger committed
76
77
     * @throws \CodeException
     * @throws \UserFormException
Carsten  Rose's avatar
Carsten Rose committed
78
     */
79
    public function testGetVarStoreSystem() {
80
        // DBUSER in qfq.ini
81
82
        $val = $this->store->getVar(SYSTEM_DB_INDEX_DATA, STORE_SYSTEM);
        $this->assertTrue($val !== false && $val !== '', "SYSTEM_DB_INDEX_DATA found in qfq.ini");
83

84
85
    }

Carsten  Rose's avatar
Carsten Rose committed
86
    /**
Marc Egger's avatar
Marc Egger committed
87
88
     * @throws \CodeException
     * @throws \UserFormException
Carsten  Rose's avatar
Carsten Rose committed
89
     */
90
    public function testSetVarStoreSystem() {
91

92
93
94
        // set new Sessionname
        $this->store->setVar(SYSTEM_SQL_LOG_MODE, "all", STORE_SYSTEM);

95
        // Sessionname: default value
96
        $this->assertEquals('all', $this->store->getVar(SYSTEM_SQL_LOG_MODE, STORE_SYSTEM), "System: SQL_LOG");
97
98

        // set new Sessionname
99
        $this->store->setVar(SYSTEM_SQL_LOG_MODE, "modify", STORE_SYSTEM);
100

101
        $this->assertEquals('modify', $this->store->getVar(SYSTEM_SQL_LOG_MODE, STORE_SYSTEM), "System: SQL_LOG");
102

103
104
    }

Carsten  Rose's avatar
Carsten Rose committed
105
    /**
Marc Egger's avatar
Marc Egger committed
106
107
     * @throws \CodeException
     * @throws \UserFormException
Carsten  Rose's avatar
Carsten Rose committed
108
     */
109
    public function testGetVarStoreClient() {
110

Carsten  Rose's avatar
Carsten Rose committed
111
        # Violates SANITIZE class: sanitized string is always an empty string.
112
        # Access are cached:
113

Carsten  Rose's avatar
Carsten Rose committed
114
115
        # Test: Retrieve a variable, default sanitize class
        $this->assertEquals('1234', $this->store->getVar(CLIENT_RECORD_ID, STORE_CLIENT), "FormName: default sanitize class");
116

Carsten  Rose's avatar
Carsten Rose committed
117
118
        # violates default SANITIZE digit: sanitized string is always an empty string.
        $this->assertEquals('', $this->store->getVar(CLIENT_SIP, STORE_CLIENT), "sanitize class digit fails");
119
120
121

        // Test GET
        $this->assertEquals('1234', $this->store->getVar('key01', STORE_CLIENT), "Param: GET");
122

123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
        // Test POST
        $this->assertEquals('2345', $this->store->getVar('key02', STORE_CLIENT), "Param: POST");

        // Test not found
        $this->assertFalse($this->store->getVar('keyUnknown', STORE_CLIENT), "Param: unknown");

        // Test Cache value
        $_POST['key03'] = 'lost';
        $this->store->getVar('key03', STORE_CLIENT);
        $this->assertEquals('3456', $this->store->getVar('key03', STORE_CLIENT), "Param: read from cache");

        // Test Cache not found
        $this->store->getVar('keyUnknwon2');
        $this->assertFalse($this->store->getVar('keyUnknown2', STORE_CLIENT), "Param: unknown from cache");

Carsten  Rose's avatar
Carsten Rose committed
138
        // Test overwrite default sanitize class
139
        $this->assertEquals('!!digit!!', $this->store->getVar(CLIENT_FORM, STORE_CLIENT, SANITIZE_ALLOW_DIGIT), "Param: overwrite default sanitize class");
140
141
142

        // Test: POST higher priority than GET
        $this->assertEquals('5678', $this->store->getVar('key04', STORE_CLIENT), "Param: POST higher priority than GET");
Carsten  Rose's avatar
Carsten Rose committed
143
144
    }

Carsten  Rose's avatar
Carsten Rose committed
145
    /**
Marc Egger's avatar
Marc Egger committed
146
147
148
149
     * @throws \CodeException
     * @throws \DbException
     * @throws \UserFormException
     * @throws \UserReportException
Carsten  Rose's avatar
Carsten Rose committed
150
     */
Carsten  Rose's avatar
Carsten Rose committed
151
    public function testStorePriority() {
152
        //default prio  FSRVD
153

154
        $this->store->unsetStore(STORE_RECORD);
155
156
157
158

        $db = new Database();
        $tableDefinition = $db->getTableDefinition('Person');
        $this->store->fillStoreTableDefaultColumnType($tableDefinition);
159

160
//        $this->assertEquals('male', $this->store->getVar('gender','','alnumx'), "Get default definition from table person.gender");
161
162
163
164
165
166
167
168

        $this->store->setVar('gender', 'female', STORE_RECORD);
        $this->assertEquals('female', $this->store->getVar('gender'), "Retrieve 'gender' from STORE_RECORD");

        $this->store->setVar('gender', 'male2', STORE_SIP);
        $this->assertEquals('male2', $this->store->getVar('gender'), "Retrieve 'gender' from STORE_SIP");

        $this->store->setVar('gender', 'female2', STORE_FORM);
Carsten  Rose's avatar
Carsten Rose committed
169
        $this->assertEquals('female2', $this->store->getVar('gender', '', SANITIZE_ALLOW_ALNUMX), "Retrieve 'gender' from STORE_SIP");
170

171
    }
172

Carsten  Rose's avatar
Carsten Rose committed
173
    /**
Marc Egger's avatar
Marc Egger committed
174
175
     * @throws \CodeException
     * @throws \UserFormException
Carsten  Rose's avatar
Carsten Rose committed
176
     */
Carsten  Rose's avatar
Carsten Rose committed
177
    public function testStoreDifferentSanitizeClass() {
178
179
        //default prio  FSRD

180
181
        $this->store->setVar('fruit', 'apple', STORE_RECORD);
        $this->assertEquals('apple', $this->store->getVar('fruit'), "Retrieve 'fruit' from STORE_RECORD");
182

183
        $this->store->setVar('color', 'green', STORE_FORM);
184
        $this->assertEquals('!!digit!!', $this->store->getVar('color'), "Retrieve 'color' from STORE_FORM");
Carsten  Rose's avatar
Carsten Rose committed
185
        $this->assertEquals('green', $this->store->getVar('color', '', SANITIZE_ALLOW_ALNUMX), "Retrieve 'color' from STORE_FORM");
186
187
    }

Carsten  Rose's avatar
Carsten Rose committed
188
    /**
Marc Egger's avatar
Marc Egger committed
189
190
     * @throws \CodeException
     * @throws \UserFormException
Carsten  Rose's avatar
Carsten Rose committed
191
     */
192
    public function testGetVarStore0() {
193
194
        //default prio  FSRD

195
        $this->assertEquals(0, $this->store->getVar('fakename', STORE_ZERO), "Retrieve anything from STORE_ZERO");
196
197
    }

Carsten  Rose's avatar
Carsten Rose committed
198
    /**
Marc Egger's avatar
Marc Egger committed
199
200
     * @throws \CodeException
     * @throws \UserFormException
Carsten  Rose's avatar
Carsten Rose committed
201
     */
202
203
204
    public function testUnsetStore() {
        $this->store->unsetStore(STORE_RECORD);

205
        $this->store->setStore(array(), STORE_RECORD);
206
207
208
        $this->assertEquals(false, $this->store->getVar('apple', STORE_RECORD), "Retrieve a value from store.");
    }

Carsten  Rose's avatar
Carsten Rose committed
209
    /**
Marc Egger's avatar
Marc Egger committed
210
211
     * @throws \CodeException
     * @throws \UserFormException
Carsten  Rose's avatar
Carsten Rose committed
212
     */
213
214
215
    public function testSetVarArray() {
        $this->store->unsetStore(STORE_RECORD);
        $arr = ['a' => '1', 'apple' => 'green'];
216
        $this->store->setStore($arr, STORE_RECORD);
217
218
219
220
        $this->assertEquals('1', $this->store->getVar('a', STORE_RECORD), "Retrieve a value from store 'fake'");
        $this->assertEquals('green', $this->store->getVar('apple', STORE_RECORD), "Retrieve a value from store.");
    }

Carsten  Rose's avatar
Carsten Rose committed
221
    /**
Marc Egger's avatar
Marc Egger committed
222
223
     * @throws \CodeException
     * @throws \UserFormException
Carsten  Rose's avatar
Carsten Rose committed
224
     */
225
226
227
    public function testSetVarArrayEmpty() {
        $this->store->unsetStore(STORE_RECORD);
        $arr = array();
228
        $this->store->setStore($arr, STORE_RECORD);
229
230
        $this->assertEquals(false, $this->store->getVar('apple', STORE_RECORD), "Retrieve a value from store.");
    }
231

Carsten  Rose's avatar
Carsten Rose committed
232
    /**
Marc Egger's avatar
Marc Egger committed
233
234
235
     * @throws \CodeException
     * @throws \UserFormException
     * @throws \UserReportException
Carsten  Rose's avatar
Carsten Rose committed
236
     */
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
    public function testSetVar() {

        $this->store = Store::getInstance('', true);

        foreach ([STORE_SIP, STORE_CLIENT, STORE_EXTRA] AS $store) {
            // initial set
            $this->store->setVar('unitTest', '123', $store);
            $this->assertEquals('123', $this->store->getVar('unitTest', $store), "Retrieve var.");

            // redefine, using default 'overwrite=true'
            $this->store->setVar('unitTest', '1234', $store);
            $this->assertEquals('1234', $this->store->getVar('unitTest', $store), "Retrieve var.");

            // redefine, using explicit 'overwrite=true'
            $this->store->setVar('unitTest', '12345', $store, true);
            $this->assertEquals('12345', $this->store->getVar('unitTest', $store), "Retrieve var.");

            // redefine, using explicit 'overwrite=false' but with the same value (that is ok)
            $this->store->setVar('unitTest', '12345', $store, false);
            $this->assertEquals('12345', $this->store->getVar('unitTest', $store), "Retrieve var.");
        }
    }

Carsten  Rose's avatar
Carsten Rose committed
260
//    /**
Marc Egger's avatar
Marc Egger committed
261
//     * @expectedException \UserFormException
Carsten  Rose's avatar
Carsten Rose committed
262
//     *
Marc Egger's avatar
Marc Egger committed
263
264
265
//     * @throws \CodeException
//     * @throws \UserFormException
//     * @throws \UserReportException
Carsten  Rose's avatar
Carsten Rose committed
266
267
268
269
270
271
272
273
274
275
276
277
//     */
//    public function testConfigMandatoryValues() {
//
//        $fileName = $this->createFile('');
//        // the following produces Undefined index exception since you give an empty config.ini which does not contain the index.
//        // What do you want to test here?
//        $this->store = Store::getInstance('', true, $fileName);
//        unlink($fileName);
//
//        $this->assertEquals(false, $this->store->getStore(STORE_SYSTEM), "Retrieve system store.");
//    }
//
278
    /**
Marc Egger's avatar
Marc Egger committed
279
280
281
     * @throws \CodeException
     * @throws \UserFormException
     * @throws \UserReportException
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
     */
    public function testAppendToStore() {
        $this->store->unsetStore(STORE_RECORD);

        $this->store->appendToStore(array(), STORE_RECORD);
        $this->assertEquals(array(), $this->store->getStore(STORE_RECORD));

        $param = ['a' => 'hello', 'b' => 'world'];
        $this->store->appendToStore($param, STORE_RECORD);
        $this->assertEquals($param, $this->store->getStore(STORE_RECORD));

        $this->store->appendToStore(null, STORE_RECORD);
        $this->assertEquals($param, $this->store->getStore(STORE_RECORD));

        $this->store->appendToStore(array(), STORE_RECORD);
        $this->assertEquals($param, $this->store->getStore(STORE_RECORD));

        $param2 = ['c' => 'nice', 'd' => 'job'];
        $this->store->appendToStore($param2, STORE_RECORD);
        $this->assertEquals(array_merge($param, $param2), $this->store->getStore(STORE_RECORD));

        $param3 = ['a' => 'well', 'b' => 'done'];
        $this->store->appendToStore($param3, STORE_RECORD);
        $this->assertEquals(array_merge($param3, $param2), $this->store->getStore(STORE_RECORD));

        $this->store->setStore($param, STORE_RECORD, true);
        $this->store->appendToStore([$param2, $param3, $param3], STORE_RECORD);
        $this->assertEquals(array_merge($param, $param2), $this->store->getStore(STORE_RECORD));
    }

312
313
    /**
     * @param $body
Carsten  Rose's avatar
Carsten Rose committed
314
     * @return bool|string
315
316
317
318
319
320
321
322
323
324
325
     */
    private function createFile($body) {

        $tmpFileName = tempnam('/tmp', 'config.qfq.ini.');
        $handle = fopen($tmpFileName, "w");
        fwrite($handle, $body);
        fclose($handle);

        return $tmpFileName;
    }

Carsten  Rose's avatar
Carsten Rose committed
326
    /**
Marc Egger's avatar
Marc Egger committed
327
328
329
     * @throws \CodeException
     * @throws \UserFormException
     * @throws \UserReportException
Carsten  Rose's avatar
Carsten Rose committed
330
     */
331
332
    public function testConfigIniDefaultValues() {

Carsten  Rose's avatar
Carsten Rose committed
333
334
335
        $_GET[] = array();
        $_POST[] = array();

336
337
        $expect = [

338
339
340
341
342
343
344
345
346
347
            SYSTEM_DB_1_USER => '<DBUSER>',
            SYSTEM_DB_1_SERVER => '<DBSERVER>',
            SYSTEM_DB_1_PASSWORD => '<DBPW>',
            SYSTEM_DB_1_NAME => '<DB>',
            SYSTEM_DOCUMENTATION_QFQ => SYSTEM_DOCUMENTATION_QFQ_URL,
            SYSTEM_FLAG_PRODUCTION => 'yes',
            SYSTEM_THUMBNAIL_DIR_SECURE => SYSTEM_THUMBNAIL_DIR_SECURE_DEFAULT,
            SYSTEM_THUMBNAIL_DIR_PUBLIC => SYSTEM_THUMBNAIL_DIR_PUBLIC_DEFAULT,
            SYSTEM_CMD_INKSCAPE => 'inkscape',
            SYSTEM_CMD_CONVERT => 'convert',
348
349
            SYSTEM_CMD_PDF2SVG => 'pdf2svg',
            SYSTEM_CMD_PDFTOCAIRO => 'pdftocairo',
350
351
352
353
354
355
356
357
358
359
            SYSTEM_CMD_WKHTMLTOPDF => '/opt/wkhtmltox/bin/wkhtmltopdf',
            SYSTEM_DATE_FORMAT => 'yyyy-mm-dd',
            SYSTEM_THROW_GENERAL_ERROR => 'no',
            SYSTEM_SQL_LOG_MODE => SQL_LOG_MODE_MODIFY,
            SYSTEM_SHOW_DEBUG_INFO => SYSTEM_SHOW_DEBUG_INFO_AUTO,
            SYSTEM_DB_INIT => 'set names utf8',
            SYSTEM_DB_UPDATE => SYSTEM_DB_UPDATE_AUTO,
            SYSTEM_DB_INDEX_DATA => '1',
            SYSTEM_DB_INDEX_QFQ => '1',
            SYSTEM_ESCAPE_TYPE_DEFAULT => 'm',
360
            SYSTEM_SECURITY_VARS_HONEYPOT => SYSTEM_SECURITY_VARS_HONEYPOT_NAMES,
361
362
363
364
365
366
367
368
369
370
            SYSTEM_SECURITY_ATTACK_DELAY => 5,
            SYSTEM_SECURITY_SHOW_MESSAGE => '0',
            SYSTEM_SECURITY_GET_MAX_LENGTH => 50,
            SYSTEM_RECORD_LOCK_TIMEOUT_SECONDS => SYSTEM_RECORD_LOCK_TIMEOUT_SECONDS_DEFAULT,
            SYSTEM_ENTER_AS_SUBMIT => 1,
            SYSTEM_EDIT_FORM_PAGE => 'form',
            SYSTEM_EXTRA_BUTTON_INFO_INLINE => '<span class="glyphicon glyphicon-info-sign" aria-hidden="true"></span>',
            SYSTEM_EXTRA_BUTTON_INFO_BELOW => '<span class="glyphicon glyphicon-info-sign text-info" aria-hidden="true"></span>',
            SYSTEM_EXTRA_BUTTON_INFO_CLASS => '',
            SYSTEM_SAVE_BUTTON_TEXT => '',
Carsten  Rose's avatar
Carsten Rose committed
371
            SYSTEM_SAVE_BUTTON_TOOLTIP => '',
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
            SYSTEM_SAVE_BUTTON_CLASS => 'btn btn-default navbar-btn',
            SYSTEM_SAVE_BUTTON_GLYPH_ICON => 'glyphicon-ok',
            SYSTEM_CLOSE_BUTTON_TEXT => '',
            SYSTEM_CLOSE_BUTTON_TOOLTIP => 'Close',
            SYSTEM_CLOSE_BUTTON_CLASS => 'btn btn-default navbar-btn',
            SYSTEM_CLOSE_BUTTON_GLYPH_ICON => 'glyphicon-remove',
            SYSTEM_DELETE_BUTTON_TEXT => '',
            SYSTEM_DELETE_BUTTON_TOOLTIP => 'Delete',
            SYSTEM_DELETE_BUTTON_CLASS => 'btn btn-default navbar-btn',
            SYSTEM_DELETE_BUTTON_GLYPH_ICON => 'glyphicon-trash',
            SYSTEM_NEW_BUTTON_TEXT => '',
            SYSTEM_NEW_BUTTON_TOOLTIP => 'New',
            SYSTEM_NEW_BUTTON_CLASS => 'btn btn-default navbar-btn',
            SYSTEM_NEW_BUTTON_GLYPH_ICON => 'glyphicon-plus',
            F_BS_COLUMNS => 'col-md-12 col-lg-10',
            F_BS_LABEL_COLUMNS => 'col-md-3 col-lg-3',
            F_BS_INPUT_COLUMNS => 'col-md-6 col-lg-6',
            F_BS_NOTE_COLUMNS => 'col-md-3 col-lg-3',
Carsten  Rose's avatar
Carsten Rose committed
390
391
            F_FE_DATA_REQUIRED_ERROR => F_FE_DATA_REQUIRED_ERROR_DEFAULT,
            F_FE_DATA_MATCH_ERROR => F_FE_DATA_MATCH_ERROR_DEFAULT,
392
            F_FE_DATA_ERROR => F_FE_DATA_ERROR_DEFAULT,
393
394
395
396
397
            F_CLASS_PILL => 'qfq-color-grey-1',
            F_CLASS_BODY => 'qfq-color-grey-2',
            F_BUTTON_ON_CHANGE_CLASS => 'btn-info alert-info',
            SYSTEM_DB_NAME_DATA => '<DB>',
            SYSTEM_DB_NAME_QFQ => '<DB>',
398
399
400
401
402
403
404
405
406
407
            'DB_2_USER' => '<DBUSER>',
            'DB_2_SERVER' => '<DBSERVER>',
            'DB_2_PASSWORD' => '<DBPW>',
            'DB_2_NAME' => '<DB>',
            'DB_3_USER' => '<DBUSER>',
            'DB_3_SERVER' => '<DBSERVER>',
            'DB_3_PASSWORD' => '<DBPW>',
            'DB_3_NAME' => '<DB>',
            'LDAP_1_RDN' => 'LDAP_1_RDN',
            'LDAP_1_PASSWORD' => 'LDAP_1_PASSWORD',
408
            SYSTEM_LABEL_ALIGN => SYSTEM_LABEL_ALIGN_LEFT,
Carsten  Rose's avatar
Carsten Rose committed
409
410
411
            F_FE_DATA_PATTERN_ERROR => F_FE_DATA_PATTERN_ERROR_DEFAULT,
            F_FE_DATA_PATTERN_ERROR_SYSTEM => F_FE_DATA_PATTERN_ERROR_DEFAULT,
            SYSTEM_SECURITY_FAILED_AUTH_DELAY => '3',
412
            SYSTEM_SQL_LOG_MODE_AUTOCRON => 'error',
Carsten  Rose's avatar
Carsten Rose committed
413
            F_CLASS => 'qfq-notify',
Carsten  Rose's avatar
Carsten Rose committed
414
            SYSTEM_RENDER => SYSTEM_RENDER_SINGLE,
415
416
417
            SYSTEM_CMD_QPDF => 'qpdf',
            SYSTEM_CMD_GS => 'gs',
            SYSTEM_CMD_PDFUNITE => 'pdfunite',
418
            SYSTEM_CMD_IMG2PDF => 'img2pdf',
419
        ];
420

421
422
        $body = <<< EOT
            <?php
423
            
424
425
426
427
428
429
            return [
                // Comment
                'DB_1_USER' => '<DBUSER>',
                'DB_1_SERVER' => '<DBSERVER>',
                'DB_1_PASSWORD' => '<DBPW>',
                'DB_1_NAME' => '<DB>',
430
431
432
433
434
435
436
437
438
439
440
441
442
443

                'DB_2_USER' => '<DBUSER>',
                'DB_2_SERVER' => '<DBSERVER>',
                'DB_2_PASSWORD' => '<DBPW>',
                'DB_2_NAME' => '<DB>',

                'DB_3_USER' => '<DBUSER>',
                'DB_3_SERVER' => '<DBSERVER>',
                'DB_3_PASSWORD' => '<DBPW>',
                'DB_3_NAME' => '<DB>',

                'LDAP_1_RDN' => 'LDAP_1_RDN',
                'LDAP_1_PASSWORD' => 'LDAP_1_PASSWORD',
                
444
445
            ];
EOT;
446

447
448
449
450
        $fileName = $this->createFile($body);
        $this->store = Store::getInstance('', true, $fileName);
        unlink($fileName);

451
        $config = $this->store->getStore(STORE_SYSTEM);
452

453
        # The following won't be checked by content, cause they will change on different installations.
454
//        foreach ([ SYSTEM_SQL_LOG, SYSTEM_MAIL_LOG, SYSTEM_SITE_PATH, SYSTEM_EXT_PATH, SYSTEM_SEND_E_MAIL] as $key) {
Carsten  Rose's avatar
Carsten Rose committed
455
        foreach ([SYSTEM_SITE_PATH, SYSTEM_EXT_PATH, SYSTEM_SEND_E_MAIL, SYSTEM_SESSION_TIMEOUT_SECONDS, SYSTEM_QFQ_LOG,
Carsten  Rose's avatar
Carsten Rose committed
456
                     SYSTEM_SQL_LOG, SYSTEM_MAIL_LOG, SYSTEM_FILE_MAX_FILE_SIZE] as $key) {
Carsten  Rose's avatar
Carsten Rose committed
457
            $this->assertTrue(isset($config[$key]), "Missing default value for '$key' ");
458
459
            unset ($config[$key]);
        }
460
        // check default values
461
        $this->assertEquals($expect, $config, "Retrieve system store.");
462
463
    }

464
    /**
Marc Egger's avatar
Marc Egger committed
465
     * @expectedException \UserFormException
466
     *
Marc Egger's avatar
Marc Egger committed
467
468
     * @throws \CodeException
     * @throws \UserFormException
469
     */
470
471
    public function testGetStore() {
        $this->assertEquals(array(), $this->store->getStore('unknownstore'));
472
473
    }

474
}