Added feature #12502: Use HMACs for authencity and integrity checks (Thanks to Marcus...
[Packages/TYPO3.CMS.git] / tests / t3lib / t3lib_div_testcase.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 2009 Ingo Renner <ingo@typo3.org>
6 * All rights reserved
7 *
8 * This script is part of the TYPO3 project. The TYPO3 project is
9 * free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * The GNU General Public License can be found at
15 * http://www.gnu.org/copyleft/gpl.html.
16 *
17 * This script 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 * This copyright notice MUST APPEAR in all copies of the script!
23 ***************************************************************/
24
25
26 /**
27 * Testcase for class t3lib_div
28 *
29 * @author Ingo Renner <ingo@typo3.org>
30 * @author Oliver Klee <typo3-coding@oliverklee.de>
31 *
32 * @package TYPO3
33 * @subpackage t3lib
34 */
35 class t3lib_div_testcase extends tx_phpunit_testcase {
36 /**
37 * backup of the global variables _GET, _POST, _SERVER
38 *
39 * @var array
40 */
41 private $backupGlobalVariables;
42
43 public function setUp() {
44 $this->backupGlobalVariables = array(
45 '_GET' => $_GET,
46 '_POST' => $_POST,
47 '_SERVER' => $_SERVER,
48 'TYPO3_CONF_VARS' => $GLOBALS['TYPO3_CONF_VARS'],
49 );
50 }
51
52 public function tearDown() {
53 foreach ($this->backupGlobalVariables as $key => $data) {
54 $GLOBALS[$key] = $data;
55 }
56 }
57
58
59 /**
60 * @test
61 */
62 public function checkIntExplodeConvertsStringsToInteger() {
63 $testString = '1,foo,2';
64 $expectedArray = array(1, 0, 2);
65 $actualArray = t3lib_div::intExplode(',', $testString);
66
67 $this->assertEquals($expectedArray, $actualArray);
68 }
69
70 /**
71 * @test
72 */
73 public function checkRevExplodeCorrectlyExplodesString() {
74 $testString = 'my:words:here';
75 $expectedArray = array('my:words', 'here');
76 $actualArray = t3lib_div::revExplode(':', $testString, 2);
77
78 $this->assertEquals($expectedArray, $actualArray);
79 }
80
81 /**
82 * @test
83 */
84 public function checkTrimExplodeTrimsSpacesAtElementStartAndEnd() {
85 $testString = ' a , b , c ,d ,, e,f,';
86 $expectedArray = array('a', 'b', 'c', 'd', '', 'e', 'f', '');
87 $actualArray = t3lib_div::trimExplode(',', $testString);
88
89 $this->assertEquals($expectedArray, $actualArray);
90 }
91
92 /**
93 * @test
94 */
95 public function checkTrimExplodeRemovesNewLines() {
96 $testString = ' a , b , ' . LF . ' ,d ,, e,f,';
97 $expectedArray = array('a', 'b', 'd', 'e', 'f');
98 $actualArray = t3lib_div::trimExplode(',', $testString, true);
99
100 $this->assertEquals($expectedArray, $actualArray);
101 }
102
103 /**
104 * @test
105 */
106 public function checkTrimExplodeRemovesEmptyElements() {
107 $testString = 'a , b , c , ,d ,, ,e,f,';
108 $expectedArray = array('a', 'b', 'c', 'd', 'e', 'f');
109 $actualArray = t3lib_div::trimExplode(',', $testString, true);
110
111 $this->assertEquals($expectedArray, $actualArray);
112 }
113
114 /**
115 * @test
116 */
117 public function checkTrimExplodeKeepsRemainingResultsWithEmptyItemsAfterReachingLimitWithPositiveParameter() {
118 $testString = ' a , b , c , , d,, ,e ';
119 $expectedArray = array('a', 'b', 'c,,d,,,e'); // limiting returns the rest of the string as the last element
120 $actualArray = t3lib_div::trimExplode(',', $testString, false, 3);
121
122 $this->assertEquals($expectedArray, $actualArray);
123 }
124
125 /**
126 * @test
127 */
128 public function checkTrimExplodeKeepsRemainingResultsWithoutEmptyItemsAfterReachingLimitWithPositiveParameter() {
129 $testString = ' a , b , c , , d,, ,e ';
130 $expectedArray = array('a', 'b', 'c,d,e'); // limiting returns the rest of the string as the last element
131 $actualArray = t3lib_div::trimExplode(',', $testString, true, 3);
132
133 $this->assertEquals($expectedArray, $actualArray);
134 }
135
136 /**
137 * @test
138 */
139 public function checkTrimExplodeKeepsRamainingResultsWithEmptyItemsAfterReachingLimitWithNegativeParameter() {
140 $testString = ' a , b , c , d, ,e, f , , ';
141 $expectedArray = array('a', 'b', 'c', 'd', '', 'e'); // limiting returns the rest of the string as the last element
142 $actualArray = t3lib_div::trimExplode(',', $testString, false, -3);
143
144 $this->assertEquals($expectedArray, $actualArray);
145 }
146
147 /**
148 * @test
149 */
150 public function checkTrimExplodeKeepsRamainingResultsWithoutEmptyItemsAfterReachingLimitWithNegativeParameter() {
151 $testString = ' a , b , c , d, ,e, f , , ';
152 $expectedArray = array('a', 'b', 'c'); // limiting returns the rest of the string as the last element
153 $actualArray = t3lib_div::trimExplode(',', $testString, true, -3);
154
155 $this->assertEquals($expectedArray, $actualArray);
156 }
157
158 /**
159 * @test
160 */
161 public function checkTrimExplodeReturnsExactResultsWithoutReachingLimitWithPositiveParameter() {
162 $testString = ' a , b , , c , , , ';
163 $expectedArray = array('a', 'b', 'c'); // limiting returns the rest of the string as the last element
164 $actualArray = t3lib_div::trimExplode(',', $testString, true, 4);
165
166 $this->assertEquals($expectedArray, $actualArray);
167 }
168
169 /**
170 * @test
171 */
172 public function checkTrimExplodeKeepsZeroAsString() {
173 $testString = 'a , b , c , ,d ,, ,e,f, 0 ,';
174 $expectedArray = array('a', 'b', 'c', 'd', 'e', 'f', '0');
175 $actualArray = t3lib_div::trimExplode(',', $testString, true);
176
177 $this->assertEquals($expectedArray, $actualArray);
178 }
179
180 /**
181 * Checks whether measurement strings like "100k" return the accordant
182 * byte representation like 102400 in this case.
183 *
184 * @test
185 */
186 public function checkGetBytesFromSizeMeasurement() {
187 $this->assertEquals(
188 '102400',
189 t3lib_div::getBytesFromSizeMeasurement('100k')
190 );
191
192 $this->assertEquals(
193 '104857600',
194 t3lib_div::getBytesFromSizeMeasurement('100m')
195 );
196
197 $this->assertEquals(
198 '107374182400',
199 t3lib_div::getBytesFromSizeMeasurement('100g')
200 );
201 }
202
203 /**
204 * @test
205 */
206 public function checkIndpEnvTypo3SitePathNotEmpty() {
207 $actualEnv = t3lib_div::getIndpEnv('TYPO3_SITE_PATH');
208 $this->assertTrue(strlen($actualEnv) >= 1);
209 $this->assertEquals('/', $actualEnv{0});
210 $this->assertEquals('/', $actualEnv{strlen($actualEnv) - 1});
211 }
212
213 /**
214 * @test
215 * @see t3lib_div::underscoredToUpperCamelCase
216 */
217 public function canConvertFromUnderscoredToUpperCamelCase() {
218 $this->assertEquals('BlogExample', t3lib_div::underscoredToUpperCamelCase('blog_example'));
219 $this->assertEquals('Blogexample', t3lib_div::underscoredToUpperCamelCase('blogexample'));
220 }
221
222 /**
223 * @test
224 * @see t3lib_div::underscoredToLowerCamelCase
225 */
226 public function canConvertFromUnderscoredToLowerCamelCase() {
227 $this->assertEquals('minimalValue', t3lib_div::underscoredToLowerCamelCase('minimal_value'));
228 $this->assertEquals('minimalvalue', t3lib_div::underscoredToLowerCamelCase('minimalvalue'));
229 }
230
231 /**
232 * @test
233 * @see t3lib_div::camelCaseToLowerCaseUnderscored
234 */
235 public function canConvertFromCamelCaseToLowerCaseUnderscored() {
236 $this->assertEquals('blog_example', t3lib_div::camelCaseToLowerCaseUnderscored('BlogExample'));
237 $this->assertEquals('blogexample', t3lib_div::camelCaseToLowerCaseUnderscored('Blogexample'));
238 $this->assertEquals('blogexample', t3lib_div::camelCaseToLowerCaseUnderscored('blogexample'));
239
240 $this->assertEquals('minimal_value', t3lib_div::camelCaseToLowerCaseUnderscored('minimalValue'));
241 }
242
243 /**
244 * @test
245 * @see t3lib_div::lcfirst
246 */
247 public function canConvertFirstCharacterToBeLowerCase() {
248 $this->assertEquals('blogexample', t3lib_div::lcfirst('Blogexample'));
249 $this->assertEquals('blogExample', t3lib_div::lcfirst('BlogExample'));
250 $this->assertEquals('blogexample', t3lib_div::lcfirst('blogexample'));
251 }
252
253 /**
254 * Tests whether whitespaces are encoded correctly in a quoted-printable mail header.
255 * @test
256 */
257 public function areWhitespacesEncodedInQuotedPrintableMailHeader() {
258 $this->assertEquals(
259 '=?utf-8?Q?We_test_whether_the_copyright_character_=C2=A9_is_encoded_correctly?=',
260 t3lib_div::encodeHeader(
261 "We test whether the copyright character \xc2\xa9 is encoded correctly",
262 'quoted-printable',
263 'utf-8'
264 )
265 );
266 }
267
268 /**
269 * Tests whether question marks are encoded correctly in a quoted-printable mail header.
270 * @test
271 */
272 public function areQuestionMarksEncodedInQuotedPrintableMailHeader() {
273 $this->assertEquals(
274 '=?utf-8?Q?Is_the_copyright_character_=C2=A9_really_encoded_correctly=3F_Really=3F?=',
275 t3lib_div::encodeHeader(
276 "Is the copyright character \xc2\xa9 really encoded correctly? Really?",
277 'quoted-printable',
278 'utf-8'
279 )
280 );
281 }
282
283 /**
284 * Data provider for valid URLs, like PHP's source code test cases
285 */
286 public function validUrlDataProvider() {
287 return array(
288 array('http://example.com/index.html'),
289 array('http://www.example.com/index.php'),
290 array('http://www.example/img/test.png'),
291 array('http://www.example/img/dir/'),
292 array('http://www.example/img/dir'),
293 array('file:///tmp/test.c'),
294 array('ftp://ftp.example.com/tmp/'),
295 array('mailto:foo@bar.com'),
296 array('news:news.php.net'),
297 array('file://foo/bar'),
298 array('http://qwe'),
299 );
300 }
301
302 /**
303 * Data provider for invalid URLs, like PHP's source code test cases
304 */
305 public function invalidUrlDataProvider() {
306 return array(
307 array('http//www.example/wrong/url/'),
308 array('http:/www.example'),
309 array('/tmp/test.c'),
310 array('/'),
311 array('http://'),
312 array('http:/'),
313 array('http:'),
314 array('http'),
315 array(''),
316 array('-1'),
317 array('array()'),
318 array('qwe'),
319 );
320 }
321
322 /**
323 * @test
324 * @dataProvider validUrlDataProvider
325 * @see t3lib_div::isValidUrl()
326 */
327 public function checkisValidURL($url) {
328 $this->assertTrue(t3lib_div::isValidUrl($url));
329 }
330
331 /**
332 * @test
333 * @dataProvider invalidUrlDataProvider
334 * @see t3lib_div::isValidUrl()
335 */
336 public function checkisInValidURL($url) {
337 $this->assertFalse(t3lib_div::isValidUrl($url));
338 }
339
340 /**
341 * @test
342 * @see t3lib_div::isValidUrl()
343 */
344 public function checkisValidURLSucceedsWithWebRessource() {
345 $testUrl = 'http://www.example.org/';
346 $this->assertTrue(t3lib_div::isValidUrl($testUrl));
347 }
348
349 /**
350 * @test
351 * @see t3lib_div::isValidUrl()
352 */
353 public function checkisValidURLSucceedsWithExtentedWebRessource() {
354 $testUrl = 'https://user:pw@www.example.org:80/path?arg=value#fragment';
355 $this->assertTrue(t3lib_div::isValidUrl($testUrl));
356 }
357
358 /**
359 * @test
360 * @see t3lib_div::isValidUrl()
361 */
362 public function checkisValidURLSucceedsWithTelnetRessource() {
363 $testUrl = 'telnet://192.0.2.16:80/';
364 $this->assertTrue(t3lib_div::isValidUrl($testUrl));
365 }
366
367 /**
368 * @test
369 */
370 public function checkisValidURLSucceedsWithLdapRessource() {
371 $testUrl = 'ldap://[2001:db8::7]/c=GB?objectClass?one';
372 $this->assertTrue(t3lib_div::isValidUrl($testUrl));
373 }
374
375 /**
376 * @test
377 * @see t3lib_div::isValidUrl()
378 */
379 public function checkisValidURLSucceedsWithFileRessource() {
380 $testUrl = 'file:///etc/passwd';
381 $this->assertTrue(t3lib_div::isValidUrl($testUrl));
382 }
383
384 /**
385 * @test
386 * @see t3lib_div::isValidUrl()
387 */
388 public function checkisValidURLFailsWithHostnameOnly() {
389 $testUrl = 'www.example.org/';
390 $this->assertFalse(t3lib_div::isValidUrl($testUrl));
391 }
392
393 /**
394 * @test
395 * @see t3lib_div::isOnCurrentHost()
396 */
397 public function checkisOnCurrentHostFailsWithLocalhostIPOnly() {
398 $testUrl = '127.0.0.1';
399 $this->assertFalse(t3lib_div::isOnCurrentHost($testUrl));
400 }
401
402 /**
403 * @test
404 * @see t3lib_div::isOnCurrentHost()
405 */
406 public function checkisOnCurrentHostFailsWithPathsOnly() {
407 $testUrl = './relpath/file.txt';
408 $this->assertFalse(t3lib_div::isOnCurrentHost($testUrl));
409 $testUrl = '/abspath/file.txt?arg=value';
410 $this->assertFalse(t3lib_div::isOnCurrentHost($testUrl));
411 }
412
413 /**
414 * @test
415 * @see t3lib_div::isOnCurrentHost()
416 */
417 public function checkisOnCurrentHostFailsWithArbitraryString() {
418 $testUrl = 'arbitrary string';
419 $this->assertFalse(t3lib_div::isOnCurrentHost($testUrl));
420 }
421
422 /**
423 * @test
424 * @see t3lib_div::isOnCurrentHost()
425 */
426 public function checkisOnCurrentHostFailsWithEmptyUrl() {
427 $testUrl = '';
428 $this->assertFalse(t3lib_div::isOnCurrentHost($testUrl));
429 }
430
431 /**
432 * @test
433 * @see t3lib_div::isOnCurrentHost()
434 */
435 public function checkisOnCurrentHostFailsWithDifferentHost() {
436 $testUrl = t3lib_div::getIndpEnv('TYPO3_REQUEST_HOST') . '.example.org';
437 $this->assertFalse(t3lib_div::isOnCurrentHost($testUrl));
438 }
439
440 /**
441 * @test
442 * @see t3lib_div::isOnCurrentHost()
443 */
444 public function checkisOnCurrentHostSucceedsWithCurrentHost() {
445 $testUrl = t3lib_div::getIndpEnv('TYPO3_REQUEST_URL');
446 $this->assertTrue(t3lib_div::isOnCurrentHost($testUrl));
447 }
448
449
450 ////////////////////////////////////////
451 // Tests concerning sanitizeLocalUrl
452 ////////////////////////////////////////
453
454 /**
455 * Data provider for valid URLs.
456 * @see sanitizeLocalUrlAcceptsValidUrls
457 */
458 public function validLocalUrlDataProvider() {
459 return array(
460 array('alt_intro.php'),
461 array('alt_intro.php?foo=1&bar=2'),
462 array('/typo3/alt_intro.php'),
463 array('/index.php'),
464 array('../index.php'),
465 array('../typo3/alt_intro.php'),
466 array('../~userDirectory/index.php'),
467 array('../typo3/mod.php?var1=test-case&var2=~user'),
468 array(PATH_site . 'typo3/alt_intro.php'),
469 array(t3lib_div::getIndpEnv('TYPO3_SITE_URL') . 'typo3/alt_intro.php'),
470 array(t3lib_div::getIndpEnv('TYPO3_REQUEST_HOST') . '/index.php'),
471 );
472 }
473
474 /**
475 * Data provider for invalid URLs.
476 * @see sanitizeLocalUrlDeniesInvalidUrls
477 */
478 public function invalidLocalUrlDataProvider() {
479 return array(
480 array(''),
481 array('http://www.google.de/'),
482 array('https://www.google.de/'),
483 array('../typo3/whatever.php?argument=javascript:alert(0)'),
484 );
485 }
486
487 /**
488 * Tests whether valid local URLs are handled correctly.
489 * @dataProvider validLocalUrlDataProvider
490 * @test
491 */
492 public function sanitizeLocalUrlAcceptsPlainValidUrls($url) {
493 $this->assertEquals($url, t3lib_div::sanitizeLocalUrl($url));
494 }
495
496 /**
497 * Tests whether valid local URLs are handled correctly.
498 * @dataProvider validLocalUrlDataProvider
499 * @test
500 */
501 public function sanitizeLocalUrlAcceptsEncodedValidUrls($url) {
502 $this->assertEquals(rawurlencode($url), t3lib_div::sanitizeLocalUrl(rawurlencode($url)));
503 }
504
505 /**
506 * Tests whether valid local URLs are handled correctly.
507 * @dataProvider invalidLocalUrlDataProvider
508 * @test
509 */
510 public function sanitizeLocalUrlDeniesPlainInvalidUrls($url) {
511 $this->assertEquals('', t3lib_div::sanitizeLocalUrl($url));
512 }
513
514 /**
515 * Tests whether valid local URLs are handled correctly.
516 * @dataProvider invalidLocalUrlDataProvider
517 * @test
518 */
519 public function sanitizeLocalUrlDeniesEncodedInvalidUrls($url) {
520 $this->assertEquals('', t3lib_div::sanitizeLocalUrl(rawurlencode($url)));
521 }
522
523 //////////////////////////////////////
524 // Tests concerning arrayDiffAssocRecursive
525 //////////////////////////////////////
526
527 /**
528 * Test if a one dimensional array is correctly diffed.
529 *
530 * @test
531 * @see t3lib_div::arrayDiffAssocRecursive
532 */
533 public function doesArrayDiffAssocRecursiveCorrectlyHandleOneDimensionalArrays() {
534 $array1 = array(
535 'key1' => 'value1',
536 'key2' => 'value2',
537 'key3' => 'value3',
538 );
539 $array2 = array(
540 'key1' => 'value1',
541 'key3' => 'value3',
542 );
543 $expectedResult = array(
544 'key2' => 'value2',
545 );
546 $actualResult = t3lib_div::arrayDiffAssocRecursive($array1, $array2);
547 $this->assertEquals($expectedResult, $actualResult);
548 }
549
550 /**
551 * Test if a three dimensional array is correctly diffed.
552 *
553 * @test
554 * @see t3lib_div::arrayDiffAssocRecursive
555 */
556 public function doesArrayDiffAssocRecursiveCorrectlyHandleMultiDimensionalArrays() {
557 $array1 = array(
558 'key1' => 'value1',
559 'key2' => array(
560 'key21' => 'value21',
561 'key22' => 'value22',
562 'key23' => array(
563 'key231' => 'value231',
564 'key232' => 'value232',
565 ),
566 ),
567 );
568 $array2 = array(
569 'key1' => 'value1',
570 'key2' => array(
571 'key21' => 'value21',
572 'key23' => array(
573 'key231' => 'value231',
574 ),
575 ),
576 );
577 $expectedResult = array(
578 'key2' => array(
579 'key22' => 'value22',
580 'key23' => array(
581 'key232' => 'value232',
582 ),
583 ),
584 );
585 $actualResult = t3lib_div::arrayDiffAssocRecursive($array1, $array2);
586 $this->assertEquals($expectedResult, $actualResult);
587 }
588
589 /**
590 * Test if arrays are correctly diffed if types are different.
591 *
592 * @test
593 * @see t3lib_div::arrayDiffAssocRecursive
594 */
595 public function doesArrayDiffAssocRecursiveCorrectlyHandleMixedArrays() {
596 $array1 = array(
597 'key1' => array(
598 'key11' => 'value11',
599 'key12' => 'value12',
600 ),
601 'key2' => 'value2',
602 'key3' => 'value3',
603 );
604 $array2 = array(
605 'key1' => 'value1',
606 'key2' => array(
607 'key21' => 'value21',
608 ),
609 );
610 $expectedResult = array(
611 'key3' => 'value3',
612 );
613 $actualResult = t3lib_div::arrayDiffAssocRecursive($array1, $array2);
614 $this->assertEquals($expectedResult, $actualResult);
615 }
616
617 //////////////////////////////////////
618 // Tests concerning removeDotsFromTS
619 //////////////////////////////////////
620
621 /**
622 * Tests whether removeDotsFromTS() behaves correctly.
623 * @test
624 * @see t3lib_div::removeDotsFromTS()
625 */
626 public function doesRemoveDotsFromTypoScriptSucceed() {
627 $typoScript = array(
628 'propertyA.' => array(
629 'keyA.' => array(
630 'valueA' => 1,
631 ),
632 'keyB' => 2,
633 ),
634 'propertyB' => 3,
635 );
636
637 $expectedResult = array(
638 'propertyA' => array(
639 'keyA' => array(
640 'valueA' => 1,
641 ),
642 'keyB' => 2,
643 ),
644 'propertyB' => 3,
645 );
646
647 $this->assertEquals($expectedResult, t3lib_div::removeDotsFromTS($typoScript));
648 }
649
650 /**
651 * Tests whether removeDotsFromTS() behaves correctly.
652 * @test
653 * @see t3lib_div::removeDotsFromTS()
654 */
655 public function doesRemoveDotsFromTypoScriptCorrectlyOverrideWithArray() {
656 $typoScript = array(
657 'propertyA.' => array(
658 'keyA' => 'getsOverridden',
659 'keyA.' => array(
660 'valueA' => 1,
661 ),
662 'keyB' => 2,
663 ),
664 'propertyB' => 3,
665 );
666
667 $expectedResult = array(
668 'propertyA' => array(
669 'keyA' => array(
670 'valueA' => 1,
671 ),
672 'keyB' => 2,
673 ),
674 'propertyB' => 3,
675 );
676
677 $this->assertEquals($expectedResult, t3lib_div::removeDotsFromTS($typoScript));
678 }
679
680 /**
681 * Tests whether removeDotsFromTS() behaves correctly.
682 * @test
683 * @see t3lib_div::removeDotsFromTS()
684 */
685 public function doesRemoveDotsFromTypoScriptCorrectlyOverrideWithScalar() {
686 $typoScript = array(
687 'propertyA.' => array(
688 'keyA.' => array(
689 'valueA' => 1,
690 ),
691 'keyA' => 'willOverride',
692 'keyB' => 2,
693 ),
694 'propertyB' => 3,
695 );
696
697 $expectedResult = array(
698 'propertyA' => array(
699 'keyA' => 'willOverride',
700 'keyB' => 2,
701 ),
702 'propertyB' => 3,
703 );
704
705 $this->assertEquals($expectedResult, t3lib_div::removeDotsFromTS($typoScript));
706 }
707
708 /**
709 * Tests whether getDirs() returns an array of diretories from a given path
710 * @test
711 * @see t3lib_div::getDirs($path)
712 */
713 public function checkGetDirsReturnsArrayOfDirectoriesFromGivenDirectory() {
714 $path = PATH_t3lib;
715 $directories = t3lib_div::get_dirs($path);
716
717 $this->assertType('array', $directories);
718 }
719
720 /**
721 * Tests whether getDirs() returns the string 'error' in case of problems reading from the given path
722 * @test
723 * @see t3lib_div::getDirs($path)
724 */
725 public function checkGetDirsReturnsStringErrorOnPathFailure() {
726 $path = 'foo';
727 $result = t3lib_div::get_dirs($path);
728 $expectedResult = 'error';
729
730 $this->assertEquals($expectedResult, $result);
731 }
732
733
734 //////////////////////////////////
735 // Tests concerning hmac
736 //////////////////////////////////
737
738 /**
739 * @test
740 */
741 public function hmacReturnsHashOfProperLength() {
742 $hmac = t3lib_div::hmac('message');
743 $this->assertTrue(!empty($hmac) && is_string($hmac));
744 $this->assertTrue(strlen($hmac) == 40);
745 }
746
747 /**
748 * @test
749 */
750 public function hmacReturnsEqualHashesForEqualInput() {
751 $msg0 = 'message';
752 $msg1 = 'message';
753 $this->assertEquals(t3lib_div::hmac($msg0), t3lib_div::hmac($msg1));
754 }
755
756 /**
757 * @test
758 */
759 public function hmacReturnsNotEqualHashesForNotEqualInput() {
760 $msg0 = 'message0';
761 $msg1 = 'message1';
762 $this->assertNotEquals(t3lib_div::hmac($msg0), t3lib_div::hmac($msg1));
763 }
764
765
766 //////////////////////////////////
767 // Tests concerning quoteJSvalue
768 //////////////////////////////////
769
770 /**
771 * @test
772 */
773 public function quoteJSvalueHtmlspecialcharsDataByDefault() {
774 $this->assertContains(
775 '&gt;',
776 t3lib_div::quoteJSvalue('>')
777 );
778 }
779
780 /**
781 * @test
782 */
783 public function quoteJSvaluetHtmlspecialcharsDataWithinCDataSetToFalse() {
784 $this->assertContains(
785 '&gt;',
786 t3lib_div::quoteJSvalue('>', false)
787 );
788 }
789
790 /**
791 * @test
792 */
793 public function quoteJSvaluetNotHtmlspecialcharsDataWithinCDataSetToTrue() {
794 $this->assertContains(
795 '>',
796 t3lib_div::quoteJSvalue('>', true)
797 );
798 }
799
800 /**
801 * @test
802 */
803 public function quoteJSvalueReturnsEmptyStringQuotedInSingleQuotes() {
804 $this->assertEquals(
805 "''",
806 t3lib_div::quoteJSvalue("", true)
807 );
808 }
809
810 /**
811 * @test
812 */
813 public function quoteJSvalueNotModifiesStringWithoutSpecialCharacters() {
814 $this->assertEquals(
815 "'Hello world!'",
816 t3lib_div::quoteJSvalue("Hello world!", true)
817 );
818 }
819
820 /**
821 * @test
822 */
823 public function quoteJSvalueEscapesSingleQuote() {
824 $this->assertEquals(
825 "'\\''",
826 t3lib_div::quoteJSvalue("'", true)
827 );
828 }
829
830 /**
831 * @test
832 */
833 public function quoteJSvalueEscapesDoubleQuoteWithinCDataSetToTrue() {
834 $this->assertEquals(
835 "'\\\"'",
836 t3lib_div::quoteJSvalue('"', true)
837 );
838 }
839
840 /**
841 * @test
842 */
843 public function quoteJSvalueEscapesAndHtmlspecialcharsDoubleQuoteWithinCDataSetToFalse() {
844 $this->assertEquals(
845 "'\\&quot;'",
846 t3lib_div::quoteJSvalue('"', false)
847 );
848 }
849
850 /**
851 * @test
852 */
853 public function quoteJSvalueEscapesTab() {
854 $this->assertEquals(
855 "'" . '\t' . "'",
856 t3lib_div::quoteJSvalue(TAB)
857 );
858 }
859
860 /**
861 * @test
862 */
863 public function quoteJSvalueEscapesLinefeed() {
864 $this->assertEquals(
865 "'" . '\n' . "'",
866 t3lib_div::quoteJSvalue(LF)
867 );
868 }
869
870 /**
871 * @test
872 */
873 public function quoteJSvalueEscapesCarriageReturn() {
874 $this->assertEquals(
875 "'" . '\r' . "'",
876 t3lib_div::quoteJSvalue(CR)
877 );
878 }
879
880 /**
881 * @test
882 */
883 public function quoteJSvalueEscapesBackslah() {
884 $this->assertEquals(
885 "'\\\\'",
886 t3lib_div::quoteJSvalue('\\')
887 );
888 }
889
890 /**
891 * Tests the locallangXMLOverride feature of readLLfile()
892 * @test
893 */
894 public function readLLfileLocallangXMLOverride() {
895 $unique = uniqid('locallangXMLOverrideTest');
896
897 $xml = '<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
898 <T3locallang>
899 <data type="array">
900 <languageKey index="default" type="array">
901 <label index="buttons.logout">EXIT</label>
902 </languageKey>
903 </data>
904 </T3locallang>';
905
906 $file = PATH_site . 'typo3temp/' . $unique . '.xml';
907 t3lib_div::writeFileToTypo3tempDir($file, $xml);
908
909 // get default value
910 $defaultLL = t3lib_div::readLLfile('EXT:lang/locallang_core.xml', 'default');
911
912 // set override file
913 $GLOBALS['TYPO3_CONF_VARS']['SYS']['locallangXMLOverride']['EXT:lang/locallang_core.xml'][$unique] = $file;
914
915 // get override value
916 $overrideLL = t3lib_div::readLLfile('EXT:lang/locallang_core.xml', 'default');
917
918 $this->assertNotEquals($overrideLL['default']['buttons.logout'], '');
919 $this->assertNotEquals($defaultLL['default']['buttons.logout'], $overrideLL['default']['buttons.logout']);
920 $this->assertEquals($overrideLL['default']['buttons.logout'], 'EXIT');
921
922 unlink($file);
923 }
924
925
926 ///////////////////////////////
927 // Tests concerning _GETset()
928 ///////////////////////////////
929
930 /**
931 * @test
932 */
933 public function getSetCanSetWholeArray() {
934 $_GET = array();
935 $GLOBALS['HTTP_GET_VARS'] = array();
936 t3lib_div::_GETset(array('oneKey' => 'oneValue'));
937
938 $this->assertEquals(
939 array('oneKey' => 'oneValue'),
940 $_GET
941 );
942 $this->assertEquals(
943 array('oneKey' => 'oneValue'),
944 $GLOBALS['HTTP_GET_VARS']
945 );
946 }
947
948 /**
949 * @test
950 */
951 public function getSetForArrayDropsExistingValues() {
952 $_GET = array();
953 $GLOBALS['HTTP_GET_VARS'] = array();
954
955 t3lib_div::_GETset(array('foo' => 'bar'));
956 t3lib_div::_GETset(array('oneKey' => 'oneValue'));
957
958 $this->assertEquals(
959 array('oneKey' => 'oneValue'),
960 $_GET
961 );
962 $this->assertEquals(
963 array('oneKey' => 'oneValue'),
964 $GLOBALS['HTTP_GET_VARS']
965 );
966 }
967
968 /**
969 * @test
970 */
971 public function getSetCanAssignOneValueToOneKey() {
972 $_GET = array();
973 $GLOBALS['HTTP_GET_VARS'] = array();
974
975 t3lib_div::_GETset('oneValue', 'oneKey');
976
977 $this->assertEquals(
978 'oneValue',
979 $_GET['oneKey']
980 );
981 $this->assertEquals(
982 'oneValue',
983 $GLOBALS['HTTP_GET_VARS']['oneKey']
984 );
985 }
986
987 /**
988 * @test
989 */
990 public function getSetForOneValueNotDropsExistingValues() {
991 $_GET = array();
992 $GLOBALS['HTTP_GET_VARS'] = array();
993
994 t3lib_div::_GETset(array('foo' => 'bar'));
995 t3lib_div::_GETset('oneValue', 'oneKey');
996
997 $this->assertEquals(
998 array('foo' => 'bar', 'oneKey' => 'oneValue'),
999 $_GET
1000 );
1001 $this->assertEquals(
1002 array('foo' => 'bar', 'oneKey' => 'oneValue'),
1003 $GLOBALS['HTTP_GET_VARS']
1004 );
1005 }
1006
1007 /**
1008 * @test
1009 */
1010 public function getSetCanAssignAnArrayToSpecificArrayElement() {
1011 $_GET = array();
1012 $GLOBALS['HTTP_GET_VARS'] = array();
1013
1014 t3lib_div::_GETset(array('childKey' => 'oneValue'), 'parentKey');
1015
1016 $this->assertEquals(
1017 array('parentKey' => array('childKey' => 'oneValue')),
1018 $_GET
1019 );
1020 $this->assertEquals(
1021 array('parentKey' => array('childKey' => 'oneValue')),
1022 $GLOBALS['HTTP_GET_VARS']
1023 );
1024 }
1025
1026 /**
1027 * @test
1028 */
1029 public function getSetCanAssignAValueToSpecificArrayChildElement() {
1030 $_GET = array();
1031 $GLOBALS['HTTP_GET_VARS'] = array();
1032
1033 t3lib_div::_GETset('oneValue', 'parentKey|childKey');
1034
1035 $this->assertEquals(
1036 array('parentKey' => array('childKey' => 'oneValue')),
1037 $_GET
1038 );
1039 $this->assertEquals(
1040 array('parentKey' => array('childKey' => 'oneValue')),
1041 $GLOBALS['HTTP_GET_VARS']
1042 );
1043 }
1044
1045 /**
1046 * @test
1047 */
1048 public function getSetCanAssignAnArrayToSpecificArrayChildElement() {
1049 $_GET = array();
1050 $GLOBALS['HTTP_GET_VARS'] = array();
1051
1052 t3lib_div::_GETset(
1053 array('key1' => 'value1', 'key2' => 'value2'),
1054 'parentKey|childKey'
1055 );
1056
1057 $this->assertEquals(
1058 array(
1059 'parentKey' => array(
1060 'childKey' => array('key1' => 'value1', 'key2' => 'value2')
1061 )
1062 ),
1063 $_GET
1064 );
1065 $this->assertEquals(
1066 array(
1067 'parentKey' => array(
1068 'childKey' => array('key1' => 'value1', 'key2' => 'value2')
1069 )
1070 ),
1071 $GLOBALS['HTTP_GET_VARS']
1072 );
1073 }
1074
1075 /**
1076 * Checks if t3lib_div::fixPermissions() correctly sets permissions to single file
1077 * This test assumes directory 'PATH_site'/typo3temp exists
1078 * This test is not available on windows OS
1079 *
1080 * @test
1081 * @see t3lib_div::fixPermissions()
1082 */
1083 public function checkFixPermissionsCorrectlySetsPermissionsToFile() {
1084 if (TYPO3_OS == 'WIN') {
1085 $this->markTestSkipped('fixPermissions() tests not available on Windows');
1086 }
1087
1088 // Create and prepare test file
1089 $filename = PATH_site . 'typo3temp/' . uniqid('test_');
1090 t3lib_div::writeFileToTypo3tempDir($filename, '42');
1091 chmod($filename, 0742);
1092
1093 // Set target permissions and run method
1094 $GLOBALS['TYPO3_CONF_VARS']['BE']['fileCreateMask'] = '0660';
1095 $GLOBALS['TYPO3_CONF_VARS']['BE']['createGroup'] = posix_getegid();
1096 $fixPermissionsResult = t3lib_div::fixPermissions($filename);
1097
1098 // Get actual permissions and clean up
1099 clearstatcache();
1100 $resultFilePermissions = substr(decoct(fileperms($filename)), 2);
1101 $resultFileGroup = filegroup($filename);
1102 unlink($filename);
1103
1104 // Test if everything was ok
1105 $this->assertTrue($fixPermissionsResult);
1106 $this->assertEquals($resultFilePermissions, '0660');
1107 $this->assertEquals($resultFileGroup, posix_getegid());
1108 }
1109
1110 /**
1111 * Checks if t3lib_div::fixPermissions() correctly sets permissions to hidden file
1112 * This test assumes directory 'PATH_site'/typo3temp exists
1113 * This test is not available on windows OS
1114 *
1115 * @test
1116 * @see t3lib_div::fixPermissions()
1117 */
1118 public function checkFixPermissionsCorrectlySetsPermissionsToHiddenFile() {
1119 if (TYPO3_OS == 'WIN') {
1120 $this->markTestSkipped('fixPermissions() tests not available on Windows');
1121 }
1122
1123 // Create and prepare test file
1124 $filename = PATH_site . 'typo3temp/' . uniqid('.test_');
1125 t3lib_div::writeFileToTypo3tempDir($filename, '42');
1126 chmod($filename, 0742);
1127
1128 // Set target permissions and run method
1129 $GLOBALS['TYPO3_CONF_VARS']['BE']['fileCreateMask'] = '0660';
1130 $GLOBALS['TYPO3_CONF_VARS']['BE']['createGroup'] = posix_getegid();
1131 $fixPermissionsResult = t3lib_div::fixPermissions($filename);
1132
1133 // Get actual permissions and clean up
1134 clearstatcache();
1135 $resultFilePermissions = substr(decoct(fileperms($filename)), 2);
1136 $resultFileGroup = filegroup($filename);
1137 unlink($filename);
1138
1139 // Test if everything was ok
1140 $this->assertTrue($fixPermissionsResult);
1141 $this->assertEquals($resultFilePermissions, '0660');
1142 $this->assertEquals($resultFileGroup, posix_getegid());
1143 }
1144
1145 /**
1146 * Checks if t3lib_div::fixPermissions() correctly sets permissions to directory with trailing slash
1147 * This test assumes directory 'PATH_site'/typo3temp exists
1148 * This test is not available on windows OS
1149 *
1150 * @test
1151 * @see t3lib_div::fixPermissions()
1152 */
1153 public function checkFixPermissionsCorrectlySetsPermissionsToDirectory() {
1154 if (TYPO3_OS == 'WIN') {
1155 $this->markTestSkipped('fixPermissions() tests not available on Windows');
1156 }
1157
1158 // Create and prepare test directory
1159 $directory = PATH_site . 'typo3temp/' . uniqid('test_');
1160 t3lib_div::mkdir($directory);
1161 chmod($directory, 1551);
1162
1163 // Set target permissions and run method
1164 $GLOBALS['TYPO3_CONF_VARS']['BE']['folderCreateMask'] = '2770';
1165 $GLOBALS['TYPO3_CONF_VARS']['BE']['createGroup'] = posix_getegid();
1166 $fixPermissionsResult = t3lib_div::fixPermissions($directory . '/');
1167
1168 // Get actual permissions and clean up
1169 clearstatcache();
1170 $resultDirectoryPermissions = substr(decoct(fileperms($directory)), 1);
1171 $resultDirectoryGroup = filegroup($directory);
1172 t3lib_div::rmdir($directory);
1173
1174 // Test if everything was ok
1175 $this->assertTrue($fixPermissionsResult);
1176 $this->assertEquals($resultDirectoryPermissions, '2770');
1177 $this->assertEquals($resultDirectoryGroup, posix_getegid());
1178 }
1179
1180 /**
1181 * Checks if t3lib_div::fixPermissions() correctly sets permissions to hidden directory
1182 * This test assumes directory 'PATH_site'/typo3temp exists
1183 * This test is not available on windows OS
1184 *
1185 * @test
1186 * @see t3lib_div::fixPermissions()
1187 */
1188 public function checkFixPermissionsCorrectlySetsPermissionsToHiddenDirectory() {
1189 if (TYPO3_OS == 'WIN') {
1190 $this->markTestSkipped('fixPermissions() tests not available on Windows');
1191 }
1192
1193 // Create and prepare test directory
1194 $directory = PATH_site . 'typo3temp/' . uniqid('.test_');
1195 t3lib_div::mkdir($directory);
1196 chmod($directory, 1551);
1197
1198 // Set target permissions and run method
1199 $GLOBALS['TYPO3_CONF_VARS']['BE']['folderCreateMask'] = '2770';
1200 $GLOBALS['TYPO3_CONF_VARS']['BE']['createGroup'] = posix_getegid();
1201 $fixPermissionsResult = t3lib_div::fixPermissions($directory);
1202
1203 // Get actual permissions and clean up
1204 clearstatcache();
1205 $resultDirectoryPermissions = substr(decoct(fileperms($directory)), 1);
1206 $resultDirectoryGroup = filegroup($directory);
1207 t3lib_div::rmdir($directory);
1208
1209 // Test if everything was ok
1210 $this->assertTrue($fixPermissionsResult);
1211 $this->assertEquals($resultDirectoryPermissions, '2770');
1212 $this->assertEquals($resultDirectoryGroup, posix_getegid());
1213 }
1214
1215 /**
1216 * Checks if t3lib_div::fixPermissions() correctly sets permissions recursivly
1217 * This test assumes directory 'PATH_site'/typo3temp exists
1218 * This test is not available on windows OS
1219 *
1220 * @test
1221 * @see t3lib_div::fixPermissions()
1222 */
1223 public function checkFixPermissionsCorrectlySetsPermissionsRecursive() {
1224 if (TYPO3_OS == 'WIN') {
1225 $this->markTestSkipped('fixPermissions() tests not available on Windows');
1226 }
1227
1228 // Create and prepare test directory and file structure
1229 $baseDirectory = PATH_site . 'typo3temp/' . uniqid('test_');
1230 t3lib_div::mkdir($baseDirectory);
1231 chmod($baseDirectory, 1751);
1232 t3lib_div::writeFileToTypo3tempDir($baseDirectory . '/file', '42');
1233 chmod($baseDirectory . '/file', 0742);
1234 t3lib_div::mkdir($baseDirectory . '/foo');
1235 chmod($baseDirectory . '/foo', 1751);
1236 t3lib_div::writeFileToTypo3tempDir($baseDirectory . '/foo/file', '42');
1237 chmod($baseDirectory . '/foo/file', 0742);
1238 t3lib_div::mkdir($baseDirectory . '/.bar');
1239 chmod($baseDirectory . '/.bar', 1751);
1240 // Use this if writeFileToTypo3tempDir is fixed to create hidden files in subdirectories
1241 // t3lib_div::writeFileToTypo3tempDir($baseDirectory . '/.bar/.file', '42');
1242 // t3lib_div::writeFileToTypo3tempDir($baseDirectory . '/.bar/..file2', '42');
1243 touch($baseDirectory . '/.bar/.file', '42');
1244 chmod($baseDirectory . '/.bar/.file', 0742);
1245 touch($baseDirectory . '/.bar/..file2', '42');
1246 chmod($baseDirectory . '/.bar/..file2', 0742);
1247
1248 // Set target permissions and run method
1249 $GLOBALS['TYPO3_CONF_VARS']['BE']['fileCreateMask'] = '0660';
1250 $GLOBALS['TYPO3_CONF_VARS']['BE']['folderCreateMask'] = '2770';
1251 $GLOBALS['TYPO3_CONF_VARS']['BE']['createGroup'] = posix_getegid();
1252 $fixPermissionsResult = t3lib_div::fixPermissions($baseDirectory, TRUE);
1253
1254 // Get actual permissions
1255 clearstatcache();
1256 $resultBaseDirectoryPermissions = substr(decoct(fileperms($baseDirectory)), 1);
1257 $resultBaseDirectoryGroup = filegroup($baseDirectory);
1258 $resultBaseFilePermissions = substr(decoct(fileperms($baseDirectory . '/file')), 2);
1259 $resultBaseFileGroup = filegroup($baseDirectory . '/file');
1260 $resultFooDirectoryPermissions = substr(decoct(fileperms($baseDirectory . '/foo')), 1);
1261 $resultFooDirectoryGroup = filegroup($baseDirectory . '/foo');
1262 $resultFooFilePermissions = substr(decoct(fileperms($baseDirectory . '/foo/file')), 2);
1263 $resultFooFileGroup = filegroup($baseDirectory . '/foo/file');
1264 $resultBarDirectoryPermissions = substr(decoct(fileperms($baseDirectory . '/.bar')), 1);
1265 $resultBarDirectoryGroup = filegroup($baseDirectory . '/.bar');
1266 $resultBarFilePermissions = substr(decoct(fileperms($baseDirectory . '/.bar/.file')), 2);
1267 $resultBarFileGroup = filegroup($baseDirectory . '/.bar/.file');
1268 $resultBarFile2Permissions = substr(decoct(fileperms($baseDirectory . '/.bar/..file2')), 2);
1269 $resultBarFile2Group = filegroup($baseDirectory . '/.bar/..file2');
1270
1271 // Clean up
1272 unlink($baseDirectory . '/file');
1273 unlink($baseDirectory . '/foo/file');
1274 unlink($baseDirectory . '/.bar/.file');
1275 unlink($baseDirectory . '/.bar/..file2');
1276 t3lib_div::rmdir($baseDirectory . '/foo');
1277 t3lib_div::rmdir($baseDirectory . '/.bar');
1278 t3lib_div::rmdir($baseDirectory);
1279
1280 // Test if everything was ok
1281 $this->assertTrue($fixPermissionsResult);
1282 $this->assertEquals($resultBaseDirectoryPermissions, '2770');
1283 $this->assertEquals($resultBaseDirectoryGroup, posix_getegid());
1284 $this->assertEquals($resultBaseFilePermissions, '0660');
1285 $this->assertEquals($resultBaseFileGroup, posix_getegid());
1286 $this->assertEquals($resultFooDirectoryPermissions, '2770');
1287 $this->assertEquals($resultFooDirectoryGroup, posix_getegid());
1288 $this->assertEquals($resultFooFilePermissions, '0660');
1289 $this->assertEquals($resultFooFileGroup, posix_getegid());
1290 $this->assertEquals($resultBarDirectoryPermissions, '2770');
1291 $this->assertEquals($resultBarDirectoryGroup, posix_getegid());
1292 $this->assertEquals($resultBarFilePermissions, '0660');
1293 $this->assertEquals($resultBarFileGroup, posix_getegid());
1294 $this->assertEquals($resultBarFile2Permissions, '0660');
1295 $this->assertEquals($resultBarFile2Group, posix_getegid());
1296 }
1297
1298 /**
1299 * Checks if t3lib_div::fixPermissions() does not fix permissions on not allowed path
1300 * This test assumes directory 'PATH_site'/typo3temp exists
1301 * This test is not available on windows OS
1302 *
1303 * @test
1304 * @see t3lib_div::fixPermissions()
1305 */
1306 public function checkFixPermissionsDoesNotSetPermissionsToNotAllowedPath() {
1307 if (TYPO3_OS == 'WIN') {
1308 $this->markTestSkipped('fixPermissions() tests not available on Windows');
1309 }
1310
1311 // Create and prepare test file
1312 $filename = PATH_site . 'typo3temp/../typo3temp/' . uniqid('test_');
1313 touch($filename);
1314 chmod($filename, 0742);
1315
1316 // Set target permissions and run method
1317 $GLOBALS['TYPO3_CONF_VARS']['BE']['fileCreateMask'] = '0660';
1318 $fixPermissionsResult = t3lib_div::fixPermissions($filename);
1319
1320 // Get actual permissions and clean up
1321 clearstatcache();
1322 $resultFilePermissions = substr(decoct(fileperms($filename)), 2);
1323 unlink($filename);
1324
1325 // Test if everything was ok
1326 $this->assertFalse($fixPermissionsResult);
1327 $this->assertEquals($resultFilePermissions, '0742');
1328 }
1329
1330 /**
1331 * Checks if t3lib_div::mkdir() correctly creates a directory
1332 * This test assumes directory 'PATH_site'/typo3temp exists
1333 *
1334 * @test
1335 * @see t3lib_div::mkdir()
1336 */
1337 public function checkMkdirCorrectlyCreatesDirectory() {
1338 $directory = PATH_site . 'typo3temp/' . uniqid('test_');
1339 $mkdirResult = t3lib_div::mkdir($directory);
1340 $directoryCreated = is_dir($directory);
1341 t3lib_div::rmdir($directory);
1342 $this->assertTrue($mkdirResult);
1343 $this->assertTrue($directoryCreated);
1344 }
1345
1346 /**
1347 * Checks if t3lib_div::mkdir() correctly creates a hidden directory
1348 * This test assumes directory 'PATH_site'/typo3temp exists
1349 *
1350 * @test
1351 * @see t3lib_div::mkdir()
1352 */
1353 public function checkMkdirCorrectlyCreatesHiddenDirectory() {
1354 $directory = PATH_site . 'typo3temp/' . uniqid('.test_');
1355 $mkdirResult = t3lib_div::mkdir($directory);
1356 $directoryCreated = is_dir($directory);
1357 t3lib_div::rmdir($directory);
1358 $this->assertTrue($mkdirResult);
1359 $this->assertTrue($directoryCreated);
1360 }
1361
1362 /**
1363 * Checks if t3lib_div::mkdir() correctly creates a directory with trailing slash
1364 * This test assumes directory 'PATH_site'/typo3temp exists
1365 *
1366 * @test
1367 * @see t3lib_div::mkdir()
1368 */
1369 public function checkMkdirCorrectlyCreatesDirectoryWithTrailingSlash() {
1370 $directory = PATH_site . 'typo3temp/' . uniqid('test_');
1371 $mkdirResult = t3lib_div::mkdir($directory);
1372 $directoryCreated = is_dir($directory);
1373 t3lib_div::rmdir($directory);
1374 $this->assertTrue($mkdirResult);
1375 $this->assertTrue($directoryCreated);
1376 }
1377 }
1378 ?>