‪TYPO3CMS  9.5
GeneralUtilityTest.php
Go to the documentation of this file.
1 <?php
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
16 
17 use org\bovigo\vfs\vfsStream;
18 use org\bovigo\vfs\vfsStreamDirectory;
19 use org\bovigo\vfs\vfsStreamWrapper;
20 use Prophecy\Argument;
21 use Psr\Http\Message\ResponseInterface;
22 use Psr\Http\Message\StreamInterface;
23 use Psr\Log\LoggerInterface;
29 use TYPO3\CMS\Core\Package\PackageManager;
42 use TYPO3\TestingFramework\Core\FileStreamWrapper;
43 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
44 
48 class ‪GeneralUtilityTest extends UnitTestCase
49 {
50  const ‪NO_FIX_PERMISSIONS_ON_WINDOWS = 'fixPermissions() not available on Windows (method does nothing)';
51 
55  protected ‪$resetSingletonInstances = true;
56 
60  protected ‪$backupEnvironment = true;
61 
65  protected ‪$backupPackageManager;
66 
70  protected function ‪setUp()
71  {
72  parent::setUp();
75  ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['trustedHostsPattern'] = ‪GeneralUtility::ENV_TRUSTED_HOSTS_PATTERN_ALLOW_ALL;
77  }
78 
82  protected function ‪tearDown()
83  {
84  GeneralUtility::flushInternalRuntimeCaches();
85  if ($this->backupPackageManager) {
87  }
88  parent::tearDown();
89  }
90 
97  public function ‪isConnected()
98  {
99  $isConnected = false;
100  $connected = @fsockopen('typo3.org', 80);
101  if ($connected) {
102  $isConnected = true;
103  fclose($connected);
104  }
105  return $isConnected;
106  }
107 
115  protected function ‪getVirtualTestDir($prefix = 'root_')
116  {
117  $root = vfsStream::setup();
118  $path = $root->url() . '/typo3temp/var/tests/' . $this->getUniqueId($prefix);
119  GeneralUtility::mkdir_deep($path);
120  return $path;
121  }
122 
124  // Tests concerning _GP
126 
130  public function ‪canRetrieveValueWithGP($key, $get, $post, $expected)
131  {
132  $_GET = $get;
133  $_POST = $post;
134  $this->assertSame($expected, GeneralUtility::_GP($key));
135  }
136 
143  public function ‪gpDataProvider()
144  {
145  return [
146  'No key parameter' => [null, [], [], null],
147  'Key not found' => ['cake', [], [], null],
148  'Value only in GET' => ['cake', ['cake' => 'li\\e'], [], 'li\\e'],
149  'Value only in POST' => ['cake', [], ['cake' => 'l\\ie'], 'l\\ie'],
150  'Value from POST preferred over GET' => ['cake', ['cake' => 'is a'], ['cake' => '\\lie'], '\\lie'],
151  'Value can be an array' => [
152  'cake',
153  ['cake' => ['is a' => 'l\\ie']],
154  [],
155  ['is a' => 'l\\ie']
156  ]
157  ];
158  }
159 
161  // Tests concerning _GPmerged
163 
167  public function ‪gpMergedWillMergeArraysFromGetAndPost($get, $post, $expected)
168  {
169  $_POST = $post;
170  $_GET = $get;
171  $this->assertEquals($expected, GeneralUtility::_GPmerged('cake'));
172  }
173 
179  public function ‪gpMergedDataProvider()
180  {
181  $fullDataArray = ['cake' => ['a' => 'is a', 'b' => 'lie']];
182  $postPartData = ['cake' => ['b' => 'lie']];
183  $getPartData = ['cake' => ['a' => 'is a']];
184  $getPartDataModified = ['cake' => ['a' => 'is not a']];
185  return [
186  'Key doesn\' exist' => [['foo'], ['bar'], []],
187  'No POST data' => [$fullDataArray, [], $fullDataArray['cake']],
188  'No GET data' => [[], $fullDataArray, $fullDataArray['cake']],
189  'POST and GET are merged' => [$getPartData, $postPartData, $fullDataArray['cake']],
190  'POST is preferred over GET' => [$getPartDataModified, $fullDataArray, $fullDataArray['cake']]
191  ];
192  }
193 
195  // Tests concerning _GET / _POST
197 
203  public function ‪getAndPostDataProvider()
204  {
205  return [
206  'Requested input data doesn\'t exist' => ['cake', [], null],
207  'No key will return entire input data' => [null, ['cake' => 'l\\ie'], ['cake' => 'l\\ie']],
208  'Can retrieve specific input' => ['cake', ['cake' => 'l\\ie', 'foo'], 'l\\ie'],
209  'Can retrieve nested input data' => ['cake', ['cake' => ['is a' => 'l\\ie']], ['is a' => 'l\\ie']]
210  ];
211  }
212 
217  public function ‪canRetrieveGlobalInputsThroughGet($key, $get, $expected)
218  {
219  $_GET = $get;
220  $this->assertSame($expected, GeneralUtility::_GET($key));
221  }
222 
227  public function ‪canRetrieveGlobalInputsThroughPost($key, $post, $expected)
228  {
229  $_POST = $post;
230  $this->assertSame($expected, GeneralUtility::_POST($key));
231  }
232 
234  // Tests concerning cmpIPv4
236 
241  public static function ‪cmpIPv4DataProviderMatching()
242  {
243  return [
244  'host with full IP address' => ['127.0.0.1', '127.0.0.1'],
245  'host with two wildcards at the end' => ['127.0.0.1', '127.0.*.*'],
246  'host with wildcard at third octet' => ['127.0.0.1', '127.0.*.1'],
247  'host with wildcard at second octet' => ['127.0.0.1', '127.*.0.1'],
248  '/8 subnet' => ['127.0.0.1', '127.1.1.1/8'],
249  '/32 subnet (match only name)' => ['127.0.0.1', '127.0.0.1/32'],
250  '/30 subnet' => ['10.10.3.1', '10.10.3.3/30'],
251  'host with wildcard in list with IPv4/IPv6 addresses' => ['192.168.1.1', '127.0.0.1, 1234:5678::/126, 192.168.*'],
252  'host in list with IPv4/IPv6 addresses' => ['192.168.1.1', '::1, 1234:5678::/126, 192.168.1.1'],
253  ];
254  }
255 
260  public function ‪cmpIPv4ReturnsTrueForMatchingAddress($ip, $list)
261  {
262  $this->assertTrue(GeneralUtility::cmpIPv4($ip, $list));
263  }
264 
270  public static function ‪cmpIPv4DataProviderNotMatching()
271  {
272  return [
273  'single host' => ['127.0.0.1', '127.0.0.2'],
274  'single host with wildcard' => ['127.0.0.1', '127.*.1.1'],
275  'single host with /32 subnet mask' => ['127.0.0.1', '127.0.0.2/32'],
276  '/31 subnet' => ['127.0.0.1', '127.0.0.2/31'],
277  'list with IPv4/IPv6 addresses' => ['127.0.0.1', '10.0.2.3, 192.168.1.1, ::1'],
278  'list with only IPv6 addresses' => ['10.20.30.40', '::1, 1234:5678::/127']
279  ];
280  }
281 
286  public function ‪cmpIPv4ReturnsFalseForNotMatchingAddress($ip, $list)
287  {
288  $this->assertFalse(GeneralUtility::cmpIPv4($ip, $list));
289  }
290 
292  // Tests concerning cmpIPv6
294 
299  public static function ‪cmpIPv6DataProviderMatching()
300  {
301  return [
302  'empty address' => ['::', '::'],
303  'empty with netmask in list' => ['::', '::/0'],
304  'empty with netmask 0 and host-bits set in list' => ['::', '::123/0'],
305  'localhost' => ['::1', '::1'],
306  'localhost with leading zero blocks' => ['::1', '0:0::1'],
307  'host with submask /128' => ['::1', '0:0::1/128'],
308  '/16 subnet' => ['1234::1', '1234:5678::/16'],
309  '/126 subnet' => ['1234:5678::3', '1234:5678::/126'],
310  '/126 subnet with host-bits in list set' => ['1234:5678::3', '1234:5678::2/126'],
311  'list with IPv4/IPv6 addresses' => ['1234:5678::3', '::1, 127.0.0.1, 1234:5678::/126, 192.168.1.1']
312  ];
313  }
314 
319  public function ‪cmpIPv6ReturnsTrueForMatchingAddress($ip, $list)
320  {
321  $this->assertTrue(GeneralUtility::cmpIPv6($ip, $list));
322  }
323 
329  public static function ‪cmpIPv6DataProviderNotMatching()
330  {
331  return [
332  'empty against localhost' => ['::', '::1'],
333  'empty against localhost with /128 netmask' => ['::', '::1/128'],
334  'localhost against different host' => ['::1', '::2'],
335  'localhost against host with prior bits set' => ['::1', '::1:1'],
336  'host against different /17 subnet' => ['1234::1', '1234:f678::/17'],
337  'host against different /127 subnet' => ['1234:5678::3', '1234:5678::/127'],
338  'host against IPv4 address list' => ['1234:5678::3', '127.0.0.1, 192.168.1.1'],
339  'host against mixed list with IPv6 host in different subnet' => ['1234:5678::3', '::1, 1234:5678::/127']
340  ];
341  }
342 
347  public function ‪cmpIPv6ReturnsFalseForNotMatchingAddress($ip, $list)
348  {
349  $this->assertFalse(GeneralUtility::cmpIPv6($ip, $list));
350  }
351 
353  // Tests concerning IPv6Hex2Bin
355 
360  public static function ‪IPv6Hex2BinDataProviderCorrect()
361  {
362  return [
363  'empty 1' => ['::', str_pad('', 16, "\x00")],
364  'empty 2, already normalized' => ['0000:0000:0000:0000:0000:0000:0000:0000', str_pad('', 16, "\x00")],
365  'already normalized' => ['0102:0304:0000:0000:0000:0000:0506:0078', "\x01\x02\x03\x04" . str_pad('', 8, "\x00") . "\x05\x06\x00\x78"],
366  'expansion in middle 1' => ['1::2', "\x00\x01" . str_pad('', 12, "\x00") . "\x00\x02"],
367  'expansion in middle 2' => ['beef::fefa', "\xbe\xef" . str_pad('', 12, "\x00") . "\xfe\xfa"],
368  ];
369  }
370 
375  public function ‪IPv6Hex2BinCorrectlyConvertsAddresses($hex, $binary)
376  {
377  $this->assertTrue(GeneralUtility::IPv6Hex2Bin($hex) === $binary);
378  }
379 
381  // Tests concerning IPv6Bin2Hex
383 
388  public static function ‪IPv6Bin2HexDataProviderCorrect()
389  {
390  return [
391  'empty' => [str_pad('', 16, "\x00"), '::'],
392  'non-empty front' => ["\x01" . str_pad('', 15, "\x00"), '100::'],
393  'non-empty back' => [str_pad('', 15, "\x00") . "\x01", '::1'],
394  'normalized' => ["\x01\x02\x03\x04" . str_pad('', 8, "\x00") . "\x05\x06\x00\x78", '102:304::506:78'],
395  'expansion in middle 1' => ["\x00\x01" . str_pad('', 12, "\x00") . "\x00\x02", '1::2'],
396  'expansion in middle 2' => ["\xbe\xef" . str_pad('', 12, "\x00") . "\xfe\xfa", 'beef::fefa'],
397  ];
398  }
399 
404  public function ‪IPv6Bin2HexCorrectlyConvertsAddresses($binary, $hex)
405  {
406  $this->assertEquals(GeneralUtility::IPv6Bin2Hex($binary), $hex);
407  }
408 
410  // Tests concerning normalizeIPv6 / compressIPv6
412 
417  public static function ‪normalizeCompressIPv6DataProviderCorrect()
418  {
419  return [
420  'empty' => ['::', '0000:0000:0000:0000:0000:0000:0000:0000'],
421  'localhost' => ['::1', '0000:0000:0000:0000:0000:0000:0000:0001'],
422  'expansion in middle 1' => ['1::2', '0001:0000:0000:0000:0000:0000:0000:0002'],
423  'expansion in middle 2' => ['1:2::3', '0001:0002:0000:0000:0000:0000:0000:0003'],
424  'expansion in middle 3' => ['1::2:3', '0001:0000:0000:0000:0000:0000:0002:0003'],
425  'expansion in middle 4' => ['1:2::3:4:5', '0001:0002:0000:0000:0000:0003:0004:0005']
426  ];
427  }
428 
433  public function ‪normalizeIPv6CorrectlyNormalizesAddresses($compressed, $normalized)
434  {
435  $this->assertEquals($normalized, GeneralUtility::normalizeIPv6($compressed));
436  }
437 
442  public function ‪compressIPv6CorrectlyCompressesAdresses($compressed, $normalized)
443  {
444  $this->assertEquals($compressed, GeneralUtility::compressIPv6($normalized));
445  }
446 
451  {
452  if (strtolower(PHP_OS) === 'darwin') {
453  $this->markTestSkipped('This test does not work on OSX / Darwin OS.');
454  }
455  $this->assertEquals('::f0f', GeneralUtility::compressIPv6('0000:0000:0000:0000:0000:0000:0000:0f0f'));
456  }
457 
459  // Tests concerning validIP
461 
466  public static function ‪validIpDataProvider()
467  {
468  return [
469  '0.0.0.0' => ['0.0.0.0'],
470  'private IPv4 class C' => ['192.168.0.1'],
471  'private IPv4 class A' => ['10.0.13.1'],
472  'private IPv6' => ['fe80::daa2:5eff:fe8b:7dfb']
473  ];
474  }
475 
480  public function ‪validIpReturnsTrueForValidIp($ip)
481  {
482  $this->assertTrue(GeneralUtility::validIP($ip));
483  }
484 
490  public static function ‪invalidIpDataProvider()
491  {
492  return [
493  'null' => [null],
494  'zero' => [0],
495  'string' => ['test'],
496  'string empty' => [''],
497  'string NULL' => ['NULL'],
498  'out of bounds IPv4' => ['300.300.300.300'],
499  'dotted decimal notation with only two dots' => ['127.0.1']
500  ];
501  }
502 
507  public function ‪validIpReturnsFalseForInvalidIp($ip)
508  {
509  $this->assertFalse(GeneralUtility::validIP($ip));
510  }
511 
513  // Tests concerning cmpFQDN
515 
520  public static function ‪cmpFqdnValidDataProvider()
521  {
522  return [
523  'localhost should usually resolve, IPv4' => ['127.0.0.1', '*'],
524  'localhost should usually resolve, IPv6' => ['::1', '*'],
525  // other testcases with resolving not possible since it would
526  // require a working IPv4/IPv6-connectivity
527  'aaa.bbb.ccc.ddd.eee, full' => ['aaa.bbb.ccc.ddd.eee', 'aaa.bbb.ccc.ddd.eee'],
528  'aaa.bbb.ccc.ddd.eee, wildcard first' => ['aaa.bbb.ccc.ddd.eee', '*.ccc.ddd.eee'],
529  'aaa.bbb.ccc.ddd.eee, wildcard last' => ['aaa.bbb.ccc.ddd.eee', 'aaa.bbb.ccc.*'],
530  'aaa.bbb.ccc.ddd.eee, wildcard middle' => ['aaa.bbb.ccc.ddd.eee', 'aaa.*.eee'],
531  'list-matches, 1' => ['aaa.bbb.ccc.ddd.eee', 'xxx, yyy, zzz, aaa.*.eee'],
532  'list-matches, 2' => ['aaa.bbb.ccc.ddd.eee', '127:0:0:1,,aaa.*.eee,::1']
533  ];
534  }
535 
540  public function ‪cmpFqdnReturnsTrue($baseHost, $list)
541  {
542  $this->assertTrue(GeneralUtility::cmpFQDN($baseHost, $list));
543  }
544 
550  public static function ‪cmpFqdnInvalidDataProvider()
551  {
552  return [
553  'num-parts of hostname to check can only be less or equal than hostname, 1' => ['aaa.bbb.ccc.ddd.eee', 'aaa.bbb.ccc.ddd.eee.fff'],
554  'num-parts of hostname to check can only be less or equal than hostname, 2' => ['aaa.bbb.ccc.ddd.eee', 'aaa.*.bbb.ccc.ddd.eee']
555  ];
556  }
557 
562  public function ‪cmpFqdnReturnsFalse($baseHost, $list)
563  {
564  $this->assertFalse(GeneralUtility::cmpFQDN($baseHost, $list));
565  }
566 
568  // Tests concerning inList
570 
575  public function ‪inListForItemContainedReturnsTrue($haystack)
576  {
577  $this->assertTrue(GeneralUtility::inList($haystack, 'findme'));
578  }
579 
586  {
587  return [
588  'Element as second element of four items' => ['one,findme,three,four'],
589  'Element at beginning of list' => ['findme,one,two'],
590  'Element at end of list' => ['one,two,findme'],
591  'One item list' => ['findme']
592  ];
593  }
594 
600  public function ‪inListForItemNotContainedReturnsFalse($haystack)
601  {
602  $this->assertFalse(GeneralUtility::inList($haystack, 'findme'));
603  }
604 
611  {
612  return [
613  'Four item list' => ['one,two,three,four'],
614  'One item list' => ['one'],
615  'Empty list' => ['']
616  ];
617  }
618 
620  // Tests concerning rmFromList
622 
628  public function ‪rmFromListRemovesElementsFromCommaSeparatedList($initialList, $listWithElementRemoved)
629  {
630  $this->assertSame($listWithElementRemoved, GeneralUtility::rmFromList('removeme', $initialList));
631  }
632 
639  {
640  return [
641  'Element as second element of three' => ['one,removeme,two', 'one,two'],
642  'Element at beginning of list' => ['removeme,one,two', 'one,two'],
643  'Element at end of list' => ['one,two,removeme', 'one,two'],
644  'One item list' => ['removeme', ''],
645  'Element not contained in list' => ['one,two,three', 'one,two,three'],
646  'Empty element survives' => ['one,,three,,removeme', 'one,,three,'],
647  'Empty element survives at start' => [',removeme,three,removeme', ',three'],
648  'Empty element survives at end' => ['removeme,three,removeme,', 'three,'],
649  'Empty list' => ['', ''],
650  'List contains removeme multiple times' => ['removeme,notme,removeme,removeme', 'notme'],
651  'List contains removeme multiple times nothing else' => ['removeme,removeme,removeme', ''],
652  'List contains removeme multiple times nothing else 2x' => ['removeme,removeme', ''],
653  'List contains removeme multiple times nothing else 3x' => ['removeme,removeme,removeme', ''],
654  'List contains removeme multiple times nothing else 4x' => ['removeme,removeme,removeme,removeme', ''],
655  'List contains removeme multiple times nothing else 5x' => ['removeme,removeme,removeme,removeme,removeme', ''],
656  ];
657  }
658 
660  // Tests concerning expandList
662 
668  public function ‪expandListExpandsIntegerRanges($list, $expectation)
669  {
670  $this->assertSame($expectation, GeneralUtility::expandList($list));
671  }
672 
679  {
680  return [
681  'Expand for the same number' => ['1,2-2,7', '1,2,7'],
682  'Small range expand with parameters reversed ignores reversed items' => ['1,5-3,7', '1,7'],
683  'Small range expand' => ['1,3-5,7', '1,3,4,5,7'],
684  'Expand at beginning' => ['3-5,1,7', '3,4,5,1,7'],
685  'Expand at end' => ['1,7,3-5', '1,7,3,4,5'],
686  'Multiple small range expands' => ['1,3-5,7-10,12', '1,3,4,5,7,8,9,10,12'],
687  'One item list' => ['1-5', '1,2,3,4,5'],
688  'Nothing to expand' => ['1,2,3,4', '1,2,3,4'],
689  'Empty list' => ['', '']
690  ];
691  }
692 
697  {
698  $list = GeneralUtility::expandList('1-2000');
699  $this->assertSame(1000, count(explode(',', $list)));
700  }
701 
703  // Tests concerning uniqueList
705 
711  public function ‪uniqueListUnifiesCommaSeparatedList($initialList, $unifiedList)
712  {
713  $this->assertSame($unifiedList, GeneralUtility::uniqueList($initialList));
714  }
715 
722  {
723  return [
724  'List without duplicates' => ['one,two,three', 'one,two,three'],
725  'List with two consecutive duplicates' => ['one,two,two,three,three', 'one,two,three'],
726  'List with non-consecutive duplicates' => ['one,two,three,two,three', 'one,two,three'],
727  'One item list' => ['one', 'one'],
728  'Empty list' => ['', '']
729  ];
730  }
731 
733  // Tests concerning isFirstPartOfStr
735 
741  {
742  return [
743  'match first part of string' => ['hello world', 'hello'],
744  'match whole string' => ['hello', 'hello'],
745  'integer is part of string with same number' => ['24', 24],
746  'string is part of integer with same number' => [24, '24'],
747  'integer is part of string starting with same number' => ['24 beer please', 24]
748  ];
749  }
750 
755  public function ‪isFirstPartOfStrReturnsTrueForMatchingFirstPart($string, $part)
756  {
757  $this->assertTrue(GeneralUtility::isFirstPartOfStr($string, $part));
758  }
759 
766  {
767  return [
768  'no string match' => ['hello', 'bye'],
769  'no case sensitive string match' => ['hello world', 'Hello'],
770  'array is not part of string' => ['string', []],
771  'string is not part of array' => [[], 'string'],
772  'NULL is not part of string' => ['string', null],
773  'string is not part of NULL' => [null, 'string'],
774  'NULL is not part of array' => [[], null],
775  'array is not part of NULL' => [null, []],
776  'empty string is not part of empty string' => ['', ''],
777  'NULL is not part of empty string' => ['', null],
778  'false is not part of empty string' => ['', false],
779  'empty string is not part of NULL' => [null, ''],
780  'empty string is not part of false' => [false, ''],
781  'empty string is not part of zero integer' => [0, ''],
782  'zero integer is not part of NULL' => [null, 0],
783  'zero integer is not part of empty string' => ['', 0]
784  ];
785  }
786 
791  public function ‪isFirstPartOfStrReturnsFalseForNotMatchingFirstPart($string, $part)
792  {
793  $this->assertFalse(GeneralUtility::isFirstPartOfStr($string, $part));
794  }
795 
797  // Tests concerning formatSize
799 
803  public function ‪formatSizeTranslatesBytesToHigherOrderRepresentation($size, $labels, $base, $expected)
804  {
805  $this->assertEquals($expected, GeneralUtility::formatSize($size, $labels, $base));
806  }
807 
813  public function ‪formatSizeDataProvider()
814  {
815  return [
816  'IEC Bytes stay bytes (min)' => [1, '', 0, '1 '],
817  'IEC Bytes stay bytes (max)' => [921, '', 0, '921 '],
818  'IEC Kilobytes are used (min)' => [922, '', 0, '0.90 Ki'],
819  'IEC Kilobytes are used (max)' => [943718, '', 0, '922 Ki'],
820  'IEC Megabytes are used (min)' => [943719, '', 0, '0.90 Mi'],
821  'IEC Megabytes are used (max)' => [966367641, '', 0, '922 Mi'],
822  'IEC Gigabytes are used (min)' => [966367642, '', 0, '0.90 Gi'],
823  'IEC Gigabytes are used (max)' => [989560464998, '', 0, '922 Gi'],
824  'IEC Decimal is omitted for large kilobytes' => [31080, '', 0, '30 Ki'],
825  'IEC Decimal is omitted for large megabytes' => [31458000, '', 0, '30 Mi'],
826  'IEC Decimal is omitted for large gigabytes' => [32212254720, '', 0, '30 Gi'],
827  'SI Bytes stay bytes (min)' => [1, 'si', 0, '1 '],
828  'SI Bytes stay bytes (max)' => [899, 'si', 0, '899 '],
829  'SI Kilobytes are used (min)' => [901, 'si', 0, '0.90 k'],
830  'SI Kilobytes are used (max)' => [900000, 'si', 0, '900 k'],
831  'SI Megabytes are used (min)' => [900001, 'si', 0, '0.90 M'],
832  'SI Megabytes are used (max)' => [900000000, 'si', 0, '900 M'],
833  'SI Gigabytes are used (min)' => [900000001, 'si', 0, '0.90 G'],
834  'SI Gigabytes are used (max)' => [900000000000, 'si', 0, '900 G'],
835  'SI Decimal is omitted for large kilobytes' => [30000, 'si', 0, '30 k'],
836  'SI Decimal is omitted for large megabytes' => [30000000, 'si', 0, '30 M'],
837  'SI Decimal is omitted for large gigabytes' => [30000000000, 'si', 0, '30 G'],
838  'Label for bytes can be exchanged (binary unit)' => [1, ' Foo|||', 0, '1 Foo'],
839  'Label for kilobytes can be exchanged (binary unit)' => [1024, '| Foo||', 0, '1.00 Foo'],
840  'Label for megabyes can be exchanged (binary unit)' => [1048576, '|| Foo|', 0, '1.00 Foo'],
841  'Label for gigabytes can be exchanged (binary unit)' => [1073741824, '||| Foo', 0, '1.00 Foo'],
842  'Label for bytes can be exchanged (decimal unit)' => [1, ' Foo|||', 1000, '1 Foo'],
843  'Label for kilobytes can be exchanged (decimal unit)' => [1000, '| Foo||', 1000, '1.00 Foo'],
844  'Label for megabyes can be exchanged (decimal unit)' => [1000000, '|| Foo|', 1000, '1.00 Foo'],
845  'Label for gigabytes can be exchanged (decimal unit)' => [1000000000, '||| Foo', 1000, '1.00 Foo'],
846  'IEC Base is ignored' => [1024, 'iec', 1000, '1.00 Ki'],
847  'SI Base is ignored' => [1000, 'si', 1024, '1.00 k'],
848  'Use binary base for unexpected base' => [2048, '| Bar||', 512, '2.00 Bar']
849  ];
850  }
851 
853  // Tests concerning splitCalc
855 
860  public function ‪splitCalcDataProvider()
861  {
862  return [
863  'empty string returns empty array' => [
864  [],
865  ''
866  ],
867  'number without operator returns array with plus and number' => [
868  [['+', '42']],
869  '42'
870  ],
871  'two numbers with asterisk return first number with plus and second number with asterisk' => [
872  [['+', '42'], ['*', '31']],
873  '42 * 31'
874  ]
875  ];
876  }
877 
882  public function ‪splitCalcCorrectlySplitsExpression(array $expected, string $expression): void
883  {
884  $this->assertSame($expected, GeneralUtility::splitCalc($expression, '+-*/'));
885  }
886 
888  // Tests concerning htmlspecialchars_decode
890 
894  {
895  $string = '<typo3 version="6.0">&nbsp;</typo3>';
896  $encoded = htmlspecialchars($string);
897  $decoded = htmlspecialchars_decode($encoded);
898  $this->assertEquals($string, $decoded);
899  }
900 
902  // Tests concerning validEmail
904 
909  public function ‪validEmailValidDataProvider()
910  {
911  return [
912  'short mail address' => ['a@b.c'],
913  'simple mail address' => ['test@example.com'],
914  'uppercase characters' => ['QWERTYUIOPASDFGHJKLZXCVBNM@QWERTYUIOPASDFGHJKLZXCVBNM.NET'],
915  'equal sign in local part' => ['test=mail@example.com'],
916  'dash in local part' => ['test-mail@example.com'],
917  'plus in local part' => ['test+mail@example.com'],
918  'question mark in local part' => ['test?mail@example.com'],
919  'slash in local part' => ['foo/bar@example.com'],
920  'hash in local part' => ['foo#bar@example.com'],
921  'dot in local part' => ['firstname.lastname@employee.2something.com'],
922  'dash as local part' => ['-@foo.com'],
923  'umlauts in domain part' => ['foo@äöüfoo.com']
924  ];
925  }
926 
931  public function ‪validEmailReturnsTrueForValidMailAddress($address)
932  {
933  $this->assertTrue(GeneralUtility::validEmail($address));
934  }
935 
941  public function ‪validEmailInvalidDataProvider()
942  {
943  return [
944  'empty string' => [''],
945  'empty array' => [[]],
946  'integer' => [42],
947  'float' => [42.23],
948  'array' => [['foo']],
949  'object' => [new \stdClass()],
950  '@ sign only' => ['@'],
951  'string longer than 320 characters' => [str_repeat('0123456789', 33)],
952  'duplicate @' => ['test@@example.com'],
953  'duplicate @ combined with further special characters in local part' => ['test!.!@#$%^&*@example.com'],
954  'opening parenthesis in local part' => ['foo(bar@example.com'],
955  'closing parenthesis in local part' => ['foo)bar@example.com'],
956  'opening square bracket in local part' => ['foo[bar@example.com'],
957  'closing square bracket as local part' => [']@example.com'],
958  'top level domain only' => ['test@com'],
959  'dash as second level domain' => ['foo@-.com'],
960  'domain part starting with dash' => ['foo@-foo.com'],
961  'domain part ending with dash' => ['foo@foo-.com'],
962  'number as top level domain' => ['foo@bar.123'],
963  'dot at beginning of domain part' => ['test@.com'],
964  'local part ends with dot' => ['e.x.a.m.p.l.e.@example.com'],
965  'umlauts in local part' => ['äöüfoo@bar.com'],
966  'trailing whitespace' => ['test@example.com '],
967  'trailing carriage return' => ['test@example.com' . CR],
968  'trailing linefeed' => ['test@example.com' . LF],
969  'trailing carriage return linefeed' => ['test@example.com' . CRLF],
970  'trailing tab' => ['test@example.com' . "\t"],
971  'prohibited input characters' => ['“mailto:test@example.com”'],
972  ];
973  }
974 
979  public function ‪validEmailReturnsFalseForInvalidMailAddress($address)
980  {
981  $this->assertFalse(GeneralUtility::validEmail($address));
982  }
983 
985  // Tests concerning intExplode
987 
990  public function ‪intExplodeConvertsStringsToInteger()
991  {
992  $testString = '1,foo,2';
993  $expectedArray = [1, 0, 2];
994  $actualArray = GeneralUtility::intExplode(',', $testString);
995  $this->assertEquals($expectedArray, $actualArray);
996  }
997 
999  // Tests concerning implodeArrayForUrl / explodeUrl2Array
1001 
1006  public function ‪implodeArrayForUrlDataProvider()
1007  {
1008  $valueArray = ['one' => '√', 'two' => 2];
1009  return [
1010  'Empty input' => ['foo', [], ''],
1011  'String parameters' => ['foo', $valueArray, '&foo[one]=%E2%88%9A&foo[two]=2'],
1012  'Nested array parameters' => ['foo', [$valueArray], '&foo[0][one]=%E2%88%9A&foo[0][two]=2'],
1013  'Keep blank parameters' => ['foo', ['one' => '√', ''], '&foo[one]=%E2%88%9A&foo[0]=']
1014  ];
1015  }
1016 
1021  public function ‪implodeArrayForUrlBuildsValidParameterString($name, $input, $expected)
1022  {
1023  $this->assertSame($expected, GeneralUtility::implodeArrayForUrl($name, $input));
1024  }
1025 
1030  {
1031  $input = ['one' => '√', ''];
1032  $expected = '&foo[one]=%E2%88%9A';
1033  $this->assertSame($expected, GeneralUtility::implodeArrayForUrl('foo', $input, '', true));
1034  }
1035 
1040  {
1041  $input = ['one' => '√', ''];
1042  $expected = '&foo%5Bone%5D=%E2%88%9A&foo%5B0%5D=';
1043  $this->assertSame($expected, GeneralUtility::implodeArrayForUrl('foo', $input, '', false, true));
1044  }
1045 
1050  public function ‪explodeUrl2ArrayTransformsParameterStringToFlatArray($input, $expected)
1051  {
1052  $this->assertEquals($expected, GeneralUtility::explodeUrl2Array($input));
1053  }
1054 
1060  public function ‪explodeUrl2ArrayDataProvider()
1061  {
1062  return [
1063  'Empty string' => ['', []],
1064  'Simple parameter string' => ['&one=%E2%88%9A&two=2', ['one' => '√', 'two' => 2]],
1065  'Nested parameter string' => ['&foo[one]=%E2%88%9A&two=2', ['foo[one]' => '√', 'two' => 2]]
1066  ];
1067  }
1068 
1070  // Tests concerning compileSelectedGetVarsFromArray
1076  {
1077  $filter = 'foo,bar';
1078  $getArray = ['foo' => 1, 'cake' => 'lie'];
1079  $expected = ['foo' => 1];
1080  $result = GeneralUtility::compileSelectedGetVarsFromArray($filter, $getArray, false);
1081  $this->assertSame($expected, $result);
1082  }
1083 
1088  {
1089  $_GET['bar'] = '2';
1090  $filter = 'foo,bar';
1091  $getArray = ['foo' => 1, 'cake' => 'lie'];
1092  $expected = ['foo' => 1, 'bar' => '2'];
1093  $result = GeneralUtility::compileSelectedGetVarsFromArray($filter, $getArray, true);
1094  $this->assertSame($expected, $result);
1095  }
1096 
1098  // Tests concerning revExplode
1100 
1104  public function ‪revExplodeDataProvider()
1105  {
1106  return [
1107  'limit 0 should return unexploded string' => [
1108  ':',
1109  'my:words:here',
1110  0,
1111  ['my:words:here']
1112  ],
1113  'limit 1 should return unexploded string' => [
1114  ':',
1115  'my:words:here',
1116  1,
1117  ['my:words:here']
1118  ],
1119  'limit 2 should return two pieces' => [
1120  ':',
1121  'my:words:here',
1122  2,
1123  ['my:words', 'here']
1124  ],
1125  'limit 3 should return unexploded string' => [
1126  ':',
1127  'my:words:here',
1128  3,
1129  ['my', 'words', 'here']
1130  ],
1131  'limit 0 should return unexploded string if no delimiter is contained' => [
1132  ':',
1133  'mywordshere',
1134  0,
1135  ['mywordshere']
1136  ],
1137  'limit 1 should return unexploded string if no delimiter is contained' => [
1138  ':',
1139  'mywordshere',
1140  1,
1141  ['mywordshere']
1142  ],
1143  'limit 2 should return unexploded string if no delimiter is contained' => [
1144  ':',
1145  'mywordshere',
1146  2,
1147  ['mywordshere']
1148  ],
1149  'limit 3 should return unexploded string if no delimiter is contained' => [
1150  ':',
1151  'mywordshere',
1152  3,
1153  ['mywordshere']
1154  ],
1155  'multi character delimiter is handled properly with limit 2' => [
1156  '[]',
1157  'a[b][c][d]',
1158  2,
1159  ['a[b][c', 'd]']
1160  ],
1161  'multi character delimiter is handled properly with limit 3' => [
1162  '[]',
1163  'a[b][c][d]',
1164  3,
1165  ['a[b', 'c', 'd]']
1166  ],
1167  ];
1168  }
1169 
1174  public function ‪revExplodeCorrectlyExplodesStringForGivenPartsCount($delimiter, $testString, $count, $expectedArray)
1175  {
1176  $actualArray = GeneralUtility::revExplode($delimiter, $testString, $count);
1177  $this->assertEquals($expectedArray, $actualArray);
1178  }
1179 
1184  {
1185  $testString = 'even:more:of:my:words:here';
1186  $expectedArray = ['even:more:of:my', 'words', 'here'];
1187  $actualArray = GeneralUtility::revExplode(':', $testString, 3);
1188  $this->assertEquals($expectedArray, $actualArray);
1189  }
1190 
1192  // Tests concerning trimExplode
1194 
1204  public function ‪trimExplodeReturnsCorrectResult($delimiter, $testString, $removeEmpty, $limit, $expectedResult)
1205  {
1206  $this->assertSame($expectedResult, GeneralUtility::trimExplode($delimiter, $testString, $removeEmpty, $limit));
1207  }
1208 
1213  {
1214  return [
1215  'spaces at element start and end' => [
1216  ',',
1217  ' a , b , c ,d ,, e,f,',
1218  false,
1219  0,
1220  ['a', 'b', 'c', 'd', '', 'e', 'f', '']
1221  ],
1222  'removes newline' => [
1223  ',',
1224  ' a , b , ' . LF . ' ,d ,, e,f,',
1225  true,
1226  0,
1227  ['a', 'b', 'd', 'e', 'f']
1228  ],
1229  'removes empty elements' => [
1230  ',',
1231  'a , b , c , ,d ,, ,e,f,',
1232  true,
1233  0,
1234  ['a', 'b', 'c', 'd', 'e', 'f']
1235  ],
1236  'keeps remaining results with empty items after reaching limit with positive parameter' => [
1237  ',',
1238  ' a , b , c , , d,, ,e ',
1239  false,
1240  3,
1241  ['a', 'b', 'c , , d,, ,e']
1242  ],
1243  'keeps remaining results without empty items after reaching limit with positive parameter' => [
1244  ',',
1245  ' a , b , c , , d,, ,e ',
1246  true,
1247  3,
1248  ['a', 'b', 'c , d,e']
1249  ],
1250  'keeps remaining results with empty items after reaching limit with negative parameter' => [
1251  ',',
1252  ' a , b , c , d, ,e, f , , ',
1253  false,
1254  -3,
1255  ['a', 'b', 'c', 'd', '', 'e']
1256  ],
1257  'keeps remaining results without empty items after reaching limit with negative parameter' => [
1258  ',',
1259  ' a , b , c , d, ,e, f , , ',
1260  true,
1261  -3,
1262  ['a', 'b', 'c']
1263  ],
1264  'returns exact results without reaching limit with positive parameter' => [
1265  ',',
1266  ' a , b , , c , , , ',
1267  true,
1268  4,
1269  ['a', 'b', 'c']
1270  ],
1271  'keeps zero as string' => [
1272  ',',
1273  'a , b , c , ,d ,, ,e,f, 0 ,',
1274  true,
1275  0,
1276  ['a', 'b', 'c', 'd', 'e', 'f', '0']
1277  ],
1278  'keeps whitespace inside elements' => [
1279  ',',
1280  'a , b , c , ,d ,, ,e,f, g h ,',
1281  true,
1282  0,
1283  ['a', 'b', 'c', 'd', 'e', 'f', 'g h']
1284  ],
1285  'can use internal regex delimiter as explode delimiter' => [
1286  '/',
1287  'a / b / c / /d // /e/f/ g h /',
1288  true,
1289  0,
1290  ['a', 'b', 'c', 'd', 'e', 'f', 'g h']
1291  ],
1292  'can use whitespaces as delimiter' => [
1293  ' ',
1294  '* * * * *',
1295  true,
1296  0,
1297  ['*', '*', '*', '*', '*']
1298  ],
1299  'can use words as delimiter' => [
1300  'All',
1301  'HelloAllTogether',
1302  true,
1303  0,
1304  ['Hello', 'Together']
1305  ],
1306  'can use word with appended and prepended spaces as delimiter' => [
1307  ' all ',
1308  'Hello all together',
1309  true,
1310  0,
1311  ['Hello', 'together']
1312  ],
1313  'can use word with appended and prepended spaces as delimiter and do not remove empty' => [
1314  ' all ',
1315  'Hello all together all there all all are all none',
1316  false,
1317  0,
1318  ['Hello', 'together', 'there', '', 'are', 'none']
1319  ],
1320  'can use word with appended and prepended spaces as delimiter, do not remove empty and limit' => [
1321  ' all ',
1322  'Hello all together all there all all are all none',
1323  false,
1324  5,
1325  ['Hello', 'together', 'there', '', 'are all none']
1326  ],
1327  'can use word with appended and prepended spaces as delimiter, do not remove empty, limit and multiple delimiter in last' => [
1328  ' all ',
1329  'Hello all together all there all all are all none',
1330  false,
1331  4,
1332  ['Hello', 'together', 'there', 'all are all none']
1333  ],
1334  'can use word with appended and prepended spaces as delimiter, remove empty and limit' => [
1335  ' all ',
1336  'Hello all together all there all all are all none',
1337  true,
1338  4,
1339  ['Hello', 'together', 'there', 'are all none']
1340  ],
1341  'can use word with appended and prepended spaces as delimiter, remove empty and limit and multiple delimiter in last' => [
1342  ' all ',
1343  'Hello all together all there all all are all none',
1344  true,
1345  5,
1346  ['Hello', 'together', 'there', 'are' , 'none']
1347  ],
1348  'can use words as delimiter and do not remove empty' => [
1349  'all there',
1350  'Helloall theretogether all there all there are all there none',
1351  false,
1352  0,
1353  ['Hello', 'together', '', 'are', 'none']
1354  ],
1355  'can use words as delimiter, do not remove empty and limit' => [
1356  'all there',
1357  'Helloall theretogether all there all there are all there none',
1358  false,
1359  4,
1360  ['Hello', 'together', '', 'are all there none']
1361  ],
1362  'can use words as delimiter, do not remove empty, limit and multiple delimiter in last' => [
1363  'all there',
1364  'Helloall theretogether all there all there are all there none',
1365  false,
1366  3,
1367  ['Hello', 'together', 'all there are all there none']
1368  ],
1369  'can use words as delimiter, remove empty' => [
1370  'all there',
1371  'Helloall theretogether all there all there are all there none',
1372  true,
1373  0,
1374  ['Hello', 'together', 'are', 'none']
1375  ],
1376  'can use words as delimiter, remove empty and limit' => [
1377  'all there',
1378  'Helloall theretogether all there all there are all there none',
1379  true,
1380  3,
1381  ['Hello', 'together', 'are all there none']
1382  ],
1383  'can use words as delimiter, remove empty and limit and multiple delimiter in last' => [
1384  'all there',
1385  'Helloall theretogether all there all there are all there none',
1386  true,
1387  4,
1388  ['Hello', 'together', 'are' , 'none']
1389  ],
1390  'can use new line as delimiter' => [
1391  LF,
1392  "Hello\nall\ntogether",
1393  true,
1394  0,
1395  ['Hello', 'all', 'together']
1396  ],
1397  'works with whitespace separator' => [
1398  "\t",
1399  " a b \t c \t \t d \t e \t u j \t s",
1400  false,
1401  0,
1402  ['a b', 'c', '', 'd', 'e', 'u j', 's']
1403  ],
1404  'works with whitespace separator and limit' => [
1405  "\t",
1406  " a b \t c \t \t d \t e \t u j \t s",
1407  false,
1408  4,
1409  ['a b', 'c', '', "d \t e \t u j \t s"]
1410  ],
1411  'works with whitespace separator and remove empty' => [
1412  "\t",
1413  " a b \t c \t \t d \t e \t u j \t s",
1414  true,
1415  0,
1416  ['a b', 'c', 'd', 'e', 'u j', 's']
1417  ],
1418  'works with whitespace separator remove empty and limit' => [
1419  "\t",
1420  " a b \t c \t \t d \t e \t u j \t s",
1421  true,
1422  3,
1423  ['a b', 'c', "d \t e \t u j \t s"]
1424  ],
1425  ];
1426  }
1427 
1429  // Tests concerning getBytesFromSizeMeasurement
1431 
1437  {
1438  return [
1439  '100 kilo Bytes' => ['102400', '100k'],
1440  '100 mega Bytes' => ['104857600', '100m'],
1441  '100 giga Bytes' => ['107374182400', '100g']
1442  ];
1443  }
1444 
1449  public function ‪getBytesFromSizeMeasurementCalculatesCorrectByteValue($expected, $byteString)
1450  {
1451  $this->assertEquals($expected, GeneralUtility::getBytesFromSizeMeasurement($byteString));
1452  }
1453 
1455  // Tests concerning getIndpEnv
1461  {
1462  $this->assertTrue(strlen(GeneralUtility::getIndpEnv('TYPO3_SITE_PATH')) >= 1);
1463  }
1464 
1469  {
1472  true,
1473  false,
1478  ‪Environment::getBackendPath() . '/index.php',
1479  ‪Environment::isWindows() ? 'WINDOWS' : 'UNIX'
1480  );
1481  $result = GeneralUtility::getIndpEnv('TYPO3_SITE_PATH');
1482  $this->assertEquals('/', $result[0]);
1483  }
1484 
1490  {
1491  $result = GeneralUtility::getIndpEnv('TYPO3_SITE_PATH');
1492  $this->assertRegExp('/^[a-z]:\//i', $result);
1493  }
1494 
1499  {
1500  $result = GeneralUtility::getIndpEnv('TYPO3_SITE_PATH');
1501  $this->assertEquals('/', $result[strlen($result) - 1]);
1502  }
1503 
1507  public static function ‪hostnameAndPortDataProvider()
1508  {
1509  return [
1510  'localhost ipv4 without port' => ['127.0.0.1', '127.0.0.1', ''],
1511  'localhost ipv4 with port' => ['127.0.0.1:81', '127.0.0.1', '81'],
1512  'localhost ipv6 without port' => ['[::1]', '[::1]', ''],
1513  'localhost ipv6 with port' => ['[::1]:81', '[::1]', '81'],
1514  'ipv6 without port' => ['[2001:DB8::1]', '[2001:DB8::1]', ''],
1515  'ipv6 with port' => ['[2001:DB8::1]:81', '[2001:DB8::1]', '81'],
1516  'hostname without port' => ['lolli.did.this', 'lolli.did.this', ''],
1517  'hostname with port' => ['lolli.did.this:42', 'lolli.did.this', '42']
1518  ];
1519  }
1520 
1525  public function ‪getIndpEnvTypo3HostOnlyParsesHostnamesAndIpAdresses($httpHost, $expectedIp)
1526  {
1527  $_SERVER['HTTP_HOST'] = $httpHost;
1528  $this->assertEquals($expectedIp, GeneralUtility::getIndpEnv('TYPO3_HOST_ONLY'));
1529  }
1530 
1535  {
1536  unset(‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['trustedHostsPattern']);
1537  $this->assertFalse(‪GeneralUtilityFixture::isAllowedHostHeaderValue('evil.foo.bar'));
1538  }
1539 
1544  {
1545  return [
1546  'hostname without port matching' => ['lolli.did.this', '.*\.did\.this'],
1547  'other hostname without port matching' => ['helmut.did.this', '.*\.did\.this'],
1548  'two different hostnames without port matching 1st host' => ['helmut.is.secure', '(helmut\.is\.secure|lolli\.is\.secure)'],
1549  'two different hostnames without port matching 2nd host' => ['lolli.is.secure', '(helmut\.is\.secure|lolli\.is\.secure)'],
1550  'hostname with port matching' => ['lolli.did.this:42', '.*\.did\.this:42'],
1551  'hostnames are case insensitive 1' => ['lolli.DID.this:42', '.*\.did.this:42'],
1552  'hostnames are case insensitive 2' => ['lolli.did.this:42', '.*\.DID.this:42'],
1553  ];
1554  }
1555 
1560  {
1561  return [
1562  'hostname without port' => ['lolli.did.this', 'helmut\.did\.this'],
1563  'hostname with port, but port not allowed' => ['lolli.did.this:42', 'helmut\.did\.this'],
1564  'two different hostnames in pattern but host header starts with different value #1' => ['sub.helmut.is.secure', '(helmut\.is\.secure|lolli\.is\.secure)'],
1565  'two different hostnames in pattern but host header starts with different value #2' => ['sub.lolli.is.secure', '(helmut\.is\.secure|lolli\.is\.secure)'],
1566  'two different hostnames in pattern but host header ends with different value #1' => ['helmut.is.secure.tld', '(helmut\.is\.secure|lolli\.is\.secure)'],
1567  'two different hostnames in pattern but host header ends with different value #2' => ['lolli.is.secure.tld', '(helmut\.is\.secure|lolli\.is\.secure)'],
1568  ];
1569  }
1570 
1577  public function ‪isAllowedHostHeaderValueReturnsTrueIfHostValueMatches($httpHost, $hostNamePattern)
1578  {
1579  ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['trustedHostsPattern'] = $hostNamePattern;
1580  $this->assertTrue(‪GeneralUtilityFixture::isAllowedHostHeaderValue($httpHost));
1581  }
1582 
1589  public function ‪isAllowedHostHeaderValueReturnsFalseIfHostValueMatches($httpHost, $hostNamePattern)
1590  {
1591  ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['trustedHostsPattern'] = $hostNamePattern;
1593  }
1594 
1595  public function ‪serverNamePatternDataProvider()
1596  {
1597  return [
1598  'host value matches server name and server port is default http' => [
1599  'httpHost' => 'secure.web.server',
1600  'serverName' => 'secure.web.server',
1601  'isAllowed' => true,
1602  'serverPort' => '80',
1603  'ssl' => 'Off',
1604  ],
1605  'host value matches server name if compared case insensitive 1' => [
1606  'httpHost' => 'secure.web.server',
1607  'serverName' => 'secure.WEB.server',
1608  'isAllowed' => true,
1609  ],
1610  'host value matches server name if compared case insensitive 2' => [
1611  'httpHost' => 'secure.WEB.server',
1612  'serverName' => 'secure.web.server',
1613  'isAllowed' => true,
1614  ],
1615  'host value matches server name and server port is default https' => [
1616  'httpHost' => 'secure.web.server',
1617  'serverName' => 'secure.web.server',
1618  'isAllowed' => true,
1619  'serverPort' => '443',
1620  'ssl' => 'On',
1621  ],
1622  'host value matches server name and server port' => [
1623  'httpHost' => 'secure.web.server:88',
1624  'serverName' => 'secure.web.server',
1625  'isAllowed' => true,
1626  'serverPort' => '88',
1627  ],
1628  'host value matches server name case insensitive 1 and server port' => [
1629  'httpHost' => 'secure.WEB.server:88',
1630  'serverName' => 'secure.web.server',
1631  'isAllowed' => true,
1632  'serverPort' => '88',
1633  ],
1634  'host value matches server name case insensitive 2 and server port' => [
1635  'httpHost' => 'secure.web.server:88',
1636  'serverName' => 'secure.WEB.server',
1637  'isAllowed' => true,
1638  'serverPort' => '88',
1639  ],
1640  'host value is ipv6 but matches server name and server port' => [
1641  'httpHost' => '[::1]:81',
1642  'serverName' => '[::1]',
1643  'isAllowed' => true,
1644  'serverPort' => '81',
1645  ],
1646  'host value does not match server name' => [
1647  'httpHost' => 'insecure.web.server',
1648  'serverName' => 'secure.web.server',
1649  'isAllowed' => false,
1650  ],
1651  'host value does not match server port' => [
1652  'httpHost' => 'secure.web.server:88',
1653  'serverName' => 'secure.web.server',
1654  'isAllowed' => false,
1655  'serverPort' => '89',
1656  ],
1657  'host value has default port that does not match server port' => [
1658  'httpHost' => 'secure.web.server',
1659  'serverName' => 'secure.web.server',
1660  'isAllowed' => false,
1661  'serverPort' => '81',
1662  'ssl' => 'Off',
1663  ],
1664  'host value has default port that does not match server ssl port' => [
1665  'httpHost' => 'secure.web.server',
1666  'serverName' => 'secure.web.server',
1667  'isAllowed' => false,
1668  'serverPort' => '444',
1669  'ssl' => 'On',
1670  ],
1671  ];
1672  }
1673 
1684  public function ‪isAllowedHostHeaderValueWorksCorrectlyWithWithServerNamePattern($httpHost, $serverName, $isAllowed, $serverPort = '80', $ssl = 'Off')
1685  {
1686  ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['trustedHostsPattern'] = ‪GeneralUtility::ENV_TRUSTED_HOSTS_PATTERN_SERVER_NAME;
1687  $_SERVER['SERVER_NAME'] = $serverName;
1688  $_SERVER['SERVER_PORT'] = $serverPort;
1689  $_SERVER['HTTPS'] = $ssl;
1690  $this->assertSame($isAllowed, ‪GeneralUtilityFixture::isAllowedHostHeaderValue($httpHost));
1691  }
1692 
1697  {
1698  GeneralUtilityFixture::getIndpEnv('HTTP_HOST');
1699  GeneralUtility::flushInternalRuntimeCaches();
1700  GeneralUtilityFixture::getIndpEnv('TYPO3_HOST_ONLY');
1701  GeneralUtility::flushInternalRuntimeCaches();
1702  GeneralUtilityFixture::getIndpEnv('TYPO3_REQUEST_HOST');
1703  GeneralUtility::flushInternalRuntimeCaches();
1704  GeneralUtilityFixture::getIndpEnv('TYPO3_REQUEST_URL');
1706  }
1707 
1714  public function ‪getIndpEnvForHostThrowsExceptionForNotAllowedHostnameValues($httpHost, $hostNamePattern)
1715  {
1716  $this->expectException(\UnexpectedValueException::class);
1717  $this->expectExceptionCode(1396795884);
1718  $_SERVER['HTTP_HOST'] = $httpHost;
1719  ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['trustedHostsPattern'] = $hostNamePattern;
1720  GeneralUtilityFixture::getIndpEnv('HTTP_HOST');
1721  }
1722 
1729  public function ‪getIndpEnvForHostAllowsAllHostnameValuesIfHostPatternIsSetToAllowAll($httpHost, $hostNamePattern)
1730  {
1731  $_SERVER['HTTP_HOST'] = $httpHost;
1732  ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['trustedHostsPattern'] = ‪GeneralUtility::ENV_TRUSTED_HOSTS_PATTERN_ALLOW_ALL;
1733  $this->assertSame($httpHost, GeneralUtility::getIndpEnv('HTTP_HOST'));
1734  }
1735 
1740  public function ‪getIndpEnvTypo3PortParsesHostnamesAndIpAdresses($httpHost, $dummy, $expectedPort)
1741  {
1742  $_SERVER['HTTP_HOST'] = $httpHost;
1743  $this->assertEquals($expectedPort, GeneralUtility::getIndpEnv('TYPO3_PORT'));
1744  }
1745 
1747  // Tests concerning underscoredToUpperCamelCase
1749 
1755  {
1756  return [
1757  'single word' => ['Blogexample', 'blogexample'],
1758  'multiple words' => ['BlogExample', 'blog_example']
1759  ];
1760  }
1761 
1766  public function ‪underscoredToUpperCamelCase($expected, $inputString)
1767  {
1768  $this->assertEquals($expected, GeneralUtility::underscoredToUpperCamelCase($inputString));
1769  }
1770 
1772  // Tests concerning underscoredToLowerCamelCase
1774 
1780  {
1781  return [
1782  'single word' => ['minimalvalue', 'minimalvalue'],
1783  'multiple words' => ['minimalValue', 'minimal_value']
1784  ];
1785  }
1786 
1791  public function ‪underscoredToLowerCamelCase($expected, $inputString)
1792  {
1793  $this->assertEquals($expected, GeneralUtility::underscoredToLowerCamelCase($inputString));
1794  }
1795 
1797  // Tests concerning camelCaseToLowerCaseUnderscored
1799 
1805  {
1806  return [
1807  'single word' => ['blogexample', 'blogexample'],
1808  'single word starting upper case' => ['blogexample', 'Blogexample'],
1809  'two words starting lower case' => ['minimal_value', 'minimalValue'],
1810  'two words starting upper case' => ['blog_example', 'BlogExample']
1811  ];
1812  }
1813 
1818  public function ‪camelCaseToLowerCaseUnderscored($expected, $inputString)
1819  {
1820  $this->assertEquals($expected, GeneralUtility::camelCaseToLowerCaseUnderscored($inputString));
1821  }
1822 
1824  // Tests concerning isValidUrl
1826 
1831  public function ‪validUrlValidResourceDataProvider()
1832  {
1833  return [
1834  'http' => ['http://www.example.org/'],
1835  'http without trailing slash' => ['http://qwe'],
1836  'http directory with trailing slash' => ['http://www.example/img/dir/'],
1837  'http directory without trailing slash' => ['http://www.example/img/dir'],
1838  'http index.html' => ['http://example.com/index.html'],
1839  'http index.php' => ['http://www.example.com/index.php'],
1840  'http test.png' => ['http://www.example/img/test.png'],
1841  'http username password querystring and ancher' => ['https://user:pw@www.example.org:80/path?arg=value#fragment'],
1842  'file' => ['file:///tmp/test.c'],
1843  'file directory' => ['file://foo/bar'],
1844  'ftp directory' => ['ftp://ftp.example.com/tmp/'],
1845  'mailto' => ['mailto:foo@bar.com'],
1846  'news' => ['news:news.php.net'],
1847  'telnet' => ['telnet://192.0.2.16:80/'],
1848  'ldap' => ['ldap://[2001:db8::7]/c=GB?objectClass?one'],
1849  'http punycode domain name' => ['http://www.xn--bb-eka.at'],
1850  'http punicode subdomain' => ['http://xn--h-zfa.oebb.at'],
1851  'http domain-name umlauts' => ['http://www.öbb.at'],
1852  'http subdomain umlauts' => ['http://äh.oebb.at'],
1853  ];
1854  }
1855 
1860  public function ‪validURLReturnsTrueForValidResource($url)
1861  {
1862  $this->assertTrue(GeneralUtility::isValidUrl($url));
1863  }
1864 
1871  {
1872  return [
1873  'http missing colon' => ['http//www.example/wrong/url/'],
1874  'http missing slash' => ['http:/www.example'],
1875  'hostname only' => ['www.example.org/'],
1876  'file missing protocol specification' => ['/tmp/test.c'],
1877  'slash only' => ['/'],
1878  'string http://' => ['http://'],
1879  'string http:/' => ['http:/'],
1880  'string http:' => ['http:'],
1881  'string http' => ['http'],
1882  'empty string' => [''],
1883  'string -1' => ['-1'],
1884  'string array()' => ['array()'],
1885  'random string' => ['qwe'],
1886  'http directory umlauts' => ['http://www.oebb.at/äöü/'],
1887  'prohibited input characters' => ['https://{$unresolved_constant}'],
1888  ];
1889  }
1890 
1895  public function ‪validURLReturnsFalseForInvalidRessoure($url)
1896  {
1897  $this->assertFalse(GeneralUtility::isValidUrl($url));
1898  }
1899 
1901  // Tests concerning isOnCurrentHost
1907  {
1908  $testUrl = GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL');
1909  $this->assertTrue(GeneralUtility::isOnCurrentHost($testUrl));
1910  }
1911 
1917  public function ‪checkisOnCurrentHostInvalidHosts()
1918  {
1919  return [
1920  'empty string' => [''],
1921  'arbitrary string' => ['arbitrary string'],
1922  'localhost IP' => ['127.0.0.1'],
1923  'relative path' => ['./relpath/file.txt'],
1924  'absolute path' => ['/abspath/file.txt?arg=value'],
1925  'different host' => [GeneralUtility::getIndpEnv('TYPO3_REQUEST_HOST') . '.example.org']
1926  ];
1927  }
1928 
1930  // Tests concerning sanitizeLocalUrl
1932 
1938  {
1939  return [
1940  'alt_intro.php' => ['alt_intro.php'],
1941  'alt_intro.php?foo=1&bar=2' => ['alt_intro.php?foo=1&bar=2'],
1942  '../index.php' => ['../index.php'],
1943  '../typo3/alt_intro.php' => ['../typo3/alt_intro.php'],
1944  '../~userDirectory/index.php' => ['../~userDirectory/index.php'],
1945  '../typo3/index.php?var1=test-case&var2=~user' => ['../typo3/index.php?var1=test-case&var2=~user'],
1946  ‪Environment::getPublicPath() . '/typo3/alt_intro.php' => [‪Environment::getPublicPath() . '/typo3/alt_intro.php'],
1947  ];
1948  }
1949 
1955  public function ‪sanitizeLocalUrlAcceptsNotEncodedValidPaths($path)
1956  {
1959  true,
1960  false,
1965  ‪Environment::getBackendPath() . '/index.php',
1966  ‪Environment::isWindows() ? 'WINDOWS' : 'UNIX'
1967  );
1968  $this->assertEquals($path, GeneralUtility::sanitizeLocalUrl($path));
1969  }
1970 
1976  public function ‪sanitizeLocalUrlAcceptsEncodedValidPaths($path)
1977  {
1980  true,
1981  false,
1986  ‪Environment::getBackendPath() . '/index.php',
1987  ‪Environment::isWindows() ? 'WINDOWS' : 'UNIX'
1988  );
1989  $this->assertEquals(rawurlencode($path), GeneralUtility::sanitizeLocalUrl(rawurlencode($path)));
1990  }
1991 
1998  {
1999  return [
2000  '/cms/typo3/alt_intro.php' => [
2001  '/cms/typo3/alt_intro.php',
2002  'localhost',
2003  '/cms/',
2004  ],
2005  '/cms/index.php' => [
2006  '/cms/index.php',
2007  'localhost',
2008  '/cms/',
2009  ],
2010  'http://localhost/typo3/alt_intro.php' => [
2011  'http://localhost/typo3/alt_intro.php',
2012  'localhost',
2013  '',
2014  ],
2015  'http://localhost/cms/typo3/alt_intro.php' => [
2016  'http://localhost/cms/typo3/alt_intro.php',
2017  'localhost',
2018  '/cms/',
2019  ],
2020  ];
2021  }
2022 
2030  public function ‪sanitizeLocalUrlAcceptsNotEncodedValidUrls($url, $host, $subDirectory)
2031  {
2034  true,
2035  false,
2040  ‪Environment::getBackendPath() . '/index.php',
2041  ‪Environment::isWindows() ? 'WINDOWS' : 'UNIX'
2042  );
2043  $_SERVER['HTTP_HOST'] = $host;
2044  $_SERVER['SCRIPT_NAME'] = $subDirectory . 'typo3/index.php';
2045  $this->assertEquals($url, GeneralUtility::sanitizeLocalUrl($url));
2046  }
2047 
2055  public function ‪sanitizeLocalUrlAcceptsEncodedValidUrls($url, $host, $subDirectory)
2056  {
2059  true,
2060  false,
2065  ‪Environment::getBackendPath() . '/index.php',
2066  ‪Environment::isWindows() ? 'WINDOWS' : 'UNIX'
2067  );
2068  $_SERVER['HTTP_HOST'] = $host;
2069  $_SERVER['SCRIPT_NAME'] = $subDirectory . 'typo3/index.php';
2070  $this->assertEquals(rawurlencode($url), GeneralUtility::sanitizeLocalUrl(rawurlencode($url)));
2071  }
2072 
2078  public function ‪sanitizeLocalUrlInvalidDataProvider()
2079  {
2080  return [
2081  'empty string' => [''],
2082  'http domain' => ['http://www.google.de/'],
2083  'https domain' => ['https://www.google.de/'],
2084  'domain without schema' => ['//www.google.de/'],
2085  'XSS attempt' => ['" onmouseover="alert(123)"'],
2086  'invalid URL, UNC path' => ['\\\\foo\\bar\\'],
2087  'invalid URL, HTML break out attempt' => ['" >blabuubb'],
2088  'base64 encoded string' => ['data:%20text/html;base64,PHNjcmlwdD5hbGVydCgnWFNTJyk8L3NjcmlwdD4='],
2089  ];
2090  }
2091 
2098  {
2101  true,
2102  false,
2107  ‪Environment::getBackendPath() . '/index.php',
2108  ‪Environment::isWindows() ? 'WINDOWS' : 'UNIX'
2109  );
2110  $_SERVER['HTTP_HOST'] = 'localhost';
2111  $_SERVER['SCRIPT_NAME'] = 'typo3/index.php';
2112  $this->assertEquals('', GeneralUtility::sanitizeLocalUrl($url));
2113  }
2114 
2121  {
2124  true,
2125  false,
2130  ‪Environment::getPublicPath() . '/index.php',
2131  ‪Environment::isWindows() ? 'WINDOWS' : 'UNIX'
2132  );
2133  $_SERVER['HTTP_HOST'] = 'localhost';
2134  $_SERVER['SCRIPT_NAME'] = 'index.php';
2135  $this->assertEquals('', GeneralUtility::sanitizeLocalUrl($url));
2136  }
2137 
2142  public function ‪sanitizeLocalUrlDeniesEncodedInvalidUrls($url)
2143  {
2144  $this->assertEquals('', GeneralUtility::sanitizeLocalUrl(rawurlencode($url)));
2145  }
2146 
2148  // Tests concerning unlink_tempfile
2150 
2155  {
2156  $fixtureFile = __DIR__ . '/Fixtures/clear.gif';
2157  $testFilename = ‪Environment::getVarPath() . '/tests/' . $this->getUniqueId('test_') . '.gif';
2158  @copy($fixtureFile, $testFilename);
2159  GeneralUtility::unlink_tempfile($testFilename);
2160  $fileExists = file_exists($testFilename);
2161  $this->assertFalse($fileExists);
2162  }
2163 
2167  public function ‪unlink_tempfileRemovesHiddenFile()
2168  {
2169  $fixtureFile = __DIR__ . '/Fixtures/clear.gif';
2170  $testFilename = ‪Environment::getVarPath() . '/tests/' . $this->getUniqueId('.test_') . '.gif';
2171  @copy($fixtureFile, $testFilename);
2172  GeneralUtility::unlink_tempfile($testFilename);
2173  $fileExists = file_exists($testFilename);
2174  $this->assertFalse($fileExists);
2175  }
2176 
2181  {
2182  $fixtureFile = __DIR__ . '/Fixtures/clear.gif';
2183  $testFilename = ‪Environment::getVarPath() . '/tests/' . $this->getUniqueId('test_') . '.gif';
2184  @copy($fixtureFile, $testFilename);
2185  $returnValue = GeneralUtility::unlink_tempfile($testFilename);
2186  $this->assertTrue($returnValue);
2187  }
2188 
2193  {
2194  $returnValue = GeneralUtility::unlink_tempfile(‪Environment::getVarPath() . '/tests/' . $this->getUniqueId('i_do_not_exist'));
2195  $this->assertNull($returnValue);
2196  }
2197 
2202  {
2203  $returnValue = GeneralUtility::unlink_tempfile('/tmp/typo3-unit-test-unlink_tempfile');
2204  $this->assertNull($returnValue);
2205  }
2206 
2208  // Tests concerning tempnam
2210 
2215  {
2216  $filePath = GeneralUtility::tempnam('foo');
2217  $this->testFilesToDelete[] = $filePath;
2218  $fileName = basename($filePath);
2219  $this->assertStringStartsWith('foo', $fileName);
2220  }
2221 
2225  public function ‪tempnamReturnsPathWithoutBackslashes()
2226  {
2227  $filePath = GeneralUtility::tempnam('foo');
2228  $this->testFilesToDelete[] = $filePath;
2229  $this->assertNotContains('\\', $filePath);
2230  }
2231 
2236  {
2237  $filePath = GeneralUtility::tempnam('foo');
2238  $this->testFilesToDelete[] = $filePath;
2239  $this->assertStringStartsWith(‪Environment::getPublicPath() . '/', $filePath);
2240  }
2241 
2243  // Tests concerning removeDotsFromTS
2249  {
2250  $typoScript = [
2251  'propertyA.' => [
2252  'keyA.' => [
2253  'valueA' => 1
2254  ],
2255  'keyB' => 2
2256  ],
2257  'propertyB' => 3
2258  ];
2259  $expectedResult = [
2260  'propertyA' => [
2261  'keyA' => [
2262  'valueA' => 1
2263  ],
2264  'keyB' => 2
2265  ],
2266  'propertyB' => 3
2267  ];
2268  $this->assertEquals($expectedResult, GeneralUtility::removeDotsFromTS($typoScript));
2269  }
2270 
2275  {
2276  $typoScript = [
2277  'propertyA.' => [
2278  'keyA' => 'getsOverridden',
2279  'keyA.' => [
2280  'valueA' => 1
2281  ],
2282  'keyB' => 2
2283  ],
2284  'propertyB' => 3
2285  ];
2286  $expectedResult = [
2287  'propertyA' => [
2288  'keyA' => [
2289  'valueA' => 1
2290  ],
2291  'keyB' => 2
2292  ],
2293  'propertyB' => 3
2294  ];
2295  $this->assertEquals($expectedResult, GeneralUtility::removeDotsFromTS($typoScript));
2296  }
2297 
2302  {
2303  $typoScript = [
2304  'propertyA.' => [
2305  'keyA.' => [
2306  'valueA' => 1
2307  ],
2308  'keyA' => 'willOverride',
2309  'keyB' => 2
2310  ],
2311  'propertyB' => 3
2312  ];
2313  $expectedResult = [
2314  'propertyA' => [
2315  'keyA' => 'willOverride',
2316  'keyB' => 2
2317  ],
2318  'propertyB' => 3
2319  ];
2320  $this->assertEquals($expectedResult, GeneralUtility::removeDotsFromTS($typoScript));
2321  }
2322 
2324  // Tests concerning get_dirs
2330  {
2331  $directories = GeneralUtility::get_dirs(‪Environment::getLegacyConfigPath() . '/');
2332  $this->assertInternalType(\PHPUnit\Framework\Constraint\IsType::TYPE_ARRAY, $directories);
2333  }
2334 
2339  {
2340  $path = 'foo';
2341  $result = GeneralUtility::get_dirs($path);
2342  $expectedResult = 'error';
2343  $this->assertEquals($expectedResult, $result);
2344  }
2345 
2347  // Tests concerning hmac
2352  public function ‪hmacReturnsHashOfProperLength()
2353  {
2354  $hmac = GeneralUtility::hmac('message');
2355  $this->assertTrue(!empty($hmac) && is_string($hmac));
2356  $this->assertTrue(strlen($hmac) == 40);
2357  }
2358 
2362  public function ‪hmacReturnsEqualHashesForEqualInput()
2363  {
2364  $msg0 = 'message';
2365  $msg1 = 'message';
2366  $this->assertEquals(GeneralUtility::hmac($msg0), GeneralUtility::hmac($msg1));
2367  }
2368 
2373  {
2374  $msg0 = 'message0';
2375  $msg1 = 'message1';
2376  $this->assertNotEquals(GeneralUtility::hmac($msg0), GeneralUtility::hmac($msg1));
2377  }
2378 
2380  // Tests concerning quoteJSvalue
2382 
2387  public function ‪quoteJsValueDataProvider()
2388  {
2389  return [
2390  'Immune characters are returned as is' => [
2391  '._,',
2392  '._,'
2393  ],
2394  'Alphanumerical characters are returned as is' => [
2395  'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789',
2396  'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'
2397  ],
2398  'Angle brackets and ampersand are encoded' => [
2399  '<>&',
2400  '\\u003C\\u003E\\u0026'
2401  ],
2402  'Quotes and backslashes are encoded' => [
2403  '"\'\\',
2404  '\\u0022\\u0027\\u005C'
2405  ],
2406  'Forward slashes are escaped' => [
2407  '</script>',
2408  '\\u003C\\/script\\u003E'
2409  ],
2410  'Empty string stays empty' => [
2411  '',
2412  ''
2413  ],
2414  'Exclamation mark and space are properly encoded' => [
2415  'Hello World!',
2416  'Hello\\u0020World\\u0021'
2417  ],
2418  'Whitespaces are properly encoded' => [
2419  "\t" . LF . CR . ' ',
2420  '\\u0009\\u000A\\u000D\\u0020'
2421  ],
2422  'Null byte is properly encoded' => [
2423  "\0",
2424  '\\u0000'
2425  ],
2426  'Umlauts are properly encoded' => [
2427  'ÜüÖöÄä',
2428  '\\u00dc\\u00fc\\u00d6\\u00f6\\u00c4\\u00e4'
2429  ]
2430  ];
2431  }
2432 
2439  public function ‪quoteJsValueTest($input, $expected)
2440  {
2441  $this->assertSame('\'' . $expected . '\'', GeneralUtility::quoteJSvalue($input));
2442  }
2443 
2445  // Tests concerning minifyJavaScript
2451  {
2452  unset(‪$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_div.php']['minifyJavaScript']);
2453  $testString = $this->getUniqueId('string');
2454  $this->assertSame($testString, GeneralUtility::minifyJavaScript($testString));
2455  }
2456 
2458  // Tests concerning fixPermissions
2460 
2464  public function ‪fixPermissionsSetsGroup()
2465  {
2466  if (‪Environment::isWindows()) {
2467  $this->markTestSkipped(self::NO_FIX_PERMISSIONS_ON_WINDOWS);
2468  }
2469  // Create and prepare test file
2470  $filename = $this->‪getVirtualTestDir() . '/' . $this->getUniqueId('test_');
2472  $currentGroupId = posix_getegid();
2473  // Set target group and run method
2474  ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['createGroup'] = $currentGroupId;
2475  GeneralUtilityFilesystemFixture::fixPermissions($filename);
2476  clearstatcache();
2477  $this->assertEquals($currentGroupId, filegroup($filename));
2478  }
2479 
2483  public function ‪fixPermissionsSetsPermissionsToFile()
2484  {
2485  if (‪Environment::isWindows()) {
2486  $this->markTestSkipped(self::NO_FIX_PERMISSIONS_ON_WINDOWS);
2487  }
2488  // Create and prepare test file
2489  $filename = $this->‪getVirtualTestDir() . '/' . $this->getUniqueId('test_');
2491  chmod($filename, 482);
2492  // Set target permissions and run method
2493  ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['fileCreateMask'] = '0660';
2494  $fixPermissionsResult = GeneralUtilityFilesystemFixture::fixPermissions($filename);
2495  clearstatcache();
2496  $this->assertTrue($fixPermissionsResult);
2497  $this->assertEquals('0660', substr(decoct(fileperms($filename)), 2));
2498  }
2499 
2504  {
2505  if (‪Environment::isWindows()) {
2506  $this->markTestSkipped(self::NO_FIX_PERMISSIONS_ON_WINDOWS);
2507  }
2508  // Create and prepare test file
2509  $filename = $this->‪getVirtualTestDir() . '/' . $this->getUniqueId('test_');
2511  chmod($filename, 482);
2512  // Set target permissions and run method
2513  ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['fileCreateMask'] = '0660';
2514  $fixPermissionsResult = GeneralUtilityFilesystemFixture::fixPermissions($filename);
2515  clearstatcache();
2516  $this->assertTrue($fixPermissionsResult);
2517  $this->assertEquals('0660', substr(decoct(fileperms($filename)), 2));
2518  }
2519 
2524  {
2525  if (‪Environment::isWindows()) {
2526  $this->markTestSkipped(self::NO_FIX_PERMISSIONS_ON_WINDOWS);
2527  }
2528  // Create and prepare test directory
2529  $directory = $this->‪getVirtualTestDir() . '/' . $this->getUniqueId('test_');
2530  GeneralUtilityFilesystemFixture::mkdir($directory);
2531  chmod($directory, 1551);
2532  // Set target permissions and run method
2533  ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['folderCreateMask'] = '0770';
2534  $fixPermissionsResult = GeneralUtilityFilesystemFixture::fixPermissions($directory);
2535  clearstatcache();
2536  $this->assertTrue($fixPermissionsResult);
2537  $this->assertEquals('0770', substr(decoct(fileperms($directory)), 1));
2538  }
2539 
2544  {
2545  if (‪Environment::isWindows()) {
2546  $this->markTestSkipped(self::NO_FIX_PERMISSIONS_ON_WINDOWS);
2547  }
2548  // Create and prepare test directory
2549  $directory = $this->‪getVirtualTestDir() . '/' . $this->getUniqueId('test_');
2550  GeneralUtilityFilesystemFixture::mkdir($directory);
2551  chmod($directory, 1551);
2552  // Set target permissions and run method
2553  ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['folderCreateMask'] = '0770';
2554  $fixPermissionsResult = GeneralUtilityFilesystemFixture::fixPermissions($directory . '/');
2555  // Get actual permissions and clean up
2556  clearstatcache();
2557  $this->assertTrue($fixPermissionsResult);
2558  $this->assertEquals('0770', substr(decoct(fileperms($directory)), 1));
2559  }
2560 
2565  {
2566  if (‪Environment::isWindows()) {
2567  $this->markTestSkipped(self::NO_FIX_PERMISSIONS_ON_WINDOWS);
2568  }
2569  // Create and prepare test directory
2570  $directory = $this->‪getVirtualTestDir() . '/' . $this->getUniqueId('test_');
2571  GeneralUtilityFilesystemFixture::mkdir($directory);
2572  chmod($directory, 1551);
2573  // Set target permissions and run method
2574  ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['folderCreateMask'] = '0770';
2575  $fixPermissionsResult = GeneralUtilityFilesystemFixture::fixPermissions($directory);
2576  // Get actual permissions and clean up
2577  clearstatcache();
2578  $this->assertTrue($fixPermissionsResult);
2579  $this->assertEquals('0770', substr(decoct(fileperms($directory)), 1));
2580  }
2581 
2586  {
2587  if (‪Environment::isWindows()) {
2588  $this->markTestSkipped(self::NO_FIX_PERMISSIONS_ON_WINDOWS);
2589  }
2590  // Create and prepare test directory and file structure
2591  $baseDirectory = $this->‪getVirtualTestDir() . '/' . $this->getUniqueId('test_');
2592  GeneralUtilityFilesystemFixture::mkdir($baseDirectory);
2593  chmod($baseDirectory, 1751);
2594  ‪GeneralUtilityFilesystemFixture::writeFileToTypo3tempDir($baseDirectory . '/file', '42');
2595  chmod($baseDirectory . '/file', 482);
2596  GeneralUtilityFilesystemFixture::mkdir($baseDirectory . '/foo');
2597  chmod($baseDirectory . '/foo', 1751);
2598  ‪GeneralUtilityFilesystemFixture::writeFileToTypo3tempDir($baseDirectory . '/foo/file', '42');
2599  chmod($baseDirectory . '/foo/file', 482);
2600  GeneralUtilityFilesystemFixture::mkdir($baseDirectory . '/.bar');
2601  chmod($baseDirectory . '/.bar', 1751);
2602  // Use this if writeFileToTypo3tempDir is fixed to create hidden files in subdirectories
2603  // \TYPO3\CMS\Core\Utility\GeneralUtility::writeFileToTypo3tempDir($baseDirectory . '/.bar/.file', '42');
2604  // \TYPO3\CMS\Core\Utility\GeneralUtility::writeFileToTypo3tempDir($baseDirectory . '/.bar/..file2', '42');
2605  touch($baseDirectory . '/.bar/.file', '42');
2606  chmod($baseDirectory . '/.bar/.file', 482);
2607  touch($baseDirectory . '/.bar/..file2', '42');
2608  chmod($baseDirectory . '/.bar/..file2', 482);
2609  // Set target permissions and run method
2610  ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['fileCreateMask'] = '0660';
2611  ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['folderCreateMask'] = '0770';
2612  $fixPermissionsResult = GeneralUtilityFilesystemFixture::fixPermissions($baseDirectory, true);
2613  // Get actual permissions
2614  clearstatcache();
2615  $resultBaseDirectoryPermissions = substr(decoct(fileperms($baseDirectory)), 1);
2616  $resultBaseFilePermissions = substr(decoct(fileperms($baseDirectory . '/file')), 2);
2617  $resultFooDirectoryPermissions = substr(decoct(fileperms($baseDirectory . '/foo')), 1);
2618  $resultFooFilePermissions = substr(decoct(fileperms($baseDirectory . '/foo/file')), 2);
2619  $resultBarDirectoryPermissions = substr(decoct(fileperms($baseDirectory . '/.bar')), 1);
2620  $resultBarFilePermissions = substr(decoct(fileperms($baseDirectory . '/.bar/.file')), 2);
2621  $resultBarFile2Permissions = substr(decoct(fileperms($baseDirectory . '/.bar/..file2')), 2);
2622  // Test if everything was ok
2623  $this->assertTrue($fixPermissionsResult);
2624  $this->assertEquals('0770', $resultBaseDirectoryPermissions);
2625  $this->assertEquals('0660', $resultBaseFilePermissions);
2626  $this->assertEquals('0770', $resultFooDirectoryPermissions);
2627  $this->assertEquals('0660', $resultFooFilePermissions);
2628  $this->assertEquals('0770', $resultBarDirectoryPermissions);
2629  $this->assertEquals('0660', $resultBarFilePermissions);
2630  $this->assertEquals('0660', $resultBarFile2Permissions);
2631  }
2632 
2637  {
2638  if (‪Environment::isWindows()) {
2639  $this->markTestSkipped(self::NO_FIX_PERMISSIONS_ON_WINDOWS);
2640  }
2641  // Create and prepare test file
2642  $filename = ‪Environment::getVarPath() . '/tests/../../../typo3temp/var/tests/' . $this->getUniqueId('test_');
2643  // Set target permissions and run method
2644  ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['fileCreateMask'] = '0660';
2645  $fixPermissionsResult = GeneralUtility::fixPermissions($filename);
2646  $this->assertFalse($fixPermissionsResult);
2647  }
2648 
2653  {
2654  if (‪Environment::isWindows()) {
2655  $this->markTestSkipped(self::NO_FIX_PERMISSIONS_ON_WINDOWS);
2656  }
2657  $filename = 'typo3temp/var/tests/' . $this->getUniqueId('test_');
2658  GeneralUtility::writeFileToTypo3tempDir(‪Environment::getPublicPath() . '/' . $filename, '42');
2659  $this->testFilesToDelete[] = ‪Environment::getPublicPath() . '/' . $filename;
2660  chmod(‪Environment::getPublicPath() . '/' . $filename, 482);
2661  // Set target permissions and run method
2662  ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['fileCreateMask'] = '0660';
2663  $fixPermissionsResult = GeneralUtility::fixPermissions($filename);
2664  clearstatcache();
2665  $this->assertTrue($fixPermissionsResult);
2666  $this->assertEquals('0660', substr(decoct(fileperms(‪Environment::getPublicPath() . '/' . $filename)), 2));
2667  }
2668 
2673  {
2674  if (‪Environment::isWindows()) {
2675  $this->markTestSkipped(self::NO_FIX_PERMISSIONS_ON_WINDOWS);
2676  }
2677  $filename = $this->‪getVirtualTestDir() . '/' . $this->getUniqueId('test_');
2679  chmod($filename, 482);
2680  unset(‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['fileCreateMask']);
2681  $fixPermissionsResult = GeneralUtilityFilesystemFixture::fixPermissions($filename);
2682  clearstatcache();
2683  $this->assertTrue($fixPermissionsResult);
2684  $this->assertEquals('0644', substr(decoct(fileperms($filename)), 2));
2685  }
2686 
2691  {
2692  if (‪Environment::isWindows()) {
2693  $this->markTestSkipped(self::NO_FIX_PERMISSIONS_ON_WINDOWS);
2694  }
2695  $directory = $this->‪getVirtualTestDir() . '/' . $this->getUniqueId('test_');
2696  GeneralUtilityFilesystemFixture::mkdir($directory);
2697  chmod($directory, 1551);
2698  unset(‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['folderCreateMask']);
2699  $fixPermissionsResult = GeneralUtilityFilesystemFixture::fixPermissions($directory);
2700  clearstatcache();
2701  $this->assertTrue($fixPermissionsResult);
2702  $this->assertEquals('0755', substr(decoct(fileperms($directory)), 1));
2703  }
2704 
2706  // Tests concerning mkdir
2711  public function ‪mkdirCreatesDirectory()
2712  {
2713  $directory = $this->‪getVirtualTestDir() . '/' . $this->getUniqueId('test_');
2714  $mkdirResult = GeneralUtilityFilesystemFixture::mkdir($directory);
2715  clearstatcache();
2716  $this->assertTrue($mkdirResult);
2717  $this->assertTrue(is_dir($directory));
2718  }
2719 
2723  public function ‪mkdirCreatesHiddenDirectory()
2724  {
2725  $directory = $this->‪getVirtualTestDir() . '/' . $this->getUniqueId('.test_');
2726  $mkdirResult = GeneralUtilityFilesystemFixture::mkdir($directory);
2727  clearstatcache();
2728  $this->assertTrue($mkdirResult);
2729  $this->assertTrue(is_dir($directory));
2730  }
2731 
2736  {
2737  $directory = $this->‪getVirtualTestDir() . '/' . $this->getUniqueId('test_') . '/';
2738  $mkdirResult = GeneralUtilityFilesystemFixture::mkdir($directory);
2739  clearstatcache();
2740  $this->assertTrue($mkdirResult);
2741  $this->assertTrue(is_dir($directory));
2742  }
2743 
2748  {
2749  if (‪Environment::isWindows()) {
2750  $this->markTestSkipped(self::NO_FIX_PERMISSIONS_ON_WINDOWS);
2751  }
2752  $directory = $this->‪getVirtualTestDir() . '/' . $this->getUniqueId('test_');
2753  $oldUmask = umask(19);
2754  ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['folderCreateMask'] = '0772';
2755  GeneralUtilityFilesystemFixture::mkdir($directory);
2756  clearstatcache();
2757  $resultDirectoryPermissions = substr(decoct(fileperms($directory)), 1);
2758  umask($oldUmask);
2759  $this->assertEquals($resultDirectoryPermissions, '0772');
2760  }
2761 
2766  {
2767  $swapGroup = $this->‪checkGroups(__FUNCTION__);
2768  if ($swapGroup !== false) {
2769  ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['createGroup'] = $swapGroup;
2770  $directory = $this->‪getVirtualTestDir() . '/' . $this->getUniqueId('mkdirtest_');
2771  GeneralUtilityFilesystemFixture::mkdir($directory);
2772  clearstatcache();
2773  $resultDirectoryGroup = filegroup($directory);
2774  $this->assertEquals($resultDirectoryGroup, $swapGroup);
2775  }
2776  }
2777 
2779  // Helper function for filesystem ownership tests
2781 
2790  private function ‪checkGroups($methodName)
2791  {
2792  if (‪Environment::isWindows()) {
2793  $this->markTestSkipped(self::NO_FIX_PERMISSIONS_ON_WINDOWS);
2794  return false;
2795  }
2796  $groups = posix_getgroups();
2797  if (count($groups) <= 1) {
2798  $this->markTestSkipped($methodName . '() test cannot be done when the web server user is only member of 1 group.');
2799  return false;
2800  }
2801  $secondaryGroups = array_diff($groups, [posix_getegid()]);
2802  return array_shift($secondaryGroups);
2803  }
2804 
2806  // Tests concerning writeFileToTypo3tempDir()
2808 
2813  {
2814  return [
2815  [
2816  ‪Environment::getPublicPath() . '/../path/this-path-has-more-than-60-characters-in-one-base-path-you-can-even-count-more',
2817  'Input filepath "' . ‪Environment::getPublicPath() . '/../path/this-path-has-more-than-60-characters-in-one-base-path-you-can-even-count-more" was generally invalid!'
2818  ],
2819  [
2820  ‪Environment::getPublicPath() . '/dummy/path/this-path-has-more-than-60-characters-in-one-base-path-you-can-even-count-more',
2821  'Input filepath "' . ‪Environment::getPublicPath() . '/dummy/path/this-path-has-more-than-60-characters-in-one-base-path-you-can-even-count-more" was generally invalid!'
2822  ],
2823  [
2824  ‪Environment::getPublicPath() . '/dummy/path/this-path-has-more-than-60-characters-in-one-base-path-you-can-even-count-more',
2825  'Input filepath "' . ‪Environment::getPublicPath() . '/dummy/path/this-path-has-more-than-60-characters-in-one-base-path-you-can-even-count-more" was generally invalid!'
2826  ],
2827  [
2828  '/dummy/path/awesome',
2829  '"/dummy/path/" was not within directory Environment::getPublicPath() + "/typo3temp/"'
2830  ],
2831  [
2833  '"' . ‪Environment::getLegacyConfigPath() . '/" was not within directory Environment::getPublicPath() + "/typo3temp/"',
2834  ],
2835  [
2836  ‪Environment::getPublicPath() . '/typo3temp/táylor/swíft',
2837  'Subdir, "táylor/", was NOT on the form "[[:alnum:]_]/+"',
2838  ],
2839  'Path instead of file given' => [
2840  ‪Environment::getPublicPath() . '/typo3temp/dummy/path/',
2841  'Calculated file location didn\'t match input "' . ‪Environment::getPublicPath() . '/typo3temp/dummy/path/".'
2842  ],
2843  ];
2844  }
2845 
2852  public function ‪writeFileToTypo3tempDirFailsWithInvalidPath($invalidFilePath, string $expectedResult)
2853  {
2854  $result = GeneralUtility::writeFileToTypo3tempDir($invalidFilePath, 'dummy content to be written');
2855  $this->assertSame($result, $expectedResult);
2856  }
2857 
2862  {
2863  return [
2864  'Default text file' => [
2865  ‪Environment::getPublicPath() . '/typo3temp/var/paranoid/android.txt',
2866  ],
2867  'Html file extension' => [
2868  ‪Environment::getPublicPath() . '/typo3temp/var/karma.html',
2869  ],
2870  'No file extension' => [
2871  ‪Environment::getPublicPath() . '/typo3temp/var/no-surprises',
2872  ],
2873  'Deep directory' => [
2874  ‪Environment::getPublicPath() . '/typo3temp/var/climbing/up/the/walls',
2875  ],
2876  ];
2877  }
2878 
2884  public function ‪writeFileToTypo3tempDirWorksWithValidPath($filePath)
2885  {
2886  $dummyContent = 'Please could you stop the noise, I\'m trying to get some rest from all the unborn chicken voices in my head.';
2887 
2888  $this->testFilesToDelete[] = $filePath;
2889 
2890  $result = GeneralUtility::writeFileToTypo3tempDir($filePath, $dummyContent);
2891 
2892  $this->assertNull($result);
2893  $this->assertFileExists($filePath);
2894  $this->assertStringEqualsFile($filePath, $dummyContent);
2895  }
2896 
2898  // Tests concerning mkdir_deep
2903  public function ‪mkdirDeepCreatesDirectory()
2904  {
2905  $directory = $this->‪getVirtualTestDir() . '/' . $this->getUniqueId('test_');
2906  GeneralUtility::mkdir_deep($directory);
2907  $this->assertTrue(is_dir($directory));
2908  }
2909 
2914  {
2915  $directory = $this->‪getVirtualTestDir() . 'typo3temp/var/tests/' . $this->getUniqueId('test_');
2916  $subDirectory = $directory . '/foo';
2917  GeneralUtility::mkdir_deep($subDirectory);
2918  $this->assertTrue(is_dir($subDirectory));
2919  }
2920 
2926  {
2927  return [
2928  'no double slash if concatenated with Environment::getPublicPath()' => ['fileadmin/testDir1'],
2929  'double slash if concatenated with Environment::getPublicPath()' => ['/fileadmin/testDir2'],
2930  ];
2931  }
2932 
2937  public function ‪mkdirDeepCreatesDirectoryWithDoubleSlashes($directoryToCreate)
2938  {
2939  vfsStream::setup();
2940  // Load fixture files and folders from disk
2941  FileStreamWrapper::init(‪Environment::getPublicPath());
2942  FileStreamWrapper::registerOverlayPath('fileadmin', 'vfs://root/fileadmin', true);
2943  GeneralUtility::mkdir_deep(‪Environment::getPublicPath() . '/' . $directoryToCreate);
2944  $this->assertTrue(is_dir(‪Environment::getPublicPath() . '/' . $directoryToCreate));
2945  FileStreamWrapper::destroy();
2946  }
2947 
2952  {
2953  if (‪Environment::isWindows()) {
2954  $this->markTestSkipped(self::NO_FIX_PERMISSIONS_ON_WINDOWS);
2955  }
2956  $directory = $this->getUniqueId('mkdirdeeptest_');
2957  $oldUmask = umask(19);
2958  ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['folderCreateMask'] = '0777';
2959  GeneralUtility::mkdir_deep(‪Environment::getVarPath() . '/tests/' . $directory);
2960  $this->testFilesToDelete[] = ‪Environment::getVarPath() . '/tests/' . $directory;
2961  clearstatcache();
2962  umask($oldUmask);
2963  $this->assertEquals('777', substr(decoct(fileperms(‪Environment::getVarPath() . '/tests/' . $directory)), -3, 3));
2964  }
2965 
2970  {
2971  if (‪Environment::isWindows()) {
2972  $this->markTestSkipped(self::NO_FIX_PERMISSIONS_ON_WINDOWS);
2973  }
2974  $directory = $this->getUniqueId('mkdirdeeptest_');
2975  $subDirectory = $directory . '/bar';
2976  ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['folderCreateMask'] = '0777';
2977  $oldUmask = umask(19);
2978  GeneralUtility::mkdir_deep(‪Environment::getVarPath() . '/tests/' . $subDirectory);
2979  $this->testFilesToDelete[] = ‪Environment::getVarPath() . '/tests/' . $directory;
2980  clearstatcache();
2981  umask($oldUmask);
2982  $this->assertEquals('777', substr(decoct(fileperms(‪Environment::getVarPath() . '/tests/' . $directory)), -3, 3));
2983  }
2984 
2989  {
2990  if (‪Environment::isWindows()) {
2991  $this->markTestSkipped(self::NO_FIX_PERMISSIONS_ON_WINDOWS);
2992  }
2993  $baseDirectory = ‪Environment::getVarPath() . '/tests/';
2994  $existingDirectory = $this->getUniqueId('test_existing_') . '/';
2995  $newSubDirectory = $this->getUniqueId('test_new_');
2996  @mkdir($baseDirectory . $existingDirectory);
2997  $this->testFilesToDelete[] = $baseDirectory . $existingDirectory;
2998  chmod($baseDirectory . $existingDirectory, 482);
2999  GeneralUtility::mkdir_deep($baseDirectory . $existingDirectory . $newSubDirectory);
3000  $this->assertEquals(742, (int)substr(decoct(fileperms($baseDirectory . $existingDirectory)), 2));
3001  }
3002 
3007  {
3008  $swapGroup = $this->‪checkGroups(__FUNCTION__);
3009  if ($swapGroup !== false) {
3010  ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['createGroup'] = $swapGroup;
3011  $directory = $this->getUniqueId('mkdirdeeptest_');
3012  GeneralUtility::mkdir_deep(‪Environment::getVarPath() . '/tests/' . $directory);
3013  $this->testFilesToDelete[] = ‪Environment::getVarPath() . '/tests/' . $directory;
3014  clearstatcache();
3015  $resultDirectoryGroup = filegroup(‪Environment::getVarPath() . '/tests/' . $directory);
3016  $this->assertEquals($resultDirectoryGroup, $swapGroup);
3017  }
3018  }
3019 
3024  {
3025  $swapGroup = $this->‪checkGroups(__FUNCTION__);
3026  if ($swapGroup !== false) {
3027  ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['createGroup'] = $swapGroup;
3028  $directory = $this->getUniqueId('mkdirdeeptest_');
3029  $subDirectory = $directory . '/bar';
3030  GeneralUtility::mkdir_deep(‪Environment::getVarPath() . '/tests/' . $subDirectory);
3031  $this->testFilesToDelete[] = ‪Environment::getVarPath() . '/tests/' . $directory;
3032  clearstatcache();
3033  $resultDirectoryGroup = filegroup(‪Environment::getVarPath() . '/tests/' . $directory);
3034  $this->assertEquals($resultDirectoryGroup, $swapGroup);
3035  }
3036  }
3037 
3042  {
3043  $swapGroup = $this->‪checkGroups(__FUNCTION__);
3044  if ($swapGroup !== false) {
3045  ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['createGroup'] = $swapGroup;
3046  $directory = $this->getUniqueId('mkdirdeeptest_');
3047  $subDirectory = $directory . '/bar';
3048  GeneralUtility::mkdir_deep(‪Environment::getVarPath() . '/tests/' . $subDirectory);
3049  $this->testFilesToDelete[] = ‪Environment::getVarPath() . '/tests/' . $directory;
3050  clearstatcache();
3051  $resultDirectoryGroup = filegroup(‪Environment::getVarPath() . '/tests/' . $directory);
3052  $this->assertEquals($resultDirectoryGroup, $swapGroup);
3053  }
3054  }
3055 
3059  public function ‪mkdirDeepCreatesDirectoryInVfsStream()
3060  {
3061  vfsStreamWrapper::register();
3062  $baseDirectory = $this->getUniqueId('test_');
3063  vfsStreamWrapper::setRoot(new vfsStreamDirectory($baseDirectory));
3064  GeneralUtility::mkdir_deep('vfs://' . $baseDirectory . '/sub');
3065  $this->assertTrue(is_dir('vfs://' . $baseDirectory . '/sub'));
3066  }
3067 
3072  {
3073  $this->expectException(\RuntimeException::class);
3074  $this->expectExceptionCode(1170251401);
3075 
3076  GeneralUtility::mkdir_deep('http://localhost');
3077  }
3078 
3083  {
3084  $this->expectException(\InvalidArgumentException::class);
3085  $this->expectExceptionCode(1303662955);
3086 
3087  GeneralUtility::mkdir_deep([]);
3088  }
3089 
3094  {
3095  $this->expectException(\InvalidArgumentException::class);
3096  $this->expectExceptionCode(1303662956);
3097 
3098  GeneralUtility::mkdir_deep(‪Environment::getPublicPath() . '/typo3temp/foo', []);
3099  }
3100 
3102  // Tests concerning rmdir
3104 
3108  public function ‪rmdirRemovesFile()
3109  {
3110  $file = ‪Environment::getVarPath() . '/tests/' . $this->getUniqueId('file_');
3111  touch($file);
3112  GeneralUtility::rmdir($file);
3113  $this->assertFalse(file_exists($file));
3114  }
3115 
3119  public function ‪rmdirReturnTrueIfFileWasRemoved()
3120  {
3121  $file = ‪Environment::getVarPath() . '/tests/' . $this->getUniqueId('file_');
3122  touch($file);
3123  $this->assertTrue(GeneralUtility::rmdir($file));
3124  }
3125 
3129  public function ‪rmdirReturnFalseIfNoFileWasRemoved()
3130  {
3131  $file = ‪Environment::getVarPath() . '/tests/' . $this->getUniqueId('file_');
3132  $this->assertFalse(GeneralUtility::rmdir($file));
3133  }
3134 
3138  public function ‪rmdirRemovesDirectory()
3139  {
3140  $directory = ‪Environment::getVarPath() . '/tests/' . $this->getUniqueId('directory_');
3141  mkdir($directory);
3142  GeneralUtility::rmdir($directory);
3143  $this->assertFalse(file_exists($directory));
3144  }
3145 
3150  {
3151  $directory = ‪Environment::getVarPath() . '/tests/' . $this->getUniqueId('directory_') . '/';
3152  mkdir($directory);
3153  GeneralUtility::rmdir($directory);
3154  $this->assertFalse(file_exists($directory));
3155  }
3156 
3161  {
3162  $directory = ‪Environment::getVarPath() . '/tests/' . $this->getUniqueId('directory_') . '/';
3163  mkdir($directory);
3164  $file = $this->getUniqueId('file_');
3165  touch($directory . $file);
3166  $this->testFilesToDelete[] = $directory;
3167  $return = GeneralUtility::rmdir($directory);
3168  $this->assertTrue(file_exists($directory));
3169  $this->assertTrue(file_exists($directory . $file));
3170  $this->assertFalse($return);
3171  }
3172 
3177  {
3178  $directory = ‪Environment::getVarPath() . '/tests/' . $this->getUniqueId('directory_') . '/';
3179  mkdir($directory);
3180  mkdir($directory . 'sub/');
3181  touch($directory . 'sub/file');
3182  $return = GeneralUtility::rmdir($directory, true);
3183  $this->assertFalse(file_exists($directory));
3184  $this->assertTrue($return);
3185  }
3186 
3190  public function ‪rmdirRemovesLinkToDirectory()
3191  {
3192  $existingDirectory = ‪Environment::getVarPath() . '/tests/' . $this->getUniqueId('notExists_') . '/';
3193  mkdir($existingDirectory);
3194  $this->testFilesToDelete[] = $existingDirectory;
3195  $symlinkName = ‪Environment::getVarPath() . '/tests/' . $this->getUniqueId('link_');
3196  symlink($existingDirectory, $symlinkName);
3197  GeneralUtility::rmdir($symlinkName, true);
3198  $this->assertFalse(is_link($symlinkName));
3199  }
3200 
3204  public function ‪rmdirRemovesDeadLinkToDirectory()
3205  {
3206  $notExistingDirectory = ‪Environment::getVarPath() . '/tests/' . $this->getUniqueId('notExists_') . '/';
3207  $symlinkName = ‪Environment::getVarPath() . '/tests/' . $this->getUniqueId('link_');
3208  mkdir($notExistingDirectory);
3209  symlink($notExistingDirectory, $symlinkName);
3210  rmdir($notExistingDirectory);
3211 
3212  GeneralUtility::rmdir($symlinkName, true);
3213  $this->assertFalse(is_link($symlinkName));
3214  }
3215 
3219  public function ‪rmdirRemovesDeadLinkToFile()
3220  {
3221  $notExistingFile = ‪Environment::getVarPath() . '/tests/' . $this->getUniqueId('notExists_');
3222  $symlinkName = ‪Environment::getVarPath() . '/tests/' . $this->getUniqueId('link_');
3223  touch($notExistingFile);
3224  symlink($notExistingFile, $symlinkName);
3225  unlink($notExistingFile);
3226  GeneralUtility::rmdir($symlinkName, true);
3227  $this->assertFalse(is_link($symlinkName));
3228  }
3229 
3231  // Tests concerning getFilesInDir
3233 
3239  protected function ‪getFilesInDirCreateTestDirectory()
3240  {
3241  $structure = [
3242  'subDirectory' => [
3243  'test.php' => 'butter',
3244  'other.php' => 'milk',
3245  'stuff.csv' => 'honey',
3246  ],
3247  'excludeMe.txt' => 'cocoa nibs',
3248  'double.setup.typoscript' => 'cool TS',
3249  'testB.txt' => 'olive oil',
3250  'testA.txt' => 'eggs',
3251  'testC.txt' => 'carrots',
3252  'test.js' => 'oranges',
3253  'test.css' => 'apples',
3254  '.secret.txt' => 'sammon',
3255  ];
3256  vfsStream::setup('test', null, $structure);
3257  $vfsUrl = vfsStream::url('test');
3258 
3259  // set random values for mtime
3260  foreach ($structure as $structureLevel1Key => $structureLevel1Content) {
3261  $newMtime = rand();
3262  if (is_array($structureLevel1Content)) {
3263  foreach ($structureLevel1Content as $structureLevel2Key => $structureLevel2Content) {
3264  touch($vfsUrl . '/' . $structureLevel1Key . '/' . $structureLevel2Key, $newMtime);
3265  }
3266  } else {
3267  touch($vfsUrl . '/' . $structureLevel1Key, $newMtime);
3268  }
3269  }
3270 
3271  return $vfsUrl;
3272  }
3273 
3277  public function ‪getFilesInDirFindsRegularFile()
3278  {
3279  $vfsStreamUrl = $this->‪getFilesInDirCreateTestDirectory();
3280  $files = GeneralUtility::getFilesInDir($vfsStreamUrl);
3281  $this->assertContains('testA.txt', $files);
3282  }
3283 
3287  public function ‪getFilesInDirFindsHiddenFile()
3288  {
3289  $vfsStreamUrl = $this->‪getFilesInDirCreateTestDirectory();
3290  $files = GeneralUtility::getFilesInDir($vfsStreamUrl);
3291  $this->assertContains('.secret.txt', $files);
3292  }
3293 
3299  public function ‪fileExtensionDataProvider()
3300  {
3301  return [
3302  'no space' => [
3303  'setup.typoscript,txt,js,css'
3304  ],
3305  'spaces' => [
3306  'setup.typoscript, txt, js, css'
3307  ],
3308  'mixed' => [
3309  'setup.typoscript , txt,js, css'
3310  ],
3311  'wild' => [
3312  'setup.typoscript, txt, js , css'
3313  ]
3314  ];
3315  }
3316 
3321  public function ‪getFilesInDirByExtensionFindsFiles($fileExtensions)
3322  {
3323  $vfsStreamUrl = $this->‪getFilesInDirCreateTestDirectory();
3324  $files = GeneralUtility::getFilesInDir($vfsStreamUrl, $fileExtensions);
3325  $this->assertContains('double.setup.typoscript', $files);
3326  $this->assertContains('testA.txt', $files);
3327  $this->assertContains('test.js', $files);
3328  $this->assertContains('test.css', $files);
3329  }
3330 
3335  {
3336  $vfsStreamUrl = $this->‪getFilesInDirCreateTestDirectory();
3337  $files = GeneralUtility::getFilesInDir($vfsStreamUrl, 'txt,js');
3338  $this->assertContains('testA.txt', $files);
3339  $this->assertContains('test.js', $files);
3340  $this->assertNotContains('test.css', $files);
3341  }
3342 
3347  {
3348  $vfsStreamUrl = $this->‪getFilesInDirCreateTestDirectory();
3349  $files = GeneralUtility::getFilesInDir($vfsStreamUrl, '', false, '', 'excludeMe.*');
3350  $this->assertContains('test.js', $files);
3351  $this->assertNotContains('excludeMe.txt', $files);
3352  }
3353 
3357  public function ‪getFilesInDirCanPrependPath()
3358  {
3359  $vfsStreamUrl = $this->‪getFilesInDirCreateTestDirectory();
3360  $this->assertContains(
3361  $vfsStreamUrl . '/testA.txt',
3362  GeneralUtility::getFilesInDir($vfsStreamUrl, '', true)
3363  );
3364  }
3365 
3370  {
3371  $vfsStreamUrl = $this->‪getFilesInDirCreateTestDirectory();
3372  $this->assertSame(
3373  array_values(GeneralUtility::getFilesInDir($vfsStreamUrl, '', false)),
3374  ['.secret.txt', 'double.setup.typoscript', 'excludeMe.txt', 'test.css', 'test.js', 'testA.txt', 'testB.txt', 'testC.txt']
3375  );
3376  }
3377 
3381  public function ‪getFilesInDirCanOrderByMtime()
3382  {
3383  $vfsStreamUrl = $this->‪getFilesInDirCreateTestDirectory();
3384  $files = [];
3385  $iterator = new \DirectoryIterator($vfsStreamUrl);
3386  foreach ($iterator as $fileinfo) {
3387  if ($fileinfo->isFile()) {
3388  $files[$fileinfo->getFilename()] = $fileinfo->getMTime();
3389  }
3390  }
3391  asort($files);
3392  $this->assertSame(
3393  array_values(GeneralUtility::getFilesInDir($vfsStreamUrl, '', false, 'mtime')),
3394  array_keys($files)
3395  );
3396  }
3397 
3402  {
3403  $vfsStreamUrl = $this->‪getFilesInDirCreateTestDirectory();
3404  $this->assertArrayHasKey(
3405  md5($vfsStreamUrl . '/testA.txt'),
3406  GeneralUtility::getFilesInDir($vfsStreamUrl)
3407  );
3408  }
3409 
3413  public function ‪getFilesInDirDoesNotFindDirectories()
3414  {
3415  $vfsStreamUrl = $this->‪getFilesInDirCreateTestDirectory();
3416  $this->assertNotContains(
3417  'subDirectory',
3418  GeneralUtility::getFilesInDir($vfsStreamUrl)
3419  );
3420  }
3421 
3428  public function ‪getFilesInDirDoesNotFindDotfiles()
3429  {
3430  $vfsStreamUrl = $this->‪getFilesInDirCreateTestDirectory();
3431  $files = GeneralUtility::getFilesInDir($vfsStreamUrl);
3432  $this->assertNotContains('..', $files);
3433  $this->assertNotContains('.', $files);
3434  }
3435 
3437  // Tests concerning split_fileref
3443  {
3444  $directoryName = $this->getUniqueId('test_') . '.com';
3445  $directoryPath = ‪Environment::getVarPath() . '/tests/';
3446  $directory = $directoryPath . $directoryName;
3447  mkdir($directory, octdec(‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['folderCreateMask']));
3448  $fileInfo = GeneralUtility::split_fileref($directory);
3449  $directoryCreated = is_dir($directory);
3450  rmdir($directory);
3451  $this->assertTrue($directoryCreated);
3452  $this->assertInternalType(\PHPUnit\Framework\Constraint\IsType::TYPE_ARRAY, $fileInfo);
3453  $this->assertEquals($directoryPath, $fileInfo['path']);
3454  $this->assertEquals($directoryName, $fileInfo['file']);
3455  $this->assertEquals($directoryName, $fileInfo['filebody']);
3456  $this->assertEquals('', $fileInfo['fileext']);
3457  $this->assertArrayNotHasKey('realFileext', $fileInfo);
3458  }
3459 
3464  {
3465  $testFile = 'fileadmin/media/someFile.png';
3466  $fileInfo = GeneralUtility::split_fileref($testFile);
3467  $this->assertInternalType(\PHPUnit\Framework\Constraint\IsType::TYPE_ARRAY, $fileInfo);
3468  $this->assertEquals('fileadmin/media/', $fileInfo['path']);
3469  $this->assertEquals('someFile.png', $fileInfo['file']);
3470  $this->assertEquals('someFile', $fileInfo['filebody']);
3471  $this->assertEquals('png', $fileInfo['fileext']);
3472  }
3473 
3475  // Tests concerning dirname
3477 
3481  public function ‪dirnameDataProvider()
3482  {
3483  return [
3484  'absolute path with multiple part and file' => ['/dir1/dir2/script.php', '/dir1/dir2'],
3485  'absolute path with one part' => ['/dir1/', '/dir1'],
3486  'absolute path to file without extension' => ['/dir1/something', '/dir1'],
3487  'relative path with one part and file' => ['dir1/script.php', 'dir1'],
3488  'relative one-character path with one part and file' => ['d/script.php', 'd'],
3489  'absolute zero-part path with file' => ['/script.php', ''],
3490  'empty string' => ['', '']
3491  ];
3492  }
3493 
3500  public function ‪dirnameWithDataProvider($input, $expectedValue)
3501  {
3502  $this->assertEquals($expectedValue, GeneralUtility::dirname($input));
3503  }
3504 
3506  // Tests concerning resolveBackPath
3508 
3512  public function ‪resolveBackPathDataProvider()
3513  {
3514  return [
3515  'empty path' => ['', ''],
3516  'this directory' => ['./', './'],
3517  'relative directory without ..' => ['dir1/dir2/dir3/', 'dir1/dir2/dir3/'],
3518  'relative path without ..' => ['dir1/dir2/script.php', 'dir1/dir2/script.php'],
3519  'absolute directory without ..' => ['/dir1/dir2/dir3/', '/dir1/dir2/dir3/'],
3520  'absolute path without ..' => ['/dir1/dir2/script.php', '/dir1/dir2/script.php'],
3521  'only one directory upwards without trailing slash' => ['..', '..'],
3522  'only one directory upwards with trailing slash' => ['../', '../'],
3523  'one level with trailing ..' => ['dir1/..', ''],
3524  'one level with trailing ../' => ['dir1/../', ''],
3525  'two levels with trailing ..' => ['dir1/dir2/..', 'dir1'],
3526  'two levels with trailing ../' => ['dir1/dir2/../', 'dir1/'],
3527  'leading ../ without trailing /' => ['../dir1', '../dir1'],
3528  'leading ../ with trailing /' => ['../dir1/', '../dir1/'],
3529  'leading ../ and inside path' => ['../dir1/dir2/../dir3/', '../dir1/dir3/'],
3530  'one times ../ in relative directory' => ['dir1/../dir2/', 'dir2/'],
3531  'one times ../ in absolute directory' => ['/dir1/../dir2/', '/dir2/'],
3532  'one times ../ in relative path' => ['dir1/../dir2/script.php', 'dir2/script.php'],
3533  'one times ../ in absolute path' => ['/dir1/../dir2/script.php', '/dir2/script.php'],
3534  'consecutive ../' => ['dir1/dir2/dir3/../../../dir4', 'dir4'],
3535  'distrubuted ../ with trailing /' => ['dir1/../dir2/dir3/../', 'dir2/'],
3536  'distributed ../ without trailing /' => ['dir1/../dir2/dir3/..', 'dir2'],
3537  'multiple distributed and consecutive ../ together' => ['dir1/dir2/dir3/dir4/../../dir5/dir6/dir7/../dir8/', 'dir1/dir2/dir5/dir6/dir8/'],
3538  'dirname with leading ..' => ['dir1/..dir2/dir3/', 'dir1/..dir2/dir3/'],
3539  'dirname with trailing ..' => ['dir1/dir2../dir3/', 'dir1/dir2../dir3/'],
3540  'more times upwards than downwards in directory' => ['dir1/../../', '../'],
3541  'more times upwards than downwards in path' => ['dir1/../../script.php', '../script.php']
3542  ];
3543  }
3544 
3551  public function ‪resolveBackPathWithDataProvider($input, $expectedValue)
3552  {
3553  $this->assertEquals($expectedValue, GeneralUtility::resolveBackPath($input));
3554  }
3555 
3557  // Tests concerning makeInstance, setSingletonInstance, addInstance, purgeInstances
3563  {
3564  $this->expectException(\InvalidArgumentException::class);
3565  $this->expectExceptionCode(1288965219);
3566 
3567  GeneralUtility::makeInstance('');
3568  }
3569 
3574  {
3575  $this->expectException(\InvalidArgumentException::class);
3576  $this->expectExceptionCode(1288965219);
3577 
3578  GeneralUtility::makeInstance(null);
3579  }
3580 
3585  {
3586  $this->expectException(\InvalidArgumentException::class);
3587  $this->expectExceptionCode(1288965219);
3588 
3589  GeneralUtility::makeInstance(0);
3590  }
3591 
3596  {
3597  $this->expectException(\InvalidArgumentException::class);
3598  $this->expectExceptionCode(1288965219);
3599 
3600  GeneralUtility::makeInstance([]);
3601  }
3602 
3607  {
3608  $this->expectException(\InvalidArgumentException::class);
3609  $this->expectExceptionCode(1288965219);
3610 
3611  GeneralUtility::makeInstance(['foo']);
3612  }
3613 
3618  {
3619  $this->expectException(\InvalidArgumentException::class);
3620  $this->expectExceptionCode(1420281366);
3621 
3622  GeneralUtility::makeInstance('\\TYPO3\\CMS\\Backend\\Controller\\BackendController');
3623  }
3624 
3628  public function ‪makeInstanceReturnsClassInstance()
3629  {
3630  $className = get_class($this->getMockBuilder('foo')->getMock());
3631  $this->assertTrue(GeneralUtility::makeInstance($className) instanceof $className);
3632  }
3633 
3638  {
3639  $instance = GeneralUtility::makeInstance(TwoParametersConstructorFixture::class, 'one parameter', 'another parameter');
3640  $this->assertEquals('one parameter', $instance->constructorParameter1, 'The first constructor parameter has not been set.');
3641  $this->assertEquals('another parameter', $instance->constructorParameter2, 'The second constructor parameter has not been set.');
3642  }
3643 
3648  {
3650  ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects'][OriginalClassFixture::class] = ['className' => ReplacementClassFixture::class];
3651  $this->assertInstanceOf(ReplacementClassFixture::class, GeneralUtility::makeInstance(OriginalClassFixture::class));
3652  }
3653 
3658  {
3660  ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects'][OriginalClassFixture::class] = ['className' => ReplacementClassFixture::class];
3661  ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects'][ReplacementClassFixture::class] = ['className' => OtherReplacementClassFixture::class];
3662  $this->assertInstanceOf(OtherReplacementClassFixture::class, GeneralUtility::makeInstance(OriginalClassFixture::class));
3663  }
3664 
3669  {
3670  $className = get_class($this->getMockBuilder('foo')->getMock());
3671  $this->assertNotSame(GeneralUtility::makeInstance($className), GeneralUtility::makeInstance($className));
3672  }
3673 
3678  {
3679  $className = get_class($this->createMock(\‪TYPO3\CMS\Core\SingletonInterface::class));
3680  $this->assertSame(GeneralUtility::makeInstance($className), GeneralUtility::makeInstance($className));
3681  }
3682 
3687  {
3688  $className = get_class($this->createMock(\‪TYPO3\CMS\Core\SingletonInterface::class));
3689  $instance = GeneralUtility::makeInstance($className);
3690  GeneralUtility::purgeInstances();
3691  $this->assertNotSame($instance, GeneralUtility::makeInstance($className));
3692  }
3693 
3697  public function ‪makeInstanceInjectsLogger()
3698  {
3699  $instance = GeneralUtility::makeInstance(GeneralUtilityMakeInstanceInjectLoggerFixture::class);
3700  $this->assertInstanceOf(LoggerInterface::class, $instance->getLogger());
3701  }
3702 
3707  {
3708  $this->expectException(\InvalidArgumentException::class);
3709  $this->expectExceptionCode(1288967479);
3710 
3711  $instance = $this->createMock(\‪TYPO3\CMS\Core\SingletonInterface::class);
3712  GeneralUtility::setSingletonInstance('', $instance);
3713  }
3714 
3719  {
3720  $this->expectException(\InvalidArgumentException::class);
3721  $this->expectExceptionCode(1288967686);
3722 
3723  $instance = $this->getMockBuilder(\‪TYPO3\CMS\Core\SingletonInterface::class)
3724  ->setMethods(['foo'])
3725  ->getMock();
3726  $singletonClassName = get_class($this->createMock(\‪TYPO3\CMS\Core\SingletonInterface::class));
3727  GeneralUtility::setSingletonInstance($singletonClassName, $instance);
3728  }
3729 
3734  {
3735  $instance = $this->createMock(\‪TYPO3\CMS\Core\SingletonInterface::class);
3736  $singletonClassName = get_class($instance);
3737  GeneralUtility::setSingletonInstance($singletonClassName, $instance);
3738  $this->assertSame($instance, GeneralUtility::makeInstance($singletonClassName));
3739  }
3740 
3745  {
3746  $instance1 = $this->createMock(\‪TYPO3\CMS\Core\SingletonInterface::class);
3747  $singletonClassName = get_class($instance1);
3748  $instance2 = new $singletonClassName();
3749  GeneralUtility::setSingletonInstance($singletonClassName, $instance1);
3750  GeneralUtility::setSingletonInstance($singletonClassName, $instance2);
3751  $this->assertSame($instance2, GeneralUtility::makeInstance($singletonClassName));
3752  }
3753 
3758  {
3759  $instance = $this->createMock(\‪TYPO3\CMS\Core\SingletonInterface::class);
3760  $instanceClassName = get_class($instance);
3761  GeneralUtility::setSingletonInstance($instanceClassName, $instance);
3762  $registeredSingletonInstances = GeneralUtility::getSingletonInstances();
3763  $this->assertArrayHasKey($instanceClassName, $registeredSingletonInstances);
3764  $this->assertSame($registeredSingletonInstances[$instanceClassName], $instance);
3765  }
3766 
3771  {
3772  ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects'][SingletonClassFixture::class]['className'] = ExtendedSingletonClassFixture::class;
3773  $anotherInstance = new ExtendedSingletonClassFixture();
3774  GeneralUtility::makeInstance(SingletonClassFixture::class);
3775  GeneralUtility::setSingletonInstance(SingletonClassFixture::class, $anotherInstance);
3776  $result = GeneralUtility::makeInstance(SingletonClassFixture::class);
3777  self::assertSame($anotherInstance, $result);
3778  self::assertEquals(ExtendedSingletonClassFixture::class, get_class($anotherInstance));
3779  }
3780 
3785  {
3786  $instance = $this->createMock(\‪TYPO3\CMS\Core\SingletonInterface::class);
3787  $instanceClassName = get_class($instance);
3788  GeneralUtility::setSingletonInstance($instanceClassName, $instance);
3789  GeneralUtility::resetSingletonInstances([]);
3790  $registeredSingletonInstances = GeneralUtility::getSingletonInstances();
3791  $this->assertArrayNotHasKey($instanceClassName, $registeredSingletonInstances);
3792  }
3793 
3798  {
3799  $instance = $this->createMock(\‪TYPO3\CMS\Core\SingletonInterface::class);
3800  $instanceClassName = get_class($instance);
3801  GeneralUtility::resetSingletonInstances(
3802  [$instanceClassName => $instance]
3803  );
3804  $registeredSingletonInstances = GeneralUtility::getSingletonInstances();
3805  $this->assertArrayHasKey($instanceClassName, $registeredSingletonInstances);
3806  $this->assertSame($registeredSingletonInstances[$instanceClassName], $instance);
3807  }
3808 
3813  {
3814  $this->expectException(\InvalidArgumentException::class);
3815  $this->expectExceptionCode(1288967479);
3816 
3817  $instance = $this->getMockBuilder('foo')->getMock();
3818  GeneralUtility::addInstance('', $instance);
3819  }
3820 
3825  {
3826  $this->expectException(\InvalidArgumentException::class);
3827  $this->expectExceptionCode(1288967686);
3828 
3829  $instance = $this->getMockBuilder('foo')
3830  ->setMethods(['bar'])
3831  ->getMock();
3832  $singletonClassName = get_class($this->createMock('foo'));
3833  GeneralUtility::addInstance($singletonClassName, $instance);
3834  }
3835 
3840  {
3841  $this->expectException(\InvalidArgumentException::class);
3842  $this->expectExceptionCode(1288969325);
3843 
3844  $instance = $this->createMock(\‪TYPO3\CMS\Core\SingletonInterface::class);
3845  GeneralUtility::addInstance(get_class($instance), $instance);
3846  }
3847 
3852  {
3853  $instance = $this->createMock('stdClass');
3854  $className = get_class($instance);
3855  GeneralUtility::addInstance($className, $instance);
3856  $this->assertSame($instance, GeneralUtility::makeInstance($className));
3857  }
3858 
3863  {
3864  $instance = $this->createMock('stdClass');
3865  $className = get_class($instance);
3866  GeneralUtility::addInstance($className, $instance);
3867  $this->assertNotSame(GeneralUtility::makeInstance($className), GeneralUtility::makeInstance($className));
3868  }
3869 
3874  {
3875  $instance1 = $this->createMock('stdClass');
3876  $className = get_class($instance1);
3877  GeneralUtility::addInstance($className, $instance1);
3878  $instance2 = new $className();
3879  GeneralUtility::addInstance($className, $instance2);
3880  $this->assertSame($instance1, GeneralUtility::makeInstance($className), 'The first returned instance does not match the first added instance.');
3881  $this->assertSame($instance2, GeneralUtility::makeInstance($className), 'The second returned instance does not match the second added instance.');
3882  }
3883 
3887  public function ‪purgeInstancesDropsAddedInstance()
3888  {
3889  $instance = $this->createMock('stdClass');
3890  $className = get_class($instance);
3891  GeneralUtility::addInstance($className, $instance);
3892  GeneralUtility::purgeInstances();
3893  $this->assertNotSame($instance, GeneralUtility::makeInstance($className));
3894  }
3895 
3899  public function ‪getFileAbsFileNameDateprovider()
3900  {
3901  return [
3902  'typo3/sysext/core/Resources/Public/Icons/Extension.png' => [
3903  'typo3/sysext/core/Resources/Public/Icons/Extension.png',
3904  ‪Environment::getPublicPath() . '/typo3/sysext/core/Resources/Public/Icons/Extension.png'
3905  ],
3906  'sysext/core/Resources/Public/Icons/Extension.png' => [
3907  'sysext/core/Resources/Public/Icons/Extension.png',
3908  ‪Environment::getPublicPath() . '/sysext/core/Resources/Public/Icons/Extension.png'
3909  ],
3910  './typo3/sysext/core/Resources/Public/Icons/Extension.png' => [
3911  './typo3/sysext/core/Resources/Public/Icons/Extension.png',
3912  ‪Environment::getPublicPath() . '/./typo3/sysext/core/Resources/Public/Icons/Extension.png'
3913  ],
3914  'fileadmin/foo.txt' => [
3915  'fileadmin/foo.txt',
3916  ‪Environment::getPublicPath() . '/fileadmin/foo.txt'
3917  ],
3918  './fileadmin/foo.txt' => [
3919  './fileadmin/foo.txt',
3920  ‪Environment::getPublicPath() . '/./fileadmin/foo.txt'
3921  ],
3922  '../sysext/core/Resources/Public/Icons/Extension.png' => [
3923  '../sysext/core/Resources/Public/Icons/Extension.png',
3924  ''
3925  ],
3926  '../fileadmin/foo.txt' => [
3927  '../fileadmin/foo.txt',
3928  ''
3929  ],
3930  'Public web path . ../sysext/core/Resources/Public/Icons/Extension.png' => [
3931  ‪Environment::getPublicPath() . '/../sysext/core/Resources/Public/Icons/Extension.png',
3932  ''
3933  ],
3934  'Public web path . fileadmin/foo.txt' => [
3935  ‪Environment::getPublicPath() . '/fileadmin/foo.txt',
3936  ‪Environment::getPublicPath() . '/fileadmin/foo.txt'
3937  ],
3938  'Public web path . typo3/sysext/core/Resources/Public/Icons/Extension.png' => [
3939  ‪Environment::getFrameworkBasePath() . '/core/Resources/Public/Icons/Extension.png',
3940  ‪Environment::getFrameworkBasePath() . '/core/Resources/Public/Icons/Extension.png'
3941  ],
3942  'EXT:foo/Resources/Public/Icons/Extension.png' => [
3943  'EXT:foo/Resources/Public/Icons/Extension.png',
3944  ‪Environment::getFrameworkBasePath() . '/foo/Resources/Public/Icons/Extension.png'
3945  ]
3946  ];
3947  }
3948 
3955  public function ‪getFileAbsFileNameReturnsCorrectValues($path, $expected)
3956  {
3957 
3958  // build the dummy package "foo" for use in ExtensionManagementUtility::extPath('foo');
3959  $package = $this->getMockBuilder(Package::class)
3960  ->disableOriginalConstructor()
3961  ->setMethods(['getPackagePath'])
3962  ->getMock();
3964  $packageManager = $this->getMockBuilder(PackageManager::class)
3965  ->setMethods(['isPackageActive', 'getPackage'])
3966  ->disableOriginalConstructor()
3967  ->getMock();
3968  $package->expects($this->any())
3969  ->method('getPackagePath')
3970  ->will($this->returnValue(‪Environment::getPublicPath() . '/typo3/sysext/foo/'));
3971  $packageManager->expects($this->any())
3972  ->method('isPackageActive')
3973  ->with($this->equalTo('foo'))
3974  ->will($this->returnValue(true));
3975  $packageManager->expects($this->any())
3976  ->method('getPackage')
3977  ->with('foo')
3978  ->will($this->returnValue($package));
3980 
3981  $result = GeneralUtility::getFileAbsFileName($path);
3982  $this->assertEquals($expected, $result);
3983  }
3984 
3991  {
3992  $data = [
3993  'double slash in path' => ['path//path'],
3994  'backslash in path' => ['path\\path'],
3995  'directory up in path' => ['path/../path'],
3996  'directory up at the beginning' => ['../path'],
3997  'NUL character in path' => ['path' . "\0" . 'path'],
3998  'BS character in path' => ['path' . chr(8) . 'path'],
3999  'invalid UTF-8-sequence' => ["\xc0" . 'path/path'],
4000  'Could be overlong NUL in some UTF-8 implementations, invalid in RFC3629' => ["\xc0\x80" . 'path/path'],
4001  ];
4002 
4003  // Mixing with regular utf-8
4004  $utf8Characters = 'Ссылка/';
4005  foreach ($data as $key => $value) {
4006  $data[$key . ' with UTF-8 characters prepended'] = [$utf8Characters . $value[0]];
4007  $data[$key . ' with UTF-8 characters appended'] = [$value[0] . $utf8Characters];
4008  }
4009 
4010  // Encoding with UTF-16
4011  foreach ($data as $key => $value) {
4012  $data[$key . ' encoded with UTF-16'] = [mb_convert_encoding($value[0], 'UTF-16')];
4013  }
4014 
4015  return $data;
4016  }
4017 
4025  public function ‪validPathStrDetectsInvalidCharacters($path)
4026  {
4027  $this->assertFalse(GeneralUtility::validPathStr($path));
4028  }
4029 
4033  public function ‪validPathStrDataProvider()
4034  {
4035  $data = [
4036  'normal ascii path' => ['fileadmin/templates/myfile..xml'],
4037  'special character' => ['fileadmin/templates/Ссылка (fce).xml']
4038  ];
4039 
4040  return $data;
4041  }
4042 
4049  public function ‪validPathStrWorksWithUnicodeFileNames($path)
4050  {
4051  $this->assertTrue(GeneralUtility::validPathStr($path));
4052  }
4053 
4057  public function ‪deniedFilesWithoutDenyPatternDataProvider(): array
4058  {
4059  return [
4060  'Nul character in file' => ['image' . "\0" . '.gif'],
4061  'Nul character in file with .php' => ['image.php' . "\0" . '.gif'],
4062  'Nul character and UTF-8 in file' => ['Ссылка' . "\0" . '.gif'],
4063  'Nul character and Latin-1 in file' => ['ÉÐØ' . "\0" . '.gif'],
4064  ];
4065  }
4066 
4074  public function ‪verifyNulCharacterFilesAgainstPatternWithoutFileDenyPattern(string $deniedFile)
4075  {
4076  ‪$GLOBALS['TYPO3_CONF_VARS']['BE']['fileDenyPattern'] = '';
4077  $this->assertFalse(GeneralUtility::verifyFilenameAgainstDenyPattern($deniedFile));
4078  }
4079 
4083  public function ‪deniedFilesWithDefaultDenyPatternDataProvider(): array
4084  {
4085  $data = [
4086  'Nul character in file' => ['image' . "\0", '.gif'],
4087  'Nul character in file with .php' => ['image.php' . "\0", '.gif'],
4088  'Nul character and UTF-8 in file' => ['Ссылка' . "\0", '.gif'],
4089  'Nul character and Latin-1 in file' => ['ÉÐØ' . "\0", '.gif'],
4090  'Lower umlaut .php file' => ['üWithFile', '.php'],
4091  'Upper umlaut .php file' => ['fileWithÜ', '.php'],
4092  'invalid UTF-8-sequence' => ["\xc0" . 'file', '.php'],
4093  'Could be overlong NUL in some UTF-8 implementations, invalid in RFC3629' => ["\xc0\x80" . 'file', '.php'],
4094  'Regular .php file' => ['file' , '.php'],
4095  'Regular .php3 file' => ['file', '.php3'],
4096  'Regular .php5 file' => ['file', '.php5'],
4097  'Regular .php7 file' => ['file', '.php7'],
4098  'Regular .phpsh file' => ['file', '.phpsh'],
4099  'Regular .phtml file' => ['file', '.phtml'],
4100  'Regular .pht file' => ['file', '.pht'],
4101  'Regular .phar file' => ['file', '.phar'],
4102  'Regular .shtml file' => ['file', '.shtml'],
4103  'Regular .cgi file' => ['file', '.cgi'],
4104  'Regular .pl file' => ['file', '.pl'],
4105  'Wrapped .php file ' => ['file', '.php.txt'],
4106  'Wrapped .php3 file' => ['file', '.php3.txt'],
4107  'Wrapped .php5 file' => ['file', '.php5.txt'],
4108  'Wrapped .php7 file' => ['file', '.php7.txt'],
4109  'Wrapped .phpsh file' => ['file', '.phpsh.txt'],
4110  'Wrapped .phtml file' => ['file', '.phtml.txt'],
4111  'Wrapped .pht file' => ['file', '.pht.txt'],
4112  'Wrapped .phar file' => ['file', '.phar.txt'],
4113  'Wrapped .shtml file' => ['file', '.shtml.txt'],
4114  'Wrapped .cgi file' => ['file', '.cgi.txt'],
4115  // allowed "Wrapped .pl file" in order to allow language specific files containing ".pl."
4116  '.htaccess file' => ['', '.htaccess'],
4117  ];
4118 
4119  // Mixing with regular utf-8
4120  $utf8Characters = 'Ссылка';
4121  foreach ($data as $key => $value) {
4122  if ($value[0] === '') {
4123  continue;
4124  }
4125  $data[$key . ' with UTF-8 characters prepended'] = [$utf8Characters . $value[0], $value[1]];
4126  $data[$key . ' with UTF-8 characters appended'] = [$value[0] . $utf8Characters, $value[1]];
4127  }
4128 
4129  // combine to single value
4130  $data = array_map(
4131  function (array $values): array {
4132  return [implode('', $values)];
4133  },
4134  $data
4135  );
4136 
4137  // Encoding with UTF-16
4138  foreach ($data as $key => $value) {
4139  $data[$key . ' encoded with UTF-16'] = [mb_convert_encoding($value[0], 'UTF-16')];
4140  }
4141 
4142  return $data;
4143  }
4144 
4153  {
4154  $this->assertFalse(GeneralUtility::verifyFilenameAgainstDenyPattern($deniedFile));
4155  }
4156 
4160  public function ‪allowedFilesDataProvider(): array
4161  {
4162  return [
4163  'Regular .gif file' => ['image.gif'],
4164  'Regular uppercase .gif file' => ['IMAGE.gif'],
4165  'UTF-8 .gif file' => ['Ссылка.gif'],
4166  'Lower umlaut .jpg file' => ['üWithFile.jpg'],
4167  'Upper umlaut .png file' => ['fileWithÜ.png'],
4168  'Latin-1 .gif file' => ['ÉÐØ.gif'],
4169  'Wrapped .pl file' => ['file.pl.txt'],
4170  ];
4171  }
4172 
4180  public function ‪verifyFilenameAgainstDenyPatternAcceptAllowedFiles(string $allowedFile)
4181  {
4182  $this->assertTrue(GeneralUtility::verifyFilenameAgainstDenyPattern($allowedFile));
4183  }
4184 
4186  // Tests concerning copyDirectory
4188 
4193  {
4194  $sourceDirectory = 'typo3temp/var/tests/' . $this->getUniqueId('test_') . '/';
4195  $absoluteSourceDirectory = ‪Environment::getPublicPath() . '/' . $sourceDirectory;
4196  $this->testFilesToDelete[] = $absoluteSourceDirectory;
4197  GeneralUtility::mkdir($absoluteSourceDirectory);
4198 
4199  $targetDirectory = 'typo3temp/var/tests/' . $this->getUniqueId('test_') . '/';
4200  $absoluteTargetDirectory = ‪Environment::getPublicPath() . '/' . $targetDirectory;
4201  $this->testFilesToDelete[] = $absoluteTargetDirectory;
4202 
4203  GeneralUtility::writeFileToTypo3tempDir($absoluteSourceDirectory . 'file', '42');
4204  GeneralUtility::mkdir($absoluteSourceDirectory . 'foo');
4205  GeneralUtility::writeFileToTypo3tempDir($absoluteSourceDirectory . 'foo/file', '42');
4206 
4207  GeneralUtility::copyDirectory($sourceDirectory, $targetDirectory);
4208 
4209  $this->assertFileExists($absoluteTargetDirectory . 'file');
4210  $this->assertFileExists($absoluteTargetDirectory . 'foo/file');
4211  }
4212 
4217  {
4218  $sourceDirectory = 'typo3temp/var/tests/' . $this->getUniqueId('test_') . '/';
4219  $absoluteSourceDirectory = ‪Environment::getPublicPath() . '/' . $sourceDirectory;
4220  $this->testFilesToDelete[] = $absoluteSourceDirectory;
4221  GeneralUtility::mkdir($absoluteSourceDirectory);
4222 
4223  $targetDirectory = 'typo3temp/var/tests/' . $this->getUniqueId('test_') . '/';
4224  $absoluteTargetDirectory = ‪Environment::getPublicPath() . '/' . $targetDirectory;
4225  $this->testFilesToDelete[] = $absoluteTargetDirectory;
4226 
4227  GeneralUtility::writeFileToTypo3tempDir($absoluteSourceDirectory . 'file', '42');
4228  GeneralUtility::mkdir($absoluteSourceDirectory . 'foo');
4229  GeneralUtility::writeFileToTypo3tempDir($absoluteSourceDirectory . 'foo/file', '42');
4230 
4231  GeneralUtility::copyDirectory($absoluteSourceDirectory, $absoluteTargetDirectory);
4232 
4233  $this->assertFileExists($absoluteTargetDirectory . 'file');
4234  $this->assertFileExists($absoluteTargetDirectory . 'foo/file');
4235  }
4236 
4238  // Tests concerning deprecation log
4240 
4242  // Tests concerning callUserFunction
4244 
4251  public function ‪callUserFunctionWillThrowExceptionForInvalidParameters($functionName, $expectedException)
4252  {
4253  $this->expectException(\InvalidArgumentException::class);
4254  $this->expectExceptionCode($expectedException);
4255 
4256  $inputData = ['foo' => 'bar'];
4257  GeneralUtility::callUserFunction($functionName, $inputData, $this);
4258  }
4259 
4267  {
4268  return [
4269  'Function is not prefixed' => [self::class . '->calledUserFunction', 1294585865],
4270  'Class doesn\'t exists' => ['t3lib_divTest21345->user_calledUserFunction', 1294585866],
4271  'No method name' => [self::class, 1294585867],
4272  'No class name' => ['->user_calledUserFunction', 1294585866],
4273  'No function name' => ['', 1294585867]
4274  ];
4275  }
4276 
4284  public function ‪callUserFunctionCanCallFunction()
4285  {
4286  $inputData = ['foo' => 'bar'];
4287  $result = GeneralUtility::callUserFunction(function () {
4288  return 'Worked fine';
4289  }, $inputData, $this, '');
4290  $this->assertEquals('Worked fine', $result);
4291  }
4292 
4296  public function ‪callUserFunctionCanCallMethod()
4297  {
4298  $inputData = ['foo' => 'bar'];
4299  $result = GeneralUtility::callUserFunction(self::class . '->user_calledUserFunction', $inputData, $this);
4300  $this->assertEquals('Worked fine', $result);
4301  }
4302 
4306  public function ‪user_calledUserFunction()
4307  {
4308  return 'Worked fine';
4309  }
4310 
4314  public function ‪callUserFunctionAcceptsClosures()
4315  {
4316  $inputData = ['foo' => 'bar'];
4317  $closure = function ($parameters, $reference) use ($inputData) {
4318  $reference->assertEquals($inputData, $parameters, 'Passed data doesn\'t match expected output');
4319  return 'Worked fine';
4320  };
4321  $this->assertEquals('Worked fine', GeneralUtility::callUserFunction($closure, $inputData, $this));
4322  }
4323 
4327  public function ‪callUserFunctionTrimsSpaces()
4328  {
4329  $inputData = ['foo' => 'bar'];
4330  $result = GeneralUtility::callUserFunction("\t" . self::class . '->user_calledUserFunction ', $inputData, $this);
4331  $this->assertEquals('Worked fine', $result);
4332  }
4333 
4338  {
4339  $directory = ‪Environment::getVarPath() . '/tests/' . $this->getUniqueId('directory_');
4340  mkdir($directory);
4341  $filesAndDirectories = GeneralUtility::getAllFilesAndFoldersInPath([], $directory, '', true);
4342  $check = true;
4343  foreach ($filesAndDirectories as $md5 => $path) {
4344  if (!preg_match('/^[a-f0-9]{32}$/', $md5)) {
4345  $check = false;
4346  }
4347  }
4348  GeneralUtility::rmdir($directory);
4349  $this->assertTrue($check);
4350  }
4351 
4359  {
4360  $input = [
4361  'el' => []
4362  ];
4363 
4364  ‪$output = GeneralUtility::array2xml($input);
4365 
4366  $this->assertEquals('<phparray>
4367  <el type="array"></el>
4368 </phparray>', ‪$output);
4369  }
4370 
4374  public function ‪xml2arrayHandlesWhitespacesDataProvider(): array
4375  {
4376  $headerVariants = [
4377  'utf-8' => '<?xml version="1.0" encoding="utf-8" standalone="yes"?>',
4378  'UTF-8' => '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>',
4379  'no-encoding' => '<?xml version="1.0" standalone="yes"?>',
4380  'iso-8859-1' => '<?xml version="1.0" encoding="iso-8859-1" standalone="yes"?>',
4381  'ISO-8859-1' => '<?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?>',
4382  ];
4383  $data = [];
4384  foreach ($headerVariants as $identifier => $headerVariant) {
4385  $data += [
4386  'inputWithoutWhitespaces-' . $identifier => [
4387  $headerVariant . '<T3FlexForms>
4388  <data>
4389  <field index="settings.persistenceIdentifier">
4390  <value index="vDEF">egon</value>
4391  </field>
4392  </data>
4393  </T3FlexForms>'
4394  ],
4395  'inputWithPrecedingWhitespaces-' . $identifier => [
4396  CR . ' ' . $headerVariant . '<T3FlexForms>
4397  <data>
4398  <field index="settings.persistenceIdentifier">
4399  <value index="vDEF">egon</value>
4400  </field>
4401  </data>
4402  </T3FlexForms>'
4403  ],
4404  'inputWithTrailingWhitespaces-' . $identifier => [
4405  $headerVariant . '<T3FlexForms>
4406  <data>
4407  <field index="settings.persistenceIdentifier">
4408  <value index="vDEF">egon</value>
4409  </field>
4410  </data>
4411  </T3FlexForms>' . CR . ' '
4412  ],
4413  'inputWithPrecedingAndTrailingWhitespaces-' . $identifier => [
4414  CR . ' ' . $headerVariant . '<T3FlexForms>
4415  <data>
4416  <field index="settings.persistenceIdentifier">
4417  <value index="vDEF">egon</value>
4418  </field>
4419  </data>
4420  </T3FlexForms>' . CR . ' '
4421  ],
4422  ];
4423  }
4424  return $data;
4425  }
4426 
4432  public function ‪xml2arrayHandlesWhitespaces(string $input)
4433  {
4434  $cacheManagerProphecy = $this->prophesize(CacheManager::class);
4435  $cacheProphecy = $this->prophesize(FrontendInterface::class);
4436  $cacheManagerProphecy->getCache('cache_runtime')->willReturn($cacheProphecy->reveal());
4437  $cacheProphecy->get('generalUtilityXml2Array')->shouldBeCalled()->willReturn(false);
4438  $cacheProphecy->set('generalUtilityXml2Array', Argument::cetera())->shouldBeCalled();
4439  GeneralUtility::setSingletonInstance(CacheManager::class, $cacheManagerProphecy->reveal());
4440  $expected = [
4441  'data' => [
4442  'settings.persistenceIdentifier' => [
4443  'vDEF' => 'egon',
4444  ]
4445  ],
4446  ];
4447  $this->assertSame($expected, GeneralUtility::xml2array($input));
4448  }
4449 
4453  public function ‪xml2arrayHandlesTagNamespacesDataProvider(): array
4454  {
4455  return [
4456  'inputWithNameSpaceOnRootLevel' => [
4457  '<?xml version="1.0" encoding="utf-8" standalone="yes"?>
4458  <T3:T3FlexForms>
4459  <data>
4460  <field index="settings.persistenceIdentifier">
4461  <value index="vDEF">egon</value>
4462  </field>
4463  </data>
4464  </T3:T3FlexForms>'
4465  ],
4466  'inputWithNameSpaceOnNonRootLevel' => [
4467  '<?xml version="1.0" encoding="utf-8" standalone="yes"?>
4468  <T3FlexForms>
4469  <data>
4470  <T3:field index="settings.persistenceIdentifier">
4471  <value index="vDEF">egon</value>
4472  </T3:field>
4473  </data>
4474  </T3FlexForms>'
4475  ],
4476  'inputWithNameSpaceOnRootAndNonRootLevel' => [
4477  '<?xml version="1.0" encoding="utf-8" standalone="yes"?>
4478  <T3:T3FlexForms>
4479  <data>
4480  <T3:field index="settings.persistenceIdentifier">
4481  <value index="vDEF">egon</value>
4482  </T3:field>
4483  </data>
4484  </T3:T3FlexForms>'
4485  ],
4486  ];
4487  }
4488 
4494  public function ‪xml2arrayHandlesTagNamespaces(string $input)
4495  {
4496  $cacheManagerProphecy = $this->prophesize(CacheManager::class);
4497  $cacheProphecy = $this->prophesize(FrontendInterface::class);
4498  $cacheManagerProphecy->getCache('cache_runtime')->willReturn($cacheProphecy->reveal());
4499  $cacheProphecy->get('generalUtilityXml2Array')->shouldBeCalled()->willReturn(false);
4500  $cacheProphecy->set('generalUtilityXml2Array', Argument::cetera())->shouldBeCalled();
4501  GeneralUtility::setSingletonInstance(CacheManager::class, $cacheManagerProphecy->reveal());
4502  $expected = [
4503  'data' => [
4504  'settings.persistenceIdentifier' => [
4505  'vDEF' => 'egon',
4506  ]
4507  ],
4508  ];
4509  $this->assertSame($expected, GeneralUtility::xml2array($input, 'T3:'));
4510  }
4511 
4515  public function ‪xml2arrayHandlesDocumentTagDataProvider(): array
4516  {
4517  return [
4518  'input' => [
4519  '<?xml version="1.0" encoding="utf-8" standalone="yes"?>
4520  <T3FlexForms>
4521  <data>
4522  <field index="settings.persistenceIdentifier">
4523  <value index="vDEF">egon</value>
4524  </field>
4525  </data>
4526  </T3FlexForms>',
4527  'T3FlexForms'
4528  ],
4529  'input-with-root-namespace' => [
4530  '<?xml version="1.0" encoding="utf-8" standalone="yes"?>
4531  <T3:T3FlexForms>
4532  <data>
4533  <field index="settings.persistenceIdentifier">
4534  <value index="vDEF">egon</value>
4535  </field>
4536  </data>
4537  </T3:T3FlexForms>',
4538  'T3:T3FlexForms'
4539  ],
4540  'input-with-namespace' => [
4541  '<?xml version="1.0" encoding="utf-8" standalone="yes"?>
4542  <T3FlexForms>
4543  <data>
4544  <T3:field index="settings.persistenceIdentifier">
4545  <value index="vDEF">egon</value>
4546  </T3:field>
4547  </data>
4548  </T3FlexForms>',
4549  'T3FlexForms'
4550  ],
4551  ];
4552  }
4553 
4560  public function ‪xml2arrayHandlesDocumentTag(string $input, string $docTag)
4561  {
4562  $cacheManagerProphecy = $this->prophesize(CacheManager::class);
4563  $cacheProphecy = $this->prophesize(FrontendInterface::class);
4564  $cacheManagerProphecy->getCache('cache_runtime')->willReturn($cacheProphecy->reveal());
4565  $cacheProphecy->get('generalUtilityXml2Array')->shouldBeCalled()->willReturn(false);
4566  $cacheProphecy->set('generalUtilityXml2Array', Argument::cetera())->shouldBeCalled();
4567  GeneralUtility::setSingletonInstance(CacheManager::class, $cacheManagerProphecy->reveal());
4568  $expected = [
4569  'data' => [
4570  'settings.persistenceIdentifier' => [
4571  'vDEF' => 'egon',
4572  ]
4573  ],
4574  '_DOCUMENT_TAG' => $docTag
4575  ];
4576  $this->assertSame($expected, GeneralUtility::xml2array($input, '', true));
4577  }
4578 
4582  public function ‪xml2ArrayHandlesBigXmlContentDataProvider(): array
4583  {
4584  return [
4585  '1mb' => [
4586  '<?xml version="1.0" encoding="utf-8" standalone="yes"?>
4587  <T3:T3FlexForms>
4588  <data>
4589  <field index="settings.persistenceIdentifier">
4590  <value index="vDEF">' . str_repeat('1', 1024 * 1024) . '</value>
4591  </field>
4592  </data>
4593  </T3:T3FlexForms>',
4594  str_repeat('1', 1024 * 1024)
4595  ],
4596  '5mb' => [
4597  '<?xml version="1.0" encoding="utf-8" standalone="yes"?>
4598  <T3:T3FlexForms>
4599  <data>
4600  <field index="settings.persistenceIdentifier">
4601  <value index="vDEF">' . str_repeat('1', 5 * 1024 * 1024) . '</value>
4602  </field>
4603  </data>
4604  </T3:T3FlexForms>',
4605  str_repeat('1', 5 * 1024 * 1024)
4606  ],
4607  ];
4608  }
4609 
4616  public function ‪xml2ArrayHandlesBigXmlContent(string $input, string $testValue)
4617  {
4618  $cacheManagerProphecy = $this->prophesize(CacheManager::class);
4619  $cacheProphecy = $this->prophesize(FrontendInterface::class);
4620  $cacheManagerProphecy->getCache('cache_runtime')->willReturn($cacheProphecy->reveal());
4621  $cacheProphecy->get('generalUtilityXml2Array')->shouldBeCalled()->willReturn(false);
4622  $cacheProphecy->set('generalUtilityXml2Array', Argument::cetera())->shouldBeCalled();
4623  GeneralUtility::setSingletonInstance(CacheManager::class, $cacheManagerProphecy->reveal());
4624  $expected = [
4625  'data' => [
4626  'settings.persistenceIdentifier' => [
4627  'vDEF' => $testValue,
4628  ]
4629  ],
4630  ];
4631  $this->assertSame($expected, GeneralUtility::xml2array($input));
4632  }
4633 
4644  {
4645  $cacheManagerProphecy = $this->prophesize(CacheManager::class);
4646  $cacheProphecy = $this->prophesize(FrontendInterface::class);
4647  $cacheManagerProphecy->getCache('cache_runtime')->willReturn($cacheProphecy->reveal());
4648  $cacheProphecy->get('generalUtilityXml2Array')->shouldBeCalled()->willReturn(false);
4649  $cacheProphecy->set('generalUtilityXml2Array', Argument::cetera())->shouldBeCalled();
4650  GeneralUtility::setSingletonInstance(CacheManager::class, $cacheManagerProphecy->reveal());
4651  $input = '<?xml version="1.0" encoding="utf-8" standalone="yes"?>
4652  <T3:T3FlexForms>
4653  <data>
4654  <field index="settings.persistenceIdentifier">
4655  <value index="vDEF">' . str_repeat('1', 10 * 1024 * 1024) . '</value>
4656  </field>
4657  </data>
4658  </T3:T3FlexForms>';
4659  $this->assertContains('No memory', GeneralUtility::xml2array($input));
4660  }
4661 
4666  {
4667  $prefix = '<?xml version="1.0" encoding="utf-8" standalone="yes"?><T3FlexForms><field index="index">';
4668  $suffix = '</field></T3FlexForms>';
4669  return [
4670  'no-type string' => [
4671  $prefix . '<value index="vDEF">foo bar</value>' . $suffix,
4672  'foo bar'
4673  ],
4674  'no-type integer' => [
4675  $prefix . '<value index="vDEF">123</value>' . $suffix,
4676  '123'
4677  ],
4678  'no-type double' => [
4679  $prefix . '<value index="vDEF">1.23</value>' . $suffix,
4680  '1.23'
4681  ],
4682  'integer integer' => [
4683  $prefix . '<value index="vDEF" type="integer">123</value>' . $suffix,
4684  123
4685  ],
4686  'integer double' => [
4687  $prefix . '<value index="vDEF" type="integer">1.23</value>' . $suffix,
4688  1
4689  ],
4690  'double integer' => [
4691  $prefix . '<value index="vDEF" type="double">123</value>' . $suffix,
4692  123.0
4693  ],
4694  'double double' => [
4695  $prefix . '<value index="vDEF" type="double">1.23</value>' . $suffix,
4696  1.23
4697  ],
4698  'boolean 0' => [
4699  $prefix . '<value index="vDEF" type="boolean">0</value>' . $suffix,
4700  false
4701  ],
4702  'boolean 1' => [
4703  $prefix . '<value index="vDEF" type="boolean">1</value>' . $suffix,
4704  true
4705  ],
4706  'boolean true' => [
4707  $prefix . '<value index="vDEF" type="boolean">true</value>' . $suffix,
4708  true
4709  ],
4710  'boolean false' => [
4711  $prefix . '<value index="vDEF" type="boolean">false</value>' . $suffix,
4712  true // sic(!)
4713  ],
4714  'NULL' => [
4715  $prefix . '<value index="vDEF" type="NULL"></value>' . $suffix,
4716  null
4717  ],
4718  'NULL string' => [
4719  $prefix . '<value index="vDEF" type="NULL">foo bar</value>' . $suffix,
4720  null
4721  ],
4722  'NULL integer' => [
4723  $prefix . '<value index="vDEF" type="NULL">123</value>' . $suffix,
4724  null
4725  ],
4726  'NULL double' => [
4727  $prefix . '<value index="vDEF" type="NULL">1.23</value>' . $suffix,
4728  null
4729  ],
4730  'array' => [
4731  $prefix . '<value index="vDEF" type="array"></value>' . $suffix,
4732  []
4733  ],
4734  ];
4735  }
4736 
4743  public function ‪xml2ArrayHandlesAttributeTypes(string $input, $expected)
4744  {
4745  $cacheManagerProphecy = $this->prophesize(CacheManager::class);
4746  $cacheProphecy = $this->prophesize(FrontendInterface::class);
4747  $cacheManagerProphecy->getCache('cache_runtime')->willReturn($cacheProphecy->reveal());
4748  $cacheProphecy->get('generalUtilityXml2Array')->shouldBeCalled()->willReturn(false);
4749  $cacheProphecy->set('generalUtilityXml2Array', Argument::cetera())->shouldBeCalled();
4750  GeneralUtility::setSingletonInstance(CacheManager::class, $cacheManagerProphecy->reveal());
4751  $result = GeneralUtility::xml2array($input);
4752  $this->assertSame($expected, $result['index']['vDEF']);
4753  }
4754 
4761  public function ‪idnaEncodeConvertsUnicodeCharsToASCIIString($actual, $expected)
4762  {
4763  $result = GeneralUtility::idnaEncode($actual);
4764  $this->assertSame($expected, $result);
4765  }
4766 
4773  public function ‪idnaEncodeDataProvider()
4774  {
4775  return [
4776  'empty string' => [
4777  '',
4778  ''
4779  ],
4780  'null value' => [
4781  null,
4782  ''
4783  ],
4784  'string with ascii chars' => [
4785  'example',
4786  'example'
4787  ],
4788  'domain (1) with utf8 chars' => [
4789  'dömäin.example',
4790  'xn--dmin-moa0i.example'
4791  ],
4792  'domain (2) with utf8 chars' => [
4793  'äaaa.example',
4794  'xn--aaa-pla.example'
4795  ],
4796  'domain (3) with utf8 chars' => [
4797  'déjà.vu.example',
4798  'xn--dj-kia8a.vu.example'
4799  ],
4800  'domain (4) with utf8 chars' => [
4801  'foo.âbcdéf.example',
4802  'foo.xn--bcdf-9na9b.example'
4803  ],
4804  'domain with utf8 char (german umlaut)' => [
4805  'exömple.com',
4806  'xn--exmple-xxa.com'
4807  ],
4808  'email with utf8 char (german umlaut)' => [
4809  'joe.doe@dömäin.de',
4810  'joe.doe@xn--dmin-moa0i.de'
4811  ],
4812  'email with utf8 char and @ in local (german umlaut)' => [
4813  'joe@doe@dömäin.de',
4814  'joe@doe@xn--dmin-moa0i.de'
4815  ],
4816  'email with utf8 char and @ in local (2) (german umlaut)' => [
4817  '"joe@doe"@dömäin.de',
4818  '"joe@doe"@xn--dmin-moa0i.de'
4819  ],
4820  ];
4821  }
4822 
4823  public function ‪splitHeaderLinesDataProvider(): array
4824  {
4825  return [
4826  'multi-line headers' => [
4827  ['Content-Type' => 'multipart/form-data; boundary=something', 'Content-Language' => 'de-DE, en-CA'],
4828  ['Content-Type' => 'multipart/form-data; boundary=something', 'Content-Language' => 'de-DE, en-CA'],
4829  ]
4830  ];
4831  }
4832 
4839  public function ‪splitHeaderLines(array $headers, array $expectedHeaders): void
4840  {
4841  $stream = $this->prophesize(StreamInterface::class);
4842  $response = $this->prophesize(ResponseInterface::class);
4843  $response->getBody()->willReturn($stream);
4844  $requestFactory = $this->prophesize(RequestFactory::class);
4845  $requestFactory->request(Argument::cetera())->willReturn($response);
4846 
4847  GeneralUtility::addInstance(RequestFactory::class, $requestFactory->reveal());
4848  GeneralUtility::getUrl('http://example.com', 0, $headers);
4849 
4850  $requestFactory->request(Argument::any(), Argument::any(), ['headers' => $expectedHeaders])->shouldHaveBeenCalled();
4851  }
4852 
4853  public function ‪locationHeaderUrlDataProvider(): array
4854  {
4855  return [
4856  'simple relative path' => [
4857  'foo',
4858  'foo.bar.test',
4859  'http://foo.bar.test/foo'
4860  ],
4861  'path beginning with slash' => [
4862  '/foo',
4863  'foo.bar.test',
4864  'http://foo.bar.test/foo'
4865  ],
4866  'path with full domain and https scheme' => [
4867  'https://example.com/foo',
4868  'foo.bar.test',
4869  'https://example.com/foo'
4870  ],
4871  'path with full domain and http scheme' => [
4872  'http://example.com/foo',
4873  'foo.bar.test',
4874  'http://example.com/foo'
4875  ],
4876  'path with full domain and relative scheme' => [
4877  '//example.com/foo',
4878  'foo.bar.test',
4879  '//example.com/foo'
4880  ],
4881  ];
4882  }
4883 
4892  public function ‪locationHeaderUrl($path, $host, $expected): void
4893  {
4896  true,
4897  false,
4903  ‪Environment::isWindows() ? 'WINDOWS' : 'UNIX'
4904  );
4905  $_SERVER['HTTP_HOST'] = $host;
4906  $_SERVER['SCRIPT_NAME'] = '/index.php';
4907  $result = GeneralUtility::locationHeaderUrl($path);
4908  self::assertSame($expected, $result);
4909  }
4910 }
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\xml2arrayHandlesWhitespaces
‪xml2arrayHandlesWhitespaces(string $input)
Definition: GeneralUtilityTest.php:4429
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\sanitizeLocalUrlAcceptsEncodedValidPaths
‪sanitizeLocalUrlAcceptsEncodedValidPaths($path)
Definition: GeneralUtilityTest.php:1973
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\cmpFqdnInvalidDataProvider
‪static array cmpFqdnInvalidDataProvider()
Definition: GeneralUtilityTest.php:547
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\gpDataProvider
‪array gpDataProvider()
Definition: GeneralUtilityTest.php:140
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\makeInstanceWithZeroStringClassNameThrowsException
‪makeInstanceWithZeroStringClassNameThrowsException()
Definition: GeneralUtilityTest.php:3581
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\sanitizeLocalUrlAcceptsEncodedValidUrls
‪sanitizeLocalUrlAcceptsEncodedValidUrls($url, $host, $subDirectory)
Definition: GeneralUtilityTest.php:2052
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\writeFileToTypo3tempDirWorksWithValidPath
‪writeFileToTypo3tempDirWorksWithValidPath($filePath)
Definition: GeneralUtilityTest.php:2881
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\makeInstanceResolvesConfiguredImplementationsRecursively
‪makeInstanceResolvesConfiguredImplementationsRecursively()
Definition: GeneralUtilityTest.php:3654
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\getSingletonInstancesContainsPreviouslySetSingletonInstance
‪getSingletonInstancesContainsPreviouslySetSingletonInstance()
Definition: GeneralUtilityTest.php:3754
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\rmdirDoesNotRemoveDirectoryWithFilesAndReturnsFalseIfRecursiveDeletionIsOff
‪rmdirDoesNotRemoveDirectoryWithFilesAndReturnsFalseIfRecursiveDeletionIsOff()
Definition: GeneralUtilityTest.php:3157
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\dirnameWithDataProvider
‪dirnameWithDataProvider($input, $expectedValue)
Definition: GeneralUtilityTest.php:3497
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\underscoredToLowerCamelCase
‪underscoredToLowerCamelCase($expected, $inputString)
Definition: GeneralUtilityTest.php:1788
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\validPathStrDataProvider
‪validPathStrDataProvider()
Definition: GeneralUtilityTest.php:4030
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\xml2arrayHandlesWhitespacesDataProvider
‪string[][] xml2arrayHandlesWhitespacesDataProvider()
Definition: GeneralUtilityTest.php:4371
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\cmpIPv6DataProviderNotMatching
‪static array cmpIPv6DataProviderNotMatching()
Definition: GeneralUtilityTest.php:326
‪TYPO3\CMS\Core\Tests\Unit\Utility\Fixtures\GeneralUtilityMakeInstanceInjectLoggerFixture
Definition: GeneralUtilityMakeInstanceInjectLoggerFixture.php:26
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\getFilesInDirReturnsArrayWithMd5OfElementAndPathAsArrayKey
‪getFilesInDirReturnsArrayWithMd5OfElementAndPathAsArrayKey()
Definition: GeneralUtilityTest.php:3398
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\IPv6Bin2HexDataProviderCorrect
‪static array IPv6Bin2HexDataProviderCorrect()
Definition: GeneralUtilityTest.php:385
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\implodeArrayForUrlCanSkipEmptyParameters
‪implodeArrayForUrlCanSkipEmptyParameters()
Definition: GeneralUtilityTest.php:1026
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\isFirstPartOfStrReturnsFalseForNotMatchingFirstPart
‪isFirstPartOfStrReturnsFalseForNotMatchingFirstPart($string, $part)
Definition: GeneralUtilityTest.php:788
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\makeInstanceWithBeginningSlashInClassNameThrowsException
‪makeInstanceWithBeginningSlashInClassNameThrowsException()
Definition: GeneralUtilityTest.php:3614
‪TYPO3\CMS\Core\Tests\Unit\Utility\Fixtures\GeneralUtilityFixture\resetFinalClassNameCache
‪static resetFinalClassNameCache()
Definition: GeneralUtilityFixture.php:61
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\tempnamReturnsAbsolutePathInsideDocumentRoot
‪tempnamReturnsAbsolutePathInsideDocumentRoot()
Definition: GeneralUtilityTest.php:2232
‪TYPO3\CMS\Core\Core\Environment\getPublicPath
‪static string getPublicPath()
Definition: Environment.php:153
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\validPathStrInvalidCharactersDataProvider
‪array validPathStrInvalidCharactersDataProvider()
Definition: GeneralUtilityTest.php:3987
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\underscoredToLowerCamelCaseDataProvider
‪array underscoredToLowerCamelCaseDataProvider()
Definition: GeneralUtilityTest.php:1776
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\copyDirectoryCopiesFilesAndDirectoriesWithRelativePaths
‪copyDirectoryCopiesFilesAndDirectoriesWithRelativePaths()
Definition: GeneralUtilityTest.php:4189
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\validIpReturnsTrueForValidIp
‪validIpReturnsTrueForValidIp($ip)
Definition: GeneralUtilityTest.php:477
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\array2xmlConvertsEmptyArraysToElementWithoutContent
‪array2xmlConvertsEmptyArraysToElementWithoutContent()
Definition: GeneralUtilityTest.php:4355
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\cmpFqdnReturnsTrue
‪cmpFqdnReturnsTrue($baseHost, $list)
Definition: GeneralUtilityTest.php:537
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\invalidIpDataProvider
‪static array invalidIpDataProvider()
Definition: GeneralUtilityTest.php:487
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\hmacReturnsEqualHashesForEqualInput
‪hmacReturnsEqualHashesForEqualInput()
Definition: GeneralUtilityTest.php:2359
‪TYPO3\CMS\Core\Tests\Unit\Utility\Fixtures\GeneralUtilityFixture
Definition: GeneralUtilityFixture.php:23
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\mkdirCreatesHiddenDirectory
‪mkdirCreatesHiddenDirectory()
Definition: GeneralUtilityTest.php:2720
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\validURLReturnsFalseForInvalidRessoure
‪validURLReturnsFalseForInvalidRessoure($url)
Definition: GeneralUtilityTest.php:1892
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\inListForItemNotContainedReturnsFalseDataProvider
‪array inListForItemNotContainedReturnsFalseDataProvider()
Definition: GeneralUtilityTest.php:607
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\hmacReturnsNoEqualHashesForNonEqualInput
‪hmacReturnsNoEqualHashesForNonEqualInput()
Definition: GeneralUtilityTest.php:2369
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\NO_FIX_PERMISSIONS_ON_WINDOWS
‪const NO_FIX_PERMISSIONS_ON_WINDOWS
Definition: GeneralUtilityTest.php:50
‪TYPO3\CMS\Core\Tests\Unit\Utility\Fixtures\GeneralUtilityFixture\isAllowedHostHeaderValue
‪static bool isAllowedHostHeaderValue($hostHeaderValue)
Definition: GeneralUtilityFixture.php:34
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\makeInstanceWithEmptyArrayThrowsException
‪makeInstanceWithEmptyArrayThrowsException()
Definition: GeneralUtilityTest.php:3592
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\validEmailValidDataProvider
‪array validEmailValidDataProvider()
Definition: GeneralUtilityTest.php:906
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\splitHeaderLines
‪splitHeaderLines(array $headers, array $expectedHeaders)
Definition: GeneralUtilityTest.php:4836
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\htmlspecialcharsDecodeReturnsDecodedString
‪htmlspecialcharsDecodeReturnsDecodedString()
Definition: GeneralUtilityTest.php:890
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\splitHeaderLinesDataProvider
‪splitHeaderLinesDataProvider()
Definition: GeneralUtilityTest.php:4820
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\rmdirRemovesDirectoriesRecursiveAndReturnsTrue
‪rmdirRemovesDirectoriesRecursiveAndReturnsTrue()
Definition: GeneralUtilityTest.php:3173
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\explodeUrl2ArrayDataProvider
‪array explodeUrl2ArrayDataProvider()
Definition: GeneralUtilityTest.php:1057
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\getAllFilesAndFoldersInPathReturnsArrayWithMd5Keys
‪getAllFilesAndFoldersInPathReturnsArrayWithMd5Keys()
Definition: GeneralUtilityTest.php:4334
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\mkdirDeepCreatesDirectoryWithDoubleSlashes
‪mkdirDeepCreatesDirectoryWithDoubleSlashes($directoryToCreate)
Definition: GeneralUtilityTest.php:2934
‪TYPO3\CMS\Core\Tests\Unit\Utility\Fixtures\SingletonClassFixture
Definition: SingletonClassFixture.php:23
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\fixPermissionsSetsGroup
‪fixPermissionsSetsGroup()
Definition: GeneralUtilityTest.php:2461
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\quoteJsValueTest
‪quoteJsValueTest($input, $expected)
Definition: GeneralUtilityTest.php:2436
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\implodeArrayForUrlBuildsValidParameterString
‪implodeArrayForUrlBuildsValidParameterString($name, $input, $expected)
Definition: GeneralUtilityTest.php:1018
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\resolveBackPathDataProvider
‪array< array > resolveBackPathDataProvider()
Definition: GeneralUtilityTest.php:3509
‪TYPO3\CMS\Core\Tests\Unit\Utility\Fixtures\GeneralUtilityFixture\setAllowHostHeaderValue
‪static setAllowHostHeaderValue($allowHostHeaderValue)
Definition: GeneralUtilityFixture.php:43
‪TYPO3\CMS\Core\Tests\Unit\Utility\Fixtures\GeneralUtilityFilesystemFixture\writeFileToTypo3tempDir
‪static string writeFileToTypo3tempDir($filepath, $content)
Definition: GeneralUtilityFilesystemFixture.php:64
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\mkdirSetsGroupOwnershipOfCreatedDirectory
‪mkdirSetsGroupOwnershipOfCreatedDirectory()
Definition: GeneralUtilityTest.php:2762
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\setSingletonInstanceMakesMakeInstanceReturnThatInstance
‪setSingletonInstanceMakesMakeInstanceReturnThatInstance()
Definition: GeneralUtilityTest.php:3730
‪TYPO3
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\sanitizeLocalUrlValidUrlsDataProvider
‪array sanitizeLocalUrlValidUrlsDataProvider()
Definition: GeneralUtilityTest.php:1994
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\rmdirRemovesFile
‪rmdirRemovesFile()
Definition: GeneralUtilityTest.php:3105
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\mkdirDeepThrowsExceptionIfDeepDirectoryIsNotOfTypeString
‪mkdirDeepThrowsExceptionIfDeepDirectoryIsNotOfTypeString()
Definition: GeneralUtilityTest.php:3090
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\mkdirDeepCreatesDirectoryWithAndWithoutDoubleSlashesDataProvider
‪array mkdirDeepCreatesDirectoryWithAndWithoutDoubleSlashesDataProvider()
Definition: GeneralUtilityTest.php:2922
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\validEmailInvalidDataProvider
‪array validEmailInvalidDataProvider()
Definition: GeneralUtilityTest.php:938
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\makeInstanceInjectsLogger
‪makeInstanceInjectsLogger()
Definition: GeneralUtilityTest.php:3694
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\callUserFunctionWillThrowExceptionForInvalidParameters
‪callUserFunctionWillThrowExceptionForInvalidParameters($functionName, $expectedException)
Definition: GeneralUtilityTest.php:4248
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\copyDirectoryCopiesFilesAndDirectoriesWithAbsolutePaths
‪copyDirectoryCopiesFilesAndDirectoriesWithAbsolutePaths()
Definition: GeneralUtilityTest.php:4213
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\callUserFunctionCanCallMethod
‪callUserFunctionCanCallMethod()
Definition: GeneralUtilityTest.php:4293
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\getDirsReturnsStringErrorOnPathFailure
‪getDirsReturnsStringErrorOnPathFailure()
Definition: GeneralUtilityTest.php:2335
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\unlink_tempfileRemovesValidFileInTypo3temp
‪unlink_tempfileRemovesValidFileInTypo3temp()
Definition: GeneralUtilityTest.php:2151
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\addInstanceMakesMakeInstanceReturnThatInstance
‪addInstanceMakesMakeInstanceReturnThatInstance()
Definition: GeneralUtilityTest.php:3848
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\compileSelectedGetVarsFromArrayUsesGetPostDataFallback
‪compileSelectedGetVarsFromArrayUsesGetPostDataFallback()
Definition: GeneralUtilityTest.php:1084
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\getFilesInDirByExtensionDoesNotFindFilesWithOtherExtensions
‪getFilesInDirByExtensionDoesNotFindFilesWithOtherExtensions()
Definition: GeneralUtilityTest.php:3331
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\getFilesInDirDoesSortAlphabeticallyByDefault
‪getFilesInDirDoesSortAlphabeticallyByDefault()
Definition: GeneralUtilityTest.php:3366
‪TYPO3\CMS\Core\Tests\Unit\Utility\Fixtures\GeneralUtilityFixture\$isAllowedHostHeaderValueCallCount
‪static int $isAllowedHostHeaderValueCallCount
Definition: GeneralUtilityFixture.php:26
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\trimExplodeReturnsCorrectResult
‪trimExplodeReturnsCorrectResult($delimiter, $testString, $removeEmpty, $limit, $expectedResult)
Definition: GeneralUtilityTest.php:1201
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\sanitizeLocalUrlDeniesPlainInvalidUrlsInBackendContext
‪sanitizeLocalUrlDeniesPlainInvalidUrlsInBackendContext(string $url)
Definition: GeneralUtilityTest.php:2094
‪TYPO3\CMS\Core\Tests\Unit\Utility\Fixtures\ExtendedSingletonClassFixture
Definition: ExtendedSingletonClassFixture.php:21
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\fixPermissionsSetsPermissionsToHiddenFile
‪fixPermissionsSetsPermissionsToHiddenFile()
Definition: GeneralUtilityTest.php:2500
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\getFileAbsFileNameReturnsCorrectValues
‪getFileAbsFileNameReturnsCorrectValues($path, $expected)
Definition: GeneralUtilityTest.php:3952
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\makeInstanceCalledTwoTimesForSingletonClassReturnsSameInstance
‪makeInstanceCalledTwoTimesForSingletonClassReturnsSameInstance()
Definition: GeneralUtilityTest.php:3674
‪TYPO3\CMS\Core\Core\Environment\isWindows
‪static bool isWindows()
Definition: Environment.php:266
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\isFirstPartOfStrReturnsTrueForMatchingFirstPartDataProvider
‪array isFirstPartOfStrReturnsTrueForMatchingFirstPartDataProvider()
Definition: GeneralUtilityTest.php:737
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\hostnamesNotMatchingTrustedHostsConfigurationDataProvider
‪static array hostnamesNotMatchingTrustedHostsConfigurationDataProvider()
Definition: GeneralUtilityTest.php:1556
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\getFileAbsFileNameDateprovider
‪array getFileAbsFileNameDateprovider()
Definition: GeneralUtilityTest.php:3896
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\sanitizeLocalUrlInvalidDataProvider
‪array sanitizeLocalUrlInvalidDataProvider()
Definition: GeneralUtilityTest.php:2075
‪TYPO3\CMS\Core\Tests\Unit\Utility
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\IPv6Hex2BinDataProviderCorrect
‪static array IPv6Hex2BinDataProviderCorrect()
Definition: GeneralUtilityTest.php:357
‪TYPO3\CMS\Core\Core\Environment\getCurrentScript
‪static string getCurrentScript()
Definition: Environment.php:193
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\callUserFunctionInvalidParameterDataprovider
‪array callUserFunctionInvalidParameterDataprovider()
Definition: GeneralUtilityTest.php:4263
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\mkdirDeepCreatesDirectoryInVfsStream
‪mkdirDeepCreatesDirectoryInVfsStream()
Definition: GeneralUtilityTest.php:3056
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\canRetrieveGlobalInputsThroughPost
‪canRetrieveGlobalInputsThroughPost($key, $post, $expected)
Definition: GeneralUtilityTest.php:224
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\isFirstPartOfStrReturnsFalseForNotMatchingFirstPartDataProvider
‪array isFirstPartOfStrReturnsFalseForNotMatchingFirstPartDataProvider()
Definition: GeneralUtilityTest.php:762
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\rmdirRemovesDirectoryWithTrailingSlash
‪rmdirRemovesDirectoryWithTrailingSlash()
Definition: GeneralUtilityTest.php:3146
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\splitFileRefReturnsFileTypeForFilesWithoutPathSite
‪splitFileRefReturnsFileTypeForFilesWithoutPathSite()
Definition: GeneralUtilityTest.php:3460
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\camelCaseToLowerCaseUnderscored
‪camelCaseToLowerCaseUnderscored($expected, $inputString)
Definition: GeneralUtilityTest.php:1815
‪TYPO3\CMS\Core\Tests\Unit\Utility\Fixtures\GeneralUtilityFilesystemFixture
Definition: GeneralUtilityFilesystemFixture.php:23
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\hostnamesMatchingTrustedHostsConfigurationDataProvider
‪static array hostnamesMatchingTrustedHostsConfigurationDataProvider()
Definition: GeneralUtilityTest.php:1540
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\makeInstanceWithEmptyClassNameThrowsException
‪makeInstanceWithEmptyClassNameThrowsException()
Definition: GeneralUtilityTest.php:3559
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\allGetIndpEnvCallsRelatedToHostNamesCallIsAllowedHostHeaderValue
‪allGetIndpEnvCallsRelatedToHostNamesCallIsAllowedHostHeaderValue()
Definition: GeneralUtilityTest.php:1693
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\expandListExpandsIntegerRanges
‪expandListExpandsIntegerRanges($list, $expectation)
Definition: GeneralUtilityTest.php:665
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\callUserFunctionTrimsSpaces
‪callUserFunctionTrimsSpaces()
Definition: GeneralUtilityTest.php:4324
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\fixPermissionsSetsDefaultPermissionsToFile
‪fixPermissionsSetsDefaultPermissionsToFile()
Definition: GeneralUtilityTest.php:2669
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\isConnected
‪bool isConnected()
Definition: GeneralUtilityTest.php:94
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\xml2ArrayHandlesBigXmlContentDataProvider
‪array[] xml2ArrayHandlesBigXmlContentDataProvider()
Definition: GeneralUtilityTest.php:4579
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\xml2ArrayFailsWithXmlContentBiggerThanTenMegabytes
‪xml2ArrayFailsWithXmlContentBiggerThanTenMegabytes()
Definition: GeneralUtilityTest.php:4640
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\cmpIPv4DataProviderMatching
‪static array cmpIPv4DataProviderMatching()
Definition: GeneralUtilityTest.php:238
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\callUserFunctionAcceptsClosures
‪callUserFunctionAcceptsClosures()
Definition: GeneralUtilityTest.php:4311
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\makeInstancePassesParametersToConstructor
‪makeInstancePassesParametersToConstructor()
Definition: GeneralUtilityTest.php:3634
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\xml2arrayHandlesTagNamespacesDataProvider
‪string[][] xml2arrayHandlesTagNamespacesDataProvider()
Definition: GeneralUtilityTest.php:4450
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\normalizeCompressIPv6DataProviderCorrect
‪static array normalizeCompressIPv6DataProviderCorrect()
Definition: GeneralUtilityTest.php:414
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\mkdirDeepDoesNotChangePermissionsOfExistingSubDirectories
‪mkdirDeepDoesNotChangePermissionsOfExistingSubDirectories()
Definition: GeneralUtilityTest.php:2985
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\idnaEncodeDataProvider
‪idnaEncodeDataProvider()
Definition: GeneralUtilityTest.php:4770
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\mkdirCreatesDirectory
‪mkdirCreatesDirectory()
Definition: GeneralUtilityTest.php:2708
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\rmFromListRemovesElementsFromCommaSeparatedList
‪rmFromListRemovesElementsFromCommaSeparatedList($initialList, $listWithElementRemoved)
Definition: GeneralUtilityTest.php:625
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\normalizeIPv6CorrectlyNormalizesAddresses
‪normalizeIPv6CorrectlyNormalizesAddresses($compressed, $normalized)
Definition: GeneralUtilityTest.php:430
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\intExplodeConvertsStringsToInteger
‪intExplodeConvertsStringsToInteger()
Definition: GeneralUtilityTest.php:987
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\uniqueListUnifiesCommaSeparatedList
‪uniqueListUnifiesCommaSeparatedList($initialList, $unifiedList)
Definition: GeneralUtilityTest.php:708
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\uniqueListUnifiesCommaSeparatedListDataProvider
‪array uniqueListUnifiesCommaSeparatedListDataProvider()
Definition: GeneralUtilityTest.php:718
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\mkdirDeepThrowsExceptionIfBaseDirectoryIsNotOfTypeString
‪mkdirDeepThrowsExceptionIfBaseDirectoryIsNotOfTypeString()
Definition: GeneralUtilityTest.php:3079
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\IPv6Hex2BinCorrectlyConvertsAddresses
‪IPv6Hex2BinCorrectlyConvertsAddresses($hex, $binary)
Definition: GeneralUtilityTest.php:372
‪TYPO3\CMS\Core\Tests\Unit\Utility\Fixtures\TwoParametersConstructorFixture
Definition: TwoParametersConstructorFixture.php:21
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\rmdirRemovesDirectory
‪rmdirRemovesDirectory()
Definition: GeneralUtilityTest.php:3135
‪TYPO3\CMS\Core\Tests\Unit\Utility\Fixtures\ReplacementClassFixture
Definition: ReplacementClassFixture.php:21
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\invalidFilePathForTypo3tempDirDataProvider
‪array invalidFilePathForTypo3tempDirDataProvider()
Definition: GeneralUtilityTest.php:2809
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\addInstanceForClassThatIsNoSubclassOfProvidedClassThrowsException
‪addInstanceForClassThatIsNoSubclassOfProvidedClassThrowsException()
Definition: GeneralUtilityTest.php:3821
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\fixPermissionsDoesNotSetPermissionsToNotAllowedPath
‪fixPermissionsDoesNotSetPermissionsToNotAllowedPath()
Definition: GeneralUtilityTest.php:2633
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\mkdirDeepFixesPermissionsOfCreatedDirectory
‪mkdirDeepFixesPermissionsOfCreatedDirectory()
Definition: GeneralUtilityTest.php:2948
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\validEmailReturnsTrueForValidMailAddress
‪validEmailReturnsTrueForValidMailAddress($address)
Definition: GeneralUtilityTest.php:928
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\isAllowedHostHeaderValueReturnsFalseIfTrusedHostsIsNotConfigured
‪isAllowedHostHeaderValueReturnsFalseIfTrusedHostsIsNotConfigured()
Definition: GeneralUtilityTest.php:1531
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\expandListExpandsIntegerRangesDataProvider
‪array expandListExpandsIntegerRangesDataProvider()
Definition: GeneralUtilityTest.php:675
‪TYPO3\CMS\Core\Core\Environment\getFrameworkBasePath
‪static string getFrameworkBasePath()
Definition: Environment.php:234
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\getIndpEnvTypo3SitePathReturnsStringStartingWithDrive
‪getIndpEnvTypo3SitePathReturnsStringStartingWithDrive()
Definition: GeneralUtilityTest.php:1486
‪TYPO3\CMS\Core\Core\Environment\getContext
‪static ApplicationContext getContext()
Definition: Environment.php:106
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\getFilesInDirCreateTestDirectory
‪string getFilesInDirCreateTestDirectory()
Definition: GeneralUtilityTest.php:3236
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\sanitizeLocalUrlDeniesPlainInvalidUrlsInFrontendContext
‪sanitizeLocalUrlDeniesPlainInvalidUrlsInFrontendContext(string $url)
Definition: GeneralUtilityTest.php:2117
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\unlink_tempfileRemovesHiddenFile
‪unlink_tempfileRemovesHiddenFile()
Definition: GeneralUtilityTest.php:2164
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\getFilesInDirDoesNotFindDirectories
‪getFilesInDirDoesNotFindDirectories()
Definition: GeneralUtilityTest.php:3410
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\makeInstanceCalledTwoTimesForSingletonClassWithPurgeInstancesInbetweenReturnsDifferentInstances
‪makeInstanceCalledTwoTimesForSingletonClassWithPurgeInstancesInbetweenReturnsDifferentInstances()
Definition: GeneralUtilityTest.php:3683
‪TYPO3\CMS\Core\Utility\ExtensionManagementUtility
Definition: ExtensionManagementUtility.php:36
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\fixPermissionsSetsPermissionsToHiddenDirectory
‪fixPermissionsSetsPermissionsToHiddenDirectory()
Definition: GeneralUtilityTest.php:2561
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\implodeArrayForUrlDataProvider
‪array implodeArrayForUrlDataProvider()
Definition: GeneralUtilityTest.php:1003
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\setUp
‪setUp()
Definition: GeneralUtilityTest.php:67
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\isFirstPartOfStrReturnsTrueForMatchingFirstPart
‪isFirstPartOfStrReturnsTrueForMatchingFirstPart($string, $part)
Definition: GeneralUtilityTest.php:752
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\makeInstanceWithNullClassNameThrowsException
‪makeInstanceWithNullClassNameThrowsException()
Definition: GeneralUtilityTest.php:3570
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\getFilesInDirDoesNotFindDotfiles
‪getFilesInDirDoesNotFindDotfiles()
Definition: GeneralUtilityTest.php:3425
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\deniedFilesWithDefaultDenyPatternDataProvider
‪array deniedFilesWithDefaultDenyPatternDataProvider()
Definition: GeneralUtilityTest.php:4080
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\setSingletonInstanceForClassThatIsNoSubclassOfProvidedClassThrowsException
‪setSingletonInstanceForClassThatIsNoSubclassOfProvidedClassThrowsException()
Definition: GeneralUtilityTest.php:3715
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\implodeArrayForUrlCanUrlEncodeKeyNames
‪implodeArrayForUrlCanUrlEncodeKeyNames()
Definition: GeneralUtilityTest.php:1036
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\mkdirDeepFixesPermissionsOnNewParentDirectory
‪mkdirDeepFixesPermissionsOnNewParentDirectory()
Definition: GeneralUtilityTest.php:2966
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\xml2arrayHandlesTagNamespaces
‪xml2arrayHandlesTagNamespaces(string $input)
Definition: GeneralUtilityTest.php:4491
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\inListForItemNotContainedReturnsFalse
‪inListForItemNotContainedReturnsFalse($haystack)
Definition: GeneralUtilityTest.php:597
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\$resetSingletonInstances
‪bool $resetSingletonInstances
Definition: GeneralUtilityTest.php:54
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\rmFromListRemovesElementsFromCommaSeparatedListDataProvider
‪array rmFromListRemovesElementsFromCommaSeparatedListDataProvider()
Definition: GeneralUtilityTest.php:635
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\fixPermissionsSetsDefaultPermissionsToDirectory
‪fixPermissionsSetsDefaultPermissionsToDirectory()
Definition: GeneralUtilityTest.php:2687
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\cmpFqdnValidDataProvider
‪static array cmpFqdnValidDataProvider()
Definition: GeneralUtilityTest.php:517
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\getFilesInDirCanOrderByMtime
‪getFilesInDirCanOrderByMtime()
Definition: GeneralUtilityTest.php:3378
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\hostnameAndPortDataProvider
‪static array hostnameAndPortDataProvider()
Definition: GeneralUtilityTest.php:1504
‪TYPO3\CMS\Core\Core\Environment\getProjectPath
‪static string getProjectPath()
Definition: Environment.php:142
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\dirnameDataProvider
‪array< array > dirnameDataProvider()
Definition: GeneralUtilityTest.php:3478
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest
Definition: GeneralUtilityTest.php:49
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\validURLReturnsTrueForValidResource
‪validURLReturnsTrueForValidResource($url)
Definition: GeneralUtilityTest.php:1857
‪TYPO3\CMS\Core\Utility\GeneralUtility\ENV_TRUSTED_HOSTS_PATTERN_ALLOW_ALL
‪const ENV_TRUSTED_HOSTS_PATTERN_ALLOW_ALL
Definition: GeneralUtility.php:54
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\tearDown
‪tearDown()
Definition: GeneralUtilityTest.php:79
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\fixPermissionsCorrectlySetsPermissionsRecursive
‪fixPermissionsCorrectlySetsPermissionsRecursive()
Definition: GeneralUtilityTest.php:2582
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\fixPermissionsSetsPermissionsWithRelativeFileReference
‪fixPermissionsSetsPermissionsWithRelativeFileReference()
Definition: GeneralUtilityTest.php:2649
‪TYPO3\CMS\Core\Utility\ExtensionManagementUtility\setPackageManager
‪static setPackageManager(PackageManager $packageManager)
Definition: ExtensionManagementUtility.php:63
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\inListForItemContainedReturnsTrue
‪inListForItemContainedReturnsTrue($haystack)
Definition: GeneralUtilityTest.php:572
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\validIpReturnsFalseForInvalidIp
‪validIpReturnsFalseForInvalidIp($ip)
Definition: GeneralUtilityTest.php:504
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\getBytesFromSizeMeasurementCalculatesCorrectByteValue
‪getBytesFromSizeMeasurementCalculatesCorrectByteValue($expected, $byteString)
Definition: GeneralUtilityTest.php:1446
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\sanitizeLocalUrlDeniesEncodedInvalidUrls
‪sanitizeLocalUrlDeniesEncodedInvalidUrls($url)
Definition: GeneralUtilityTest.php:2139
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\xml2ArrayHandlesAttributeTypesDataProvider
‪array[] xml2ArrayHandlesAttributeTypesDataProvider()
Definition: GeneralUtilityTest.php:4662
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\getIndpEnvForHostThrowsExceptionForNotAllowedHostnameValues
‪getIndpEnvForHostThrowsExceptionForNotAllowedHostnameValues($httpHost, $hostNamePattern)
Definition: GeneralUtilityTest.php:1711
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\trimExplodeReturnsCorrectResultDataProvider
‪array trimExplodeReturnsCorrectResultDataProvider()
Definition: GeneralUtilityTest.php:1209
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\tempnamReturnsPathStartingWithGivenPrefix
‪tempnamReturnsPathStartingWithGivenPrefix()
Definition: GeneralUtilityTest.php:2211
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\underscoredToUpperCamelCaseDataProvider
‪array underscoredToUpperCamelCaseDataProvider()
Definition: GeneralUtilityTest.php:1751
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\makeInstanceWithNonEmptyArrayThrowsException
‪makeInstanceWithNonEmptyArrayThrowsException()
Definition: GeneralUtilityTest.php:3603
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\rmdirRemovesDeadLinkToDirectory
‪rmdirRemovesDeadLinkToDirectory()
Definition: GeneralUtilityTest.php:3201
‪TYPO3\CMS\Core\Package\Package
Definition: Package.php:21
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\isAllowedHostHeaderValueWorksCorrectlyWithWithServerNamePattern
‪isAllowedHostHeaderValueWorksCorrectlyWithWithServerNamePattern($httpHost, $serverName, $isAllowed, $serverPort='80', $ssl='Off')
Definition: GeneralUtilityTest.php:1681
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\unlink_tempfileReturnsTrueIfFileWasRemoved
‪unlink_tempfileReturnsTrueIfFileWasRemoved()
Definition: GeneralUtilityTest.php:2177
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\checkGroups
‪mixed checkGroups($methodName)
Definition: GeneralUtilityTest.php:2787
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\removeDotsFromTypoScriptSucceedsWithDottedArray
‪removeDotsFromTypoScriptSucceedsWithDottedArray()
Definition: GeneralUtilityTest.php:2245
‪TYPO3\CMS\Core\Cache\CacheManager
Definition: CacheManager.php:34
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\sanitizeLocalUrlValidPathsDataProvider
‪array sanitizeLocalUrlValidPathsDataProvider()
Definition: GeneralUtilityTest.php:1934
‪TYPO3\CMS\Core\Core\Environment\initialize
‪static initialize(ApplicationContext $context, bool $cli, bool $composerMode, string $projectPath, string $publicPath, string $varPath, string $configPath, string $currentScript, string $os)
Definition: Environment.php:77
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\inListForItemContainedReturnsTrueDataProvider
‪array inListForItemContainedReturnsTrueDataProvider()
Definition: GeneralUtilityTest.php:582
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\IPv6Bin2HexCorrectlyConvertsAddresses
‪IPv6Bin2HexCorrectlyConvertsAddresses($binary, $hex)
Definition: GeneralUtilityTest.php:401
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\validIpDataProvider
‪static array validIpDataProvider()
Definition: GeneralUtilityTest.php:463
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\xml2ArrayHandlesAttributeTypes
‪xml2ArrayHandlesAttributeTypes(string $input, $expected)
Definition: GeneralUtilityTest.php:4740
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\mkdirCreatesDirectoryWithTrailingSlash
‪mkdirCreatesDirectoryWithTrailingSlash()
Definition: GeneralUtilityTest.php:2732
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\unlink_tempfileReturnsNullIfFileDoesNotExist
‪unlink_tempfileReturnsNullIfFileDoesNotExist()
Definition: GeneralUtilityTest.php:2189
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\quoteJsValueDataProvider
‪array quoteJsValueDataProvider()
Definition: GeneralUtilityTest.php:2384
‪TYPO3\CMS\Core\Core\Environment\getBackendPath
‪static string getBackendPath()
Definition: Environment.php:223
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\validEmailReturnsFalseForInvalidMailAddress
‪validEmailReturnsFalseForInvalidMailAddress($address)
Definition: GeneralUtilityTest.php:976
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\allowedFilesDataProvider
‪array allowedFilesDataProvider()
Definition: GeneralUtilityTest.php:4157
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\$backupPackageManager
‪TYPO3 CMS Core Package PackageManager $backupPackageManager
Definition: GeneralUtilityTest.php:62
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\getIndpEnvTypo3SitePathReturnsStringStartingWithSlash
‪getIndpEnvTypo3SitePathReturnsStringStartingWithSlash()
Definition: GeneralUtilityTest.php:1465
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\callUserFunctionCanCallFunction
‪callUserFunctionCanCallFunction()
Definition: GeneralUtilityTest.php:4281
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\makeInstanceInstanciatesConfiguredImplementation
‪makeInstanceInstanciatesConfiguredImplementation()
Definition: GeneralUtilityTest.php:3644
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\resolveBackPathWithDataProvider
‪resolveBackPathWithDataProvider($input, $expectedValue)
Definition: GeneralUtilityTest.php:3548
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\rmdirReturnTrueIfFileWasRemoved
‪rmdirReturnTrueIfFileWasRemoved()
Definition: GeneralUtilityTest.php:3116
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\canRetrieveValueWithGP
‪canRetrieveValueWithGP($key, $get, $post, $expected)
Definition: GeneralUtilityTest.php:127
‪TYPO3\CMS\Core\Http\RequestFactory
Definition: RequestFactory.php:27
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\explodeUrl2ArrayTransformsParameterStringToFlatArray
‪explodeUrl2ArrayTransformsParameterStringToFlatArray($input, $expected)
Definition: GeneralUtilityTest.php:1047
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\mkdirSetsPermissionsOfCreatedDirectory
‪mkdirSetsPermissionsOfCreatedDirectory()
Definition: GeneralUtilityTest.php:2744
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\setSingletonInstanceReturnsFinalClassNameWithOverriddenClass
‪setSingletonInstanceReturnsFinalClassNameWithOverriddenClass()
Definition: GeneralUtilityTest.php:3767
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\getVirtualTestDir
‪string getVirtualTestDir($prefix='root_')
Definition: GeneralUtilityTest.php:112
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\formatSizeDataProvider
‪array formatSizeDataProvider()
Definition: GeneralUtilityTest.php:810
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\mkdirDeepCreatesDirectory
‪mkdirDeepCreatesDirectory()
Definition: GeneralUtilityTest.php:2900
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\underscoredToUpperCamelCase
‪underscoredToUpperCamelCase($expected, $inputString)
Definition: GeneralUtilityTest.php:1763
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\getFilesInDirCanPrependPath
‪getFilesInDirCanPrependPath()
Definition: GeneralUtilityTest.php:3354
‪TYPO3\CMS\Core\Tests\Unit\Utility\AccessibleProxies\ExtensionManagementUtilityAccessibleProxy\getPackageManager
‪static getPackageManager()
Definition: ExtensionManagementUtilityAccessibleProxy.php:37
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\isOnCurrentHostReturnsTrueWithCurrentHost
‪isOnCurrentHostReturnsTrueWithCurrentHost()
Definition: GeneralUtilityTest.php:1903
‪TYPO3\CMS\Core\Utility\GeneralUtility\ENV_TRUSTED_HOSTS_PATTERN_SERVER_NAME
‪const ENV_TRUSTED_HOSTS_PATTERN_SERVER_NAME
Definition: GeneralUtility.php:55
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\cmpIPv6DataProviderMatching
‪static array cmpIPv6DataProviderMatching()
Definition: GeneralUtilityTest.php:296
‪TYPO3\CMS\Core\Tests\Unit\Utility\Fixtures\OriginalClassFixture
Definition: OriginalClassFixture.php:21
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\validPathStrDetectsInvalidCharacters
‪validPathStrDetectsInvalidCharacters($path)
Definition: GeneralUtilityTest.php:4022
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\mkdirDeepCreatesSubdirectoriesRecursive
‪mkdirDeepCreatesSubdirectoriesRecursive()
Definition: GeneralUtilityTest.php:2910
‪$output
‪$output
Definition: annotationChecker.php:113
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\minifyJavaScriptReturnsInputStringIfNoHookIsRegistered
‪minifyJavaScriptReturnsInputStringIfNoHookIsRegistered()
Definition: GeneralUtilityTest.php:2447
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\purgeInstancesDropsAddedInstance
‪purgeInstancesDropsAddedInstance()
Definition: GeneralUtilityTest.php:3884
‪TYPO3\CMS\Core\Cache\Frontend\FrontendInterface
Definition: FrontendInterface.php:21
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\getIndpEnvTypo3PortParsesHostnamesAndIpAdresses
‪getIndpEnvTypo3PortParsesHostnamesAndIpAdresses($httpHost, $dummy, $expectedPort)
Definition: GeneralUtilityTest.php:1737
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\mkdirDeepThrowsExceptionIfDirectoryCreationFails
‪mkdirDeepThrowsExceptionIfDirectoryCreationFails()
Definition: GeneralUtilityTest.php:3068
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\cmpIPv4DataProviderNotMatching
‪static array cmpIPv4DataProviderNotMatching()
Definition: GeneralUtilityTest.php:267
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\getIndpEnvForHostAllowsAllHostnameValuesIfHostPatternIsSetToAllowAll
‪getIndpEnvForHostAllowsAllHostnameValuesIfHostPatternIsSetToAllowAll($httpHost, $hostNamePattern)
Definition: GeneralUtilityTest.php:1726
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\getIndpEnvTypo3SitePathReturnNonEmptyString
‪getIndpEnvTypo3SitePathReturnNonEmptyString()
Definition: GeneralUtilityTest.php:1457
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\validPathStrWorksWithUnicodeFileNames
‪validPathStrWorksWithUnicodeFileNames($path)
Definition: GeneralUtilityTest.php:4046
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\cmpFqdnReturnsFalse
‪cmpFqdnReturnsFalse($baseHost, $list)
Definition: GeneralUtilityTest.php:559
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\cmpIPv4ReturnsTrueForMatchingAddress
‪cmpIPv4ReturnsTrueForMatchingAddress($ip, $list)
Definition: GeneralUtilityTest.php:257
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\deniedFilesWithoutDenyPatternDataProvider
‪array deniedFilesWithoutDenyPatternDataProvider()
Definition: GeneralUtilityTest.php:4054
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\hmacReturnsHashOfProperLength
‪hmacReturnsHashOfProperLength()
Definition: GeneralUtilityTest.php:2349
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\removeDotsFromTypoScriptOverridesWithScalar
‪removeDotsFromTypoScriptOverridesWithScalar()
Definition: GeneralUtilityTest.php:2298
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\sanitizeLocalUrlAcceptsNotEncodedValidUrls
‪sanitizeLocalUrlAcceptsNotEncodedValidUrls($url, $host, $subDirectory)
Definition: GeneralUtilityTest.php:2027
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\getDirsReturnsArrayOfDirectoriesFromGivenDirectory
‪getDirsReturnsArrayOfDirectoriesFromGivenDirectory()
Definition: GeneralUtilityTest.php:2326
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\getAndPostDataProvider
‪array getAndPostDataProvider()
Definition: GeneralUtilityTest.php:200
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\getIndpEnvTypo3HostOnlyParsesHostnamesAndIpAdresses
‪getIndpEnvTypo3HostOnlyParsesHostnamesAndIpAdresses($httpHost, $expectedIp)
Definition: GeneralUtilityTest.php:1522
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\xml2ArrayHandlesBigXmlContent
‪xml2ArrayHandlesBigXmlContent(string $input, string $testValue)
Definition: GeneralUtilityTest.php:4613
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\camelCaseToLowerCaseUnderscoredDataProvider
‪array camelCaseToLowerCaseUnderscoredDataProvider()
Definition: GeneralUtilityTest.php:1801
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\fixPermissionsSetsPermissionsToDirectory
‪fixPermissionsSetsPermissionsToDirectory()
Definition: GeneralUtilityTest.php:2520
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\getFilesInDirByExtensionFindsFiles
‪getFilesInDirByExtensionFindsFiles($fileExtensions)
Definition: GeneralUtilityTest.php:3318
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\revExplodeCorrectlyExplodesStringForGivenPartsCount
‪revExplodeCorrectlyExplodesStringForGivenPartsCount($delimiter, $testString, $count, $expectedArray)
Definition: GeneralUtilityTest.php:1171
‪TYPO3\CMS\Core\Core\Environment
Definition: Environment.php:39
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\cmpIPv6ReturnsFalseForNotMatchingAddress
‪cmpIPv6ReturnsFalseForNotMatchingAddress($ip, $list)
Definition: GeneralUtilityTest.php:344
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\validUrlValidResourceDataProvider
‪array validUrlValidResourceDataProvider()
Definition: GeneralUtilityTest.php:1828
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\splitCalcDataProvider
‪array splitCalcDataProvider()
Definition: GeneralUtilityTest.php:857
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\getFilesInDirExcludesFilesMatchingPattern
‪getFilesInDirExcludesFilesMatchingPattern()
Definition: GeneralUtilityTest.php:3343
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\checkisOnCurrentHostInvalidHosts
‪array checkisOnCurrentHostInvalidHosts()
Definition: GeneralUtilityTest.php:1914
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\setSingletonInstanceCalledTwoTimesMakesMakeInstanceReturnLastSetInstance
‪setSingletonInstanceCalledTwoTimesMakesMakeInstanceReturnLastSetInstance()
Definition: GeneralUtilityTest.php:3741
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\resetSingletonInstancesResetsPreviouslySetInstance
‪resetSingletonInstancesResetsPreviouslySetInstance()
Definition: GeneralUtilityTest.php:3781
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\resetSingletonInstancesSetsGivenInstance
‪resetSingletonInstancesSetsGivenInstance()
Definition: GeneralUtilityTest.php:3794
‪TYPO3\CMS\Core\Core\Environment\getConfigPath
‪static string getConfigPath()
Definition: Environment.php:183
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\xml2arrayHandlesDocumentTag
‪xml2arrayHandlesDocumentTag(string $input, string $docTag)
Definition: GeneralUtilityTest.php:4557
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\user_calledUserFunction
‪string user_calledUserFunction()
Definition: GeneralUtilityTest.php:4303
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\compressIPv6CorrectlyCompressesAdressWithSomeAddressOnRightSide
‪compressIPv6CorrectlyCompressesAdressWithSomeAddressOnRightSide()
Definition: GeneralUtilityTest.php:447
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\makeInstanceCalledTwoTimesAfterAddInstanceReturnTwoDifferentInstances
‪makeInstanceCalledTwoTimesAfterAddInstanceReturnTwoDifferentInstances()
Definition: GeneralUtilityTest.php:3859
‪TYPO3\CMS\Core\Tests\Unit\Utility\Fixtures\OtherReplacementClassFixture
Definition: OtherReplacementClassFixture.php:21
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\removeDotsFromTypoScriptOverridesSubArray
‪removeDotsFromTypoScriptOverridesSubArray()
Definition: GeneralUtilityTest.php:2271
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\$backupEnvironment
‪bool $backupEnvironment
Definition: GeneralUtilityTest.php:58
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\locationHeaderUrlDataProvider
‪locationHeaderUrlDataProvider()
Definition: GeneralUtilityTest.php:4850
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\tempnamReturnsPathWithoutBackslashes
‪tempnamReturnsPathWithoutBackslashes()
Definition: GeneralUtilityTest.php:2222
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\fixPermissionsSetsPermissionsToFile
‪fixPermissionsSetsPermissionsToFile()
Definition: GeneralUtilityTest.php:2480
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\verifyNulCharacterFilesAgainstPatternWithoutFileDenyPattern
‪verifyNulCharacterFilesAgainstPatternWithoutFileDenyPattern(string $deniedFile)
Definition: GeneralUtilityTest.php:4071
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\addInstanceCalledTwoTimesMakesMakeInstanceReturnBothInstancesInAddingOrder
‪addInstanceCalledTwoTimesMakesMakeInstanceReturnBothInstancesInAddingOrder()
Definition: GeneralUtilityTest.php:3870
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\canRetrieveGlobalInputsThroughGet
‪canRetrieveGlobalInputsThroughGet($key, $get, $expected)
Definition: GeneralUtilityTest.php:214
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\getFilesInDirFindsHiddenFile
‪getFilesInDirFindsHiddenFile()
Definition: GeneralUtilityTest.php:3284
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\compileSelectedGetVarsFromArrayFiltersIncomingData
‪compileSelectedGetVarsFromArrayFiltersIncomingData()
Definition: GeneralUtilityTest.php:1072
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\splitCalcCorrectlySplitsExpression
‪splitCalcCorrectlySplitsExpression(array $expected, string $expression)
Definition: GeneralUtilityTest.php:879
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\mkdirDeepSetsGroupOwnershipOfCreatedParentDirectory
‪mkdirDeepSetsGroupOwnershipOfCreatedParentDirectory()
Definition: GeneralUtilityTest.php:3020
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\cmpIPv4ReturnsFalseForNotMatchingAddress
‪cmpIPv4ReturnsFalseForNotMatchingAddress($ip, $list)
Definition: GeneralUtilityTest.php:283
‪TYPO3\CMS\Core\Tests\Unit\Utility\AccessibleProxies\ExtensionManagementUtilityAccessibleProxy
Definition: ExtensionManagementUtilityAccessibleProxy.php:26
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\fixPermissionsSetsPermissionsToDirectoryWithTrailingSlash
‪fixPermissionsSetsPermissionsToDirectoryWithTrailingSlash()
Definition: GeneralUtilityTest.php:2540
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\mkdirDeepSetsGroupOwnershipOnNewSubDirectory
‪mkdirDeepSetsGroupOwnershipOnNewSubDirectory()
Definition: GeneralUtilityTest.php:3038
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\isAllowedHostHeaderValueReturnsTrueIfHostValueMatches
‪isAllowedHostHeaderValueReturnsTrueIfHostValueMatches($httpHost, $hostNamePattern)
Definition: GeneralUtilityTest.php:1574
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\makeInstanceCalledTwoTimesForNonSingletonClassReturnsDifferentInstances
‪makeInstanceCalledTwoTimesForNonSingletonClassReturnsDifferentInstances()
Definition: GeneralUtilityTest.php:3665
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\sanitizeLocalUrlAcceptsNotEncodedValidPaths
‪sanitizeLocalUrlAcceptsNotEncodedValidPaths($path)
Definition: GeneralUtilityTest.php:1952
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:45
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\validFilePathForTypo3tempDirDataProvider
‪array validFilePathForTypo3tempDirDataProvider()
Definition: GeneralUtilityTest.php:2858
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\getIndpEnvTypo3SitePathReturnsStringEndingWithSlash
‪getIndpEnvTypo3SitePathReturnsStringEndingWithSlash()
Definition: GeneralUtilityTest.php:1495
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\fileExtensionDataProvider
‪array fileExtensionDataProvider()
Definition: GeneralUtilityTest.php:3296
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\idnaEncodeConvertsUnicodeCharsToASCIIString
‪idnaEncodeConvertsUnicodeCharsToASCIIString($actual, $expected)
Definition: GeneralUtilityTest.php:4758
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\formatSizeTranslatesBytesToHigherOrderRepresentation
‪formatSizeTranslatesBytesToHigherOrderRepresentation($size, $labels, $base, $expected)
Definition: GeneralUtilityTest.php:800
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\xml2arrayHandlesDocumentTagDataProvider
‪array[] xml2arrayHandlesDocumentTagDataProvider()
Definition: GeneralUtilityTest.php:4512
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\getBytesFromSizeMeasurementDataProvider
‪array getBytesFromSizeMeasurementDataProvider()
Definition: GeneralUtilityTest.php:1433
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\getFilesInDirFindsRegularFile
‪getFilesInDirFindsRegularFile()
Definition: GeneralUtilityTest.php:3274
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\locationHeaderUrl
‪locationHeaderUrl($path, $host, $expected)
Definition: GeneralUtilityTest.php:4889
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\gpMergedDataProvider
‪array gpMergedDataProvider()
Definition: GeneralUtilityTest.php:176
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\isValidUrlInvalidRessourceDataProvider
‪array isValidUrlInvalidRessourceDataProvider()
Definition: GeneralUtilityTest.php:1867
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\rmdirRemovesLinkToDirectory
‪rmdirRemovesLinkToDirectory()
Definition: GeneralUtilityTest.php:3187
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\addInstanceWithSingletonInstanceThrowsException
‪addInstanceWithSingletonInstanceThrowsException()
Definition: GeneralUtilityTest.php:3836
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\makeInstanceReturnsClassInstance
‪makeInstanceReturnsClassInstance()
Definition: GeneralUtilityTest.php:3625
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\setSingletonInstanceForEmptyClassNameThrowsException
‪setSingletonInstanceForEmptyClassNameThrowsException()
Definition: GeneralUtilityTest.php:3703
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\cmpIPv6ReturnsTrueForMatchingAddress
‪cmpIPv6ReturnsTrueForMatchingAddress($ip, $list)
Definition: GeneralUtilityTest.php:316
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\serverNamePatternDataProvider
‪serverNamePatternDataProvider()
Definition: GeneralUtilityTest.php:1592
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\rmdirRemovesDeadLinkToFile
‪rmdirRemovesDeadLinkToFile()
Definition: GeneralUtilityTest.php:3216
‪TYPO3\CMS\Core\Core\Environment\getLegacyConfigPath
‪static string getLegacyConfigPath()
Definition: Environment.php:256
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\unlink_tempfileReturnsNullIfFileIsNowWithinTypo3temp
‪unlink_tempfileReturnsNullIfFileIsNowWithinTypo3temp()
Definition: GeneralUtilityTest.php:2198
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\verifyFilenameAgainstDenyPatternAcceptAllowedFiles
‪verifyFilenameAgainstDenyPatternAcceptAllowedFiles(string $allowedFile)
Definition: GeneralUtilityTest.php:4177
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\splitFileRefReturnsFileTypeNotForFolders
‪splitFileRefReturnsFileTypeNotForFolders()
Definition: GeneralUtilityTest.php:3439
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\revExplodeRespectsLimitThreeWhenExploding
‪revExplodeRespectsLimitThreeWhenExploding()
Definition: GeneralUtilityTest.php:1180
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\writeFileToTypo3tempDirFailsWithInvalidPath
‪writeFileToTypo3tempDirFailsWithInvalidPath($invalidFilePath, string $expectedResult)
Definition: GeneralUtilityTest.php:2849
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\isAllowedHostHeaderValueReturnsFalseIfHostValueMatches
‪isAllowedHostHeaderValueReturnsFalseIfHostValueMatches($httpHost, $hostNamePattern)
Definition: GeneralUtilityTest.php:1586
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\verifyFilenameAgainstDenyPatternDetectsNotAllowedFiles
‪verifyFilenameAgainstDenyPatternDetectsNotAllowedFiles($deniedFile)
Definition: GeneralUtilityTest.php:4149
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\mkdirDeepSetsGroupOwnershipOfCreatedDirectory
‪mkdirDeepSetsGroupOwnershipOfCreatedDirectory()
Definition: GeneralUtilityTest.php:3003
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\expandListExpandsForTwoThousandElementsExpandsOnlyToThousandElementsMaximum
‪expandListExpandsForTwoThousandElementsExpandsOnlyToThousandElementsMaximum()
Definition: GeneralUtilityTest.php:693
‪TYPO3\CMS\Core\Core\Environment\getVarPath
‪static string getVarPath()
Definition: Environment.php:165
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\rmdirReturnFalseIfNoFileWasRemoved
‪rmdirReturnFalseIfNoFileWasRemoved()
Definition: GeneralUtilityTest.php:3126
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\compressIPv6CorrectlyCompressesAdresses
‪compressIPv6CorrectlyCompressesAdresses($compressed, $normalized)
Definition: GeneralUtilityTest.php:439
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\revExplodeDataProvider
‪array revExplodeDataProvider()
Definition: GeneralUtilityTest.php:1101
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\addInstanceForEmptyClassNameThrowsException
‪addInstanceForEmptyClassNameThrowsException()
Definition: GeneralUtilityTest.php:3809
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\gpMergedWillMergeArraysFromGetAndPost
‪gpMergedWillMergeArraysFromGetAndPost($get, $post, $expected)
Definition: GeneralUtilityTest.php:164