‪TYPO3CMS  ‪main
GeneralUtilityTest.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
20 use Psr\Log\LoggerInterface;
27 use TYPO3\CMS\Core\Package\PackageManager;
43 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
44 
45 class ‪GeneralUtilityTest extends UnitTestCase
46 {
47  public const ‪NO_FIX_PERMISSIONS_ON_WINDOWS = 'fixPermissions() not available on Windows (method does nothing)';
48 
49  protected bool ‪$resetSingletonInstances = true;
50 
51  protected bool ‪$backupEnvironment = true;
52 
53  protected ?PackageManager ‪$backupPackageManager;
54 
55  protected function ‪setUp(): void
56  {
57  parent::setUp();
59  }
60 
61  protected function ‪tearDown(): void
62  {
63  GeneralUtility::flushInternalRuntimeCaches();
64  if ($this->backupPackageManager) {
66  }
67  parent::tearDown();
68  }
69 
76  public function ‪isConnected(): bool
77  {
78  $isConnected = false;
79  $connected = @fsockopen('typo3.org', 80);
80  if ($connected) {
81  $isConnected = true;
82  fclose($connected);
83  }
84  return $isConnected;
85  }
86 
91  protected function ‪getTestDirectory(string $prefix = 'root_'): string
92  {
93  $path = ‪Environment::getVarPath() . '/tests/' . ‪StringUtility::getUniqueId($prefix);
95  $this->testFilesToDelete[] = $path;
96  return $path;
97  }
98 
100  // Tests concerning _GP
102 
106  public function ‪canRetrieveValueWithGP($key, $get, $post, $expected): void
107  {
108  $_GET = $get;
109  $_POST = $post;
110  self::assertSame($expected, ‪GeneralUtility::_GP($key));
111  }
112 
117  public function ‪gpDataProvider(): array
118  {
119  return [
120  'No key parameter' => [null, [], [], null],
121  'Key not found' => ['cake', [], [], null],
122  'Value only in GET' => ['cake', ['cake' => 'li\\e'], [], 'li\\e'],
123  'Value only in POST' => ['cake', [], ['cake' => 'l\\ie'], 'l\\ie'],
124  'Value from POST preferred over GET' => ['cake', ['cake' => 'is a'], ['cake' => '\\lie'], '\\lie'],
125  'Value can be an array' => [
126  'cake',
127  ['cake' => ['is a' => 'l\\ie']],
128  [],
129  ['is a' => 'l\\ie'],
130  ],
131  'Empty-ish key' => ['0', ['0' => 'zero'], ['0' => 'zero'], null],
132  ];
133  }
134 
136  // Tests concerning _GPmerged
138 
142  public function ‪gpMergedWillMergeArraysFromGetAndPost($get, $post, $expected): void
143  {
144  $_POST = $post;
145  $_GET = $get;
146  self::assertEquals($expected, ‪GeneralUtility::_GPmerged('cake'));
147  }
148 
152  public function ‪gpMergedDataProvider(): array
153  {
154  $fullDataArray = ['cake' => ['a' => 'is a', 'b' => 'lie']];
155  $postPartData = ['cake' => ['b' => 'lie']];
156  $getPartData = ['cake' => ['a' => 'is a']];
157  $getPartDataModified = ['cake' => ['a' => 'is not a']];
158  return [
159  'Key doesn\' exist' => [['foo'], ['bar'], []],
160  'No POST data' => [$fullDataArray, [], $fullDataArray['cake']],
161  'No GET data' => [[], $fullDataArray, $fullDataArray['cake']],
162  'POST and GET are merged' => [$getPartData, $postPartData, $fullDataArray['cake']],
163  'POST is preferred over GET' => [$getPartDataModified, $fullDataArray, $fullDataArray['cake']],
164  ];
165  }
166 
168  // Tests concerning _GET / _POST
170 
174  public function ‪getAndPostDataProvider(): array
175  {
176  return [
177  'Requested input data doesn\'t exist' => ['cake', [], null],
178  'No key will return entire input data' => [null, ['cake' => 'l\\ie'], ['cake' => 'l\\ie']],
179  'Can retrieve specific input' => ['cake', ['cake' => 'l\\ie', 'foo'], 'l\\ie'],
180  'Can retrieve nested input data' => ['cake', ['cake' => ['is a' => 'l\\ie']], ['is a' => 'l\\ie']],
181  ];
182  }
183 
188  public function ‪canRetrieveGlobalInputsThroughGet($key, $get, $expected): void
189  {
190  $_GET = $get;
191  self::assertSame($expected, ‪GeneralUtility::_GET($key));
192  }
193 
198  public function ‪canRetrieveGlobalInputsThroughPost($key, $post, $expected): void
199  {
200  $_POST = $post;
201  self::assertSame($expected, ‪GeneralUtility::_POST($key));
202  }
203 
205  // Tests concerning cmpIPv4
207 
212  public static function ‪cmpIPv4DataProviderMatching(): array
213  {
214  return [
215  'host with full IP address' => ['127.0.0.1', '127.0.0.1'],
216  'host with two wildcards at the end' => ['127.0.0.1', '127.0.*.*'],
217  'host with wildcard at third octet' => ['127.0.0.1', '127.0.*.1'],
218  'host with wildcard at second octet' => ['127.0.0.1', '127.*.0.1'],
219  '/8 subnet' => ['127.0.0.1', '127.1.1.1/8'],
220  '/32 subnet (match only name)' => ['127.0.0.1', '127.0.0.1/32'],
221  '/30 subnet' => ['10.10.3.1', '10.10.3.3/30'],
222  'host with wildcard in list with IPv4/IPv6 addresses' => ['192.168.1.1', '127.0.0.1, 1234:5678::/126, 192.168.*'],
223  'host in list with IPv4/IPv6 addresses' => ['192.168.1.1', '::1, 1234:5678::/126, 192.168.1.1'],
224  ];
225  }
226 
231  public function ‪cmpIPv4ReturnsTrueForMatchingAddress($ip, $list): void
232  {
233  self::assertTrue(‪GeneralUtility::cmpIPv4($ip, $list));
234  }
235 
241  public static function ‪cmpIPv4DataProviderNotMatching(): array
242  {
243  return [
244  'single host' => ['127.0.0.1', '127.0.0.2'],
245  'single host with wildcard' => ['127.0.0.1', '127.*.1.1'],
246  'single host with /32 subnet mask' => ['127.0.0.1', '127.0.0.2/32'],
247  '/31 subnet' => ['127.0.0.1', '127.0.0.2/31'],
248  'list with IPv4/IPv6 addresses' => ['127.0.0.1', '10.0.2.3, 192.168.1.1, ::1'],
249  'list with only IPv6 addresses' => ['10.20.30.40', '::1, 1234:5678::/127'],
250  ];
251  }
252 
257  public function ‪cmpIPv4ReturnsFalseForNotMatchingAddress($ip, $list): void
258  {
259  self::assertFalse(‪GeneralUtility::cmpIPv4($ip, $list));
260  }
261 
263  // Tests concerning cmpIPv6
265 
270  public static function ‪cmpIPv6DataProviderMatching(): array
271  {
272  return [
273  'empty address' => ['::', '::'],
274  'empty with netmask in list' => ['::', '::/0'],
275  'empty with netmask 0 and host-bits set in list' => ['::', '::123/0'],
276  'localhost' => ['::1', '::1'],
277  'localhost with leading zero blocks' => ['::1', '0:0::1'],
278  'host with submask /128' => ['::1', '0:0::1/128'],
279  '/16 subnet' => ['1234::1', '1234:5678::/16'],
280  '/126 subnet' => ['1234:5678::3', '1234:5678::/126'],
281  '/126 subnet with host-bits in list set' => ['1234:5678::3', '1234:5678::2/126'],
282  'list with IPv4/IPv6 addresses' => ['1234:5678::3', '::1, 127.0.0.1, 1234:5678::/126, 192.168.1.1'],
283  ];
284  }
285 
290  public function ‪cmpIPv6ReturnsTrueForMatchingAddress($ip, $list): void
291  {
292  self::assertTrue(‪GeneralUtility::cmpIPv6($ip, $list));
293  }
294 
300  public static function ‪cmpIPv6DataProviderNotMatching(): array
301  {
302  return [
303  'empty against localhost' => ['::', '::1'],
304  'empty against localhost with /128 netmask' => ['::', '::1/128'],
305  'localhost against different host' => ['::1', '::2'],
306  'localhost against host with prior bits set' => ['::1', '::1:1'],
307  'host against different /17 subnet' => ['1234::1', '1234:f678::/17'],
308  'host against different /127 subnet' => ['1234:5678::3', '1234:5678::/127'],
309  'host against IPv4 address list' => ['1234:5678::3', '127.0.0.1, 192.168.1.1'],
310  'host against mixed list with IPv6 host in different subnet' => ['1234:5678::3', '::1, 1234:5678::/127'],
311  ];
312  }
313 
318  public function ‪cmpIPv6ReturnsFalseForNotMatchingAddress($ip, $list): void
319  {
320  self::assertFalse(‪GeneralUtility::cmpIPv6($ip, $list));
321  }
322 
324  // Tests concerning normalizeIPv6
326 
331  public static function ‪normalizeCompressIPv6DataProviderCorrect(): array
332  {
333  return [
334  'empty' => ['::', '0000:0000:0000:0000:0000:0000:0000:0000'],
335  'localhost' => ['::1', '0000:0000:0000:0000:0000:0000:0000:0001'],
336  'expansion in middle 1' => ['1::2', '0001:0000:0000:0000:0000:0000:0000:0002'],
337  'expansion in middle 2' => ['1:2::3', '0001:0002:0000:0000:0000:0000:0000:0003'],
338  'expansion in middle 3' => ['1::2:3', '0001:0000:0000:0000:0000:0000:0002:0003'],
339  'expansion in middle 4' => ['1:2::3:4:5', '0001:0002:0000:0000:0000:0003:0004:0005'],
340  ];
341  }
342 
347  public function ‪normalizeIPv6CorrectlyNormalizesAddresses($compressed, $normalized): void
348  {
349  self::assertEquals($normalized, ‪GeneralUtility::normalizeIPv6($compressed));
350  }
351 
353  // Tests concerning validIP
355 
360  public static function ‪validIpDataProvider(): array
361  {
362  return [
363  '0.0.0.0' => ['0.0.0.0'],
364  'private IPv4 class C' => ['192.168.0.1'],
365  'private IPv4 class A' => ['10.0.13.1'],
366  'private IPv6' => ['fe80::daa2:5eff:fe8b:7dfb'],
367  ];
368  }
369 
374  public function ‪validIpReturnsTrueForValidIp($ip): void
375  {
376  self::assertTrue(‪GeneralUtility::validIP($ip));
377  }
378 
384  public static function ‪invalidIpDataProvider(): array
385  {
386  return [
387  'null' => [null],
388  'zero' => [0],
389  'string' => ['test'],
390  'string empty' => [''],
391  'string NULL' => ['NULL'],
392  'out of bounds IPv4' => ['300.300.300.300'],
393  'dotted decimal notation with only two dots' => ['127.0.1'],
394  ];
395  }
396 
401  public function ‪validIpReturnsFalseForInvalidIp($ip): void
402  {
403  self::assertFalse(‪GeneralUtility::validIP($ip));
404  }
405 
407  // Tests concerning cmpFQDN
409 
414  public static function ‪cmpFqdnValidDataProvider(): array
415  {
416  return [
417  'localhost should usually resolve, IPv4' => ['127.0.0.1', '*'],
418  'localhost should usually resolve, IPv6' => ['::1', '*'],
419  // other testcases with resolving not possible since it would
420  // require a working IPv4/IPv6-connectivity
421  'aaa.bbb.ccc.ddd.eee, full' => ['aaa.bbb.ccc.ddd.eee', 'aaa.bbb.ccc.ddd.eee'],
422  'aaa.bbb.ccc.ddd.eee, wildcard first' => ['aaa.bbb.ccc.ddd.eee', '*.ccc.ddd.eee'],
423  'aaa.bbb.ccc.ddd.eee, wildcard last' => ['aaa.bbb.ccc.ddd.eee', 'aaa.bbb.ccc.*'],
424  'aaa.bbb.ccc.ddd.eee, wildcard middle' => ['aaa.bbb.ccc.ddd.eee', 'aaa.*.eee'],
425  'list-matches, 1' => ['aaa.bbb.ccc.ddd.eee', 'xxx, yyy, zzz, aaa.*.eee'],
426  'list-matches, 2' => ['aaa.bbb.ccc.ddd.eee', '127:0:0:1,,aaa.*.eee,::1'],
427  ];
428  }
429 
434  public function ‪cmpFqdnReturnsTrue($baseHost, $list): void
435  {
436  self::assertTrue(‪GeneralUtility::cmpFQDN($baseHost, $list));
437  }
438 
444  public static function ‪cmpFqdnInvalidDataProvider(): array
445  {
446  return [
447  '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'],
448  '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'],
449  ];
450  }
451 
456  public function ‪cmpFqdnReturnsFalse($baseHost, $list): void
457  {
458  self::assertFalse(‪GeneralUtility::cmpFQDN($baseHost, $list));
459  }
460 
462  // Tests concerning inList
464 
468  public function ‪inListForItemContainedReturnsTrue(string $haystack): void
469  {
470  self::assertTrue(‪GeneralUtility::inList($haystack, 'findme'));
471  }
472 
477  {
478  return [
479  'Element as second element of four items' => ['one,findme,three,four'],
480  'Element at beginning of list' => ['findme,one,two'],
481  'Element at end of list' => ['one,two,findme'],
482  'One item list' => ['findme'],
483  ];
484  }
485 
490  public function ‪inListForItemNotContainedReturnsFalse(string $haystack): void
491  {
492  self::assertFalse(‪GeneralUtility::inList($haystack, 'findme'));
493  }
494 
499  {
500  return [
501  'Four item list' => ['one,two,three,four'],
502  'One item list' => ['one'],
503  'Empty list' => [''],
504  ];
505  }
506 
508  // Tests concerning expandList
510 
514  public function ‪expandListExpandsIntegerRanges(string $list, string $expectation): void
515  {
516  self::assertSame($expectation, ‪GeneralUtility::expandList($list));
517  }
518 
523  {
524  return [
525  'Expand for the same number' => ['1,2-2,7', '1,2,7'],
526  'Small range expand with parameters reversed ignores reversed items' => ['1,5-3,7', '1,7'],
527  'Small range expand' => ['1,3-5,7', '1,3,4,5,7'],
528  'Expand at beginning' => ['3-5,1,7', '3,4,5,1,7'],
529  'Expand at end' => ['1,7,3-5', '1,7,3,4,5'],
530  'Multiple small range expands' => ['1,3-5,7-10,12', '1,3,4,5,7,8,9,10,12'],
531  'One item list' => ['1-5', '1,2,3,4,5'],
532  'Nothing to expand' => ['1,2,3,4', '1,2,3,4'],
533  'Empty list' => ['', ''],
534  ];
535  }
536 
541  {
542  $list = ‪GeneralUtility::expandList('1-2000');
543  self::assertCount(1000, explode(',', $list));
544  }
545 
547  // Tests concerning formatSize
549 
553  public function ‪formatSizeTranslatesBytesToHigherOrderRepresentation($size, $labels, $base, $expected): void
554  {
555  self::assertEquals($expected, GeneralUtility::formatSize($size, $labels, $base));
556  }
557 
561  public function ‪formatSizeDataProvider(): array
562  {
563  return [
564  'IEC Bytes stay bytes (min)' => [1, '', 0, '1 '],
565  'IEC Bytes stay bytes (max)' => [921, '', 0, '921 '],
566  'IEC Kilobytes are used (min)' => [922, '', 0, '0.90 Ki'],
567  'IEC Kilobytes are used (max)' => [943718, '', 0, '922 Ki'],
568  'IEC Megabytes are used (min)' => [943719, '', 0, '0.90 Mi'],
569  'IEC Megabytes are used (max)' => [966367641, '', 0, '922 Mi'],
570  'IEC Gigabytes are used (min)' => [966367642, '', 0, '0.90 Gi'],
571  'IEC Gigabytes are used (max)' => [989560464998, '', 0, '922 Gi'],
572  'IEC Decimal is omitted for large kilobytes' => [31080, '', 0, '30 Ki'],
573  'IEC Decimal is omitted for large megabytes' => [31458000, '', 0, '30 Mi'],
574  'IEC Decimal is omitted for large gigabytes' => [32212254720, '', 0, '30 Gi'],
575  'SI Bytes stay bytes (min)' => [1, 'si', 0, '1 '],
576  'SI Bytes stay bytes (max)' => [899, 'si', 0, '899 '],
577  'SI Kilobytes are used (min)' => [901, 'si', 0, '0.90 k'],
578  'SI Kilobytes are used (max)' => [900000, 'si', 0, '900 k'],
579  'SI Megabytes are used (min)' => [900001, 'si', 0, '0.90 M'],
580  'SI Megabytes are used (max)' => [900000000, 'si', 0, '900 M'],
581  'SI Gigabytes are used (min)' => [900000001, 'si', 0, '0.90 G'],
582  'SI Gigabytes are used (max)' => [900000000000, 'si', 0, '900 G'],
583  'SI Decimal is omitted for large kilobytes' => [30000, 'si', 0, '30 k'],
584  'SI Decimal is omitted for large megabytes' => [30000000, 'si', 0, '30 M'],
585  'SI Decimal is omitted for large gigabytes' => [30000000000, 'si', 0, '30 G'],
586  'Label for bytes can be exchanged (binary unit)' => [1, ' Foo|||', 0, '1 Foo'],
587  'Label for kilobytes can be exchanged (binary unit)' => [1024, '| Foo||', 0, '1.00 Foo'],
588  'Label for megabytes can be exchanged (binary unit)' => [1048576, '|| Foo|', 0, '1.00 Foo'],
589  'Label for gigabytes can be exchanged (binary unit)' => [1073741824, '||| Foo', 0, '1.00 Foo'],
590  'Label for bytes can be exchanged (decimal unit)' => [1, ' Foo|||', 1000, '1 Foo'],
591  'Label for kilobytes can be exchanged (decimal unit)' => [1000, '| Foo||', 1000, '1.00 Foo'],
592  'Label for megabytes can be exchanged (decimal unit)' => [1000000, '|| Foo|', 1000, '1.00 Foo'],
593  'Label for gigabytes can be exchanged (decimal unit)' => [1000000000, '||| Foo', 1000, '1.00 Foo'],
594  'IEC Base is ignored' => [1024, 'iec', 1000, '1.00 Ki'],
595  'SI Base is ignored' => [1000, 'si', 1024, '1.00 k'],
596  'Use binary base for unexpected base' => [2048, '| Bar||', 512, '2.00 Bar'],
597  ];
598  }
599 
601  // Tests concerning splitCalc
603 
608  public function ‪splitCalcDataProvider(): array
609  {
610  return [
611  'empty string returns empty array' => [
612  [],
613  '',
614  ],
615  'number without operator returns array with plus and number' => [
616  [['+', '42']],
617  '42',
618  ],
619  'two numbers with asterisk return first number with plus and second number with asterisk' => [
620  [['+', '42'], ['*', '31']],
621  '42 * 31',
622  ],
623  ];
624  }
625 
630  public function ‪splitCalcCorrectlySplitsExpression(array $expected, string $expression): void
631  {
632  self::assertSame($expected, GeneralUtility::splitCalc($expression, '+-*/'));
633  }
634 
636  // Tests concerning htmlspecialchars_decode
638 
642  {
643  $string = '<typo3 version="6.0">&nbsp;</typo3>';
644  $encoded = htmlspecialchars($string);
645  $decoded = htmlspecialchars_decode($encoded);
646  self::assertEquals($string, $decoded);
647  }
648 
650  // Tests concerning validEmail
652 
657  public function ‪validEmailValidDataProvider(): array
658  {
659  return [
660  'short mail address' => ['a@b.c'],
661  'simple mail address' => ['test@example.com'],
662  'uppercase characters' => ['QWERTYUIOPASDFGHJKLZXCVBNM@QWERTYUIOPASDFGHJKLZXCVBNM.NET'],
663  'equal sign in local part' => ['test=mail@example.com'],
664  'dash in local part' => ['test-mail@example.com'],
665  'plus in local part' => ['test+mail@example.com'],
666  'question mark in local part' => ['test?mail@example.com'],
667  'slash in local part' => ['foo/bar@example.com'],
668  'hash in local part' => ['foo#bar@example.com'],
669  'dot in local part' => ['firstname.lastname@employee.2something.com'],
670  'dash as local part' => ['-@foo.com'],
671  'umlauts in domain part' => ['foo@äöüfoo.com'],
672  'number as top level domain' => ['foo@bar.123'],
673  'top level domain only' => ['test@localhost'],
674  'umlauts in local part' => ['äöüfoo@bar.com'],
675  'quoted @ char' => ['"Abc@def"@example.com'],
676  ];
677  }
678 
683  public function ‪validEmailReturnsTrueForValidMailAddress($address): void
684  {
685  self::assertTrue(GeneralUtility::validEmail($address));
686  }
687 
693  public function ‪validEmailInvalidDataProvider(): array
694  {
695  return [
696  'empty string' => [''],
697  'empty array' => [[]],
698  'integer' => [42],
699  'float' => [42.23],
700  'array' => [['foo']],
701  'object' => [new \stdClass()],
702  '@ sign only' => ['@'],
703  'string longer than 320 characters' => [str_repeat('0123456789', 33)],
704  'duplicate @' => ['test@@example.com'],
705  'duplicate @ combined with further special characters in local part' => ['test!.!@#$%^&*@example.com'],
706  'opening parenthesis in local part' => ['foo(bar@example.com'],
707  'closing parenthesis in local part' => ['foo)bar@example.com'],
708  'opening square bracket in local part' => ['foo[bar@example.com'],
709  'closing square bracket as local part' => [']@example.com'],
710  'dash as second level domain' => ['foo@-.com'],
711  'domain part starting with dash' => ['foo@-foo.com'],
712  'domain part ending with dash' => ['foo@foo-.com'],
713  'dot at beginning of domain part' => ['test@.com'],
714  'local part ends with dot' => ['e.x.a.m.p.l.e.@example.com'],
715  'trailing whitespace' => ['test@example.com '],
716  'trailing carriage return' => ['test@example.com' . CR],
717  'trailing linefeed' => ['test@example.com' . LF],
718  'trailing carriage return linefeed' => ['test@example.com' . CRLF],
719  'trailing tab' => ['test@example.com' . "\t"],
720  'prohibited input characters' => ['“mailto:test@example.com”'],
721  'escaped @ char' => ['abc\@def@example.com'], // known bug, see https://github.com/egulias/EmailValidator/issues/181
722  ];
723  }
724 
729  public function ‪validEmailReturnsFalseForInvalidMailAddress($address): void
730  {
731  self::assertFalse(GeneralUtility::validEmail($address));
732  }
733 
735  // Tests concerning intExplode
737 
738  public function ‪intExplodeDataProvider(): array
739  {
740  return [
741  'convertStringToInteger' => [
742  '1,foo,2',
743  false,
744  [1, 0, 2],
745  ],
746  'zerosAreKept' => [
747  '0,1, 0, 2,0',
748  false,
749  [0, 1, 0, 2, 0],
750  ],
751  'emptyValuesAreKept' => [
752  '0,1,, 0, 2,,0',
753  false,
754  [0, 1, 0, 0, 2, 0, 0],
755  ],
756  'emptyValuesAreRemoved' => [
757  '0,1,, 0, 2,,0',
758  true,
759  [0=>0, 1=>1, 3=>0, 4=>2, 6=>0], // note does not renumber keys!
760  ],
761  ];
762  }
763 
768  public function ‪intExplodeReturnsExplodedArray(string $input, bool $removeEmpty, array $expected): void
769  {
770  self::assertSame($expected, ‪GeneralUtility::intExplode(',', $input, $removeEmpty));
771  }
772 
774  // Tests concerning implodeArrayForUrl / explodeUrl2Array
776 
779  public function ‪implodeArrayForUrlDataProvider(): array
780  {
781  $valueArray = ['one' => '√', 'two' => 2];
782  return [
783  'Empty input' => ['foo', [], ''],
784  'String parameters' => ['foo', $valueArray, '&foo[one]=%E2%88%9A&foo[two]=2'],
785  'Nested array parameters' => ['foo', [$valueArray], '&foo[0][one]=%E2%88%9A&foo[0][two]=2'],
786  'Keep blank parameters' => ['foo', ['one' => '√', ''], '&foo[one]=%E2%88%9A&foo[0]='],
787  ];
788  }
789 
794  public function ‪implodeArrayForUrlBuildsValidParameterString($name, $input, $expected): void
795  {
796  self::assertSame($expected, ‪GeneralUtility::implodeArrayForUrl($name, $input));
797  }
798 
803  {
804  $input = ['one' => '√', ''];
805  $expected = '&foo[one]=%E2%88%9A';
806  self::assertSame($expected, ‪GeneralUtility::implodeArrayForUrl('foo', $input, '', true));
807  }
808 
813  {
814  $input = ['one' => '√', ''];
815  $expected = '&foo%5Bone%5D=%E2%88%9A&foo%5B0%5D=';
816  self::assertSame($expected, ‪GeneralUtility::implodeArrayForUrl('foo', $input, '', false, true));
817  }
818 
820  {
821  return [
822  'Empty string' => ['', []],
823  'Simple parameter string' => ['&one=%E2%88%9A&two=2', ['one' => '√', 'two' => 2]],
824  'Nested parameter string' => ['&foo[one]=%E2%88%9A&two=2', ['foo[one]' => '√', 'two' => 2]],
825  'Parameter without value' => ['&one=&two=2', ['one' => '', 'two' => 2]],
826  'Nested parameter without value' => ['&foo[one]=&two=2', ['foo[one]' => '', 'two' => 2]],
827  'Parameter without equals sign' => ['&one&two=2', ['one' => '', 'two' => 2]],
828  'Nested parameter without equals sign' => ['&foo[one]&two=2', ['foo[one]' => '', 'two' => 2]],
829  ];
830  }
831 
836  public function ‪explodeUrl2ArrayTransformsParameterStringToFlatArray(string $input, array $expected): void
837  {
838  self::assertEquals($expected, GeneralUtility::explodeUrl2Array($input));
839  }
840 
841  public function ‪revExplodeDataProvider(): array
842  {
843  return [
844  'limit 0 should return unexploded string' => [
845  ':',
846  'my:words:here',
847  0,
848  ['my:words:here'],
849  ],
850  'limit 1 should return unexploded string' => [
851  ':',
852  'my:words:here',
853  1,
854  ['my:words:here'],
855  ],
856  'limit 2 should return two pieces' => [
857  ':',
858  'my:words:here',
859  2,
860  ['my:words', 'here'],
861  ],
862  'limit 3 should return unexploded string' => [
863  ':',
864  'my:words:here',
865  3,
866  ['my', 'words', 'here'],
867  ],
868  'limit 0 should return unexploded string if no delimiter is contained' => [
869  ':',
870  'mywordshere',
871  0,
872  ['mywordshere'],
873  ],
874  'limit 1 should return unexploded string if no delimiter is contained' => [
875  ':',
876  'mywordshere',
877  1,
878  ['mywordshere'],
879  ],
880  'limit 2 should return unexploded string if no delimiter is contained' => [
881  ':',
882  'mywordshere',
883  2,
884  ['mywordshere'],
885  ],
886  'limit 3 should return unexploded string if no delimiter is contained' => [
887  ':',
888  'mywordshere',
889  3,
890  ['mywordshere'],
891  ],
892  'multi character delimiter is handled properly with limit 2' => [
893  '[]',
894  'a[b][c][d]',
895  2,
896  ['a[b][c', 'd]'],
897  ],
898  'multi character delimiter is handled properly with limit 3' => [
899  '[]',
900  'a[b][c][d]',
901  3,
902  ['a[b', 'c', 'd]'],
903  ],
904  ];
905  }
906 
911  public function ‪revExplodeCorrectlyExplodesStringForGivenPartsCount($delimiter, $testString, $count, $expectedArray): void
912  {
913  $actualArray = ‪GeneralUtility::revExplode($delimiter, $testString, $count);
914  self::assertEquals($expectedArray, $actualArray);
915  }
916 
921  {
922  $testString = 'even:more:of:my:words:here';
923  $expectedArray = ['even:more:of:my', 'words', 'here'];
924  $actualArray = ‪GeneralUtility::revExplode(':', $testString, 3);
925  self::assertEquals($expectedArray, $actualArray);
926  }
927 
929  // Tests concerning trimExplode
931 
935  public function ‪trimExplodeReturnsCorrectResult(string $delimiter, string $testString, bool $removeEmpty, int $limit, array $expectedResult): void
936  {
937  self::assertSame($expectedResult, ‪GeneralUtility::trimExplode($delimiter, $testString, $removeEmpty, $limit));
938  }
939 
941  {
942  return [
943  'spaces at element start and end' => [
944  ',',
945  ' a , b , c ,d ,, e,f,',
946  false,
947  0,
948  ['a', 'b', 'c', 'd', '', 'e', 'f', ''],
949  ],
950  'removes newline' => [
951  ',',
952  ' a , b , ' . LF . ' ,d ,, e,f,',
953  true,
954  0,
955  ['a', 'b', 'd', 'e', 'f'],
956  ],
957  'removes empty elements' => [
958  ',',
959  'a , b , c , ,d ,, ,e,f,',
960  true,
961  0,
962  ['a', 'b', 'c', 'd', 'e', 'f'],
963  ],
964  'keeps remaining results with empty items after reaching limit with positive parameter' => [
965  ',',
966  ' a , b , c , , d,, ,e ',
967  false,
968  3,
969  ['a', 'b', 'c , , d,, ,e'],
970  ],
971  'keeps remaining results without empty items after reaching limit with positive parameter' => [
972  ',',
973  ' a , b , c , , d,, ,e ',
974  true,
975  3,
976  ['a', 'b', 'c , d,e'],
977  ],
978  'keeps remaining results with empty items after reaching limit with negative parameter' => [
979  ',',
980  ' a , b , c , d, ,e, f , , ',
981  false,
982  -3,
983  ['a', 'b', 'c', 'd', '', 'e'],
984  ],
985  'keeps remaining results without empty items after reaching limit with negative parameter' => [
986  ',',
987  ' a , b , c , d, ,e, f , , ',
988  true,
989  -3,
990  ['a', 'b', 'c'],
991  ],
992  'returns exact results without reaching limit with positive parameter' => [
993  ',',
994  ' a , b , , c , , , ',
995  true,
996  4,
997  ['a', 'b', 'c'],
998  ],
999  'keeps zero as string' => [
1000  ',',
1001  'a , b , c , ,d ,, ,e,f, 0 ,',
1002  true,
1003  0,
1004  ['a', 'b', 'c', 'd', 'e', 'f', '0'],
1005  ],
1006  'keeps whitespace inside elements' => [
1007  ',',
1008  'a , b , c , ,d ,, ,e,f, g h ,',
1009  true,
1010  0,
1011  ['a', 'b', 'c', 'd', 'e', 'f', 'g h'],
1012  ],
1013  'can use internal regex delimiter as explode delimiter' => [
1014  '/',
1015  'a / b / c / /d // /e/f/ g h /',
1016  true,
1017  0,
1018  ['a', 'b', 'c', 'd', 'e', 'f', 'g h'],
1019  ],
1020  'can use whitespaces as delimiter' => [
1021  ' ',
1022  '* * * * *',
1023  true,
1024  0,
1025  ['*', '*', '*', '*', '*'],
1026  ],
1027  'can use words as delimiter' => [
1028  'All',
1029  'HelloAllTogether',
1030  true,
1031  0,
1032  ['Hello', 'Together'],
1033  ],
1034  'can use word with appended and prepended spaces as delimiter' => [
1035  ' all ',
1036  'Hello all together',
1037  true,
1038  0,
1039  ['Hello', 'together'],
1040  ],
1041  'can use word with appended and prepended spaces as delimiter and do not remove empty' => [
1042  ' all ',
1043  'Hello all together all there all all are all none',
1044  false,
1045  0,
1046  ['Hello', 'together', 'there', '', 'are', 'none'],
1047  ],
1048  'can use word with appended and prepended spaces as delimiter, do not remove empty and limit' => [
1049  ' all ',
1050  'Hello all together all there all all are all none',
1051  false,
1052  5,
1053  ['Hello', 'together', 'there', '', 'are all none'],
1054  ],
1055  'can use word with appended and prepended spaces as delimiter, do not remove empty, limit and multiple delimiter in last' => [
1056  ' all ',
1057  'Hello all together all there all all are all none',
1058  false,
1059  4,
1060  ['Hello', 'together', 'there', 'all are all none'],
1061  ],
1062  'can use word with appended and prepended spaces as delimiter, remove empty and limit' => [
1063  ' all ',
1064  'Hello all together all there all all are all none',
1065  true,
1066  4,
1067  ['Hello', 'together', 'there', 'are all none'],
1068  ],
1069  'can use word with appended and prepended spaces as delimiter, remove empty and limit and multiple delimiter in last' => [
1070  ' all ',
1071  'Hello all together all there all all are all none',
1072  true,
1073  5,
1074  ['Hello', 'together', 'there', 'are' , 'none'],
1075  ],
1076  'can use words as delimiter and do not remove empty' => [
1077  'all there',
1078  'Helloall theretogether all there all there are all there none',
1079  false,
1080  0,
1081  ['Hello', 'together', '', 'are', 'none'],
1082  ],
1083  'can use words as delimiter, do not remove empty and limit' => [
1084  'all there',
1085  'Helloall theretogether all there all there are all there none',
1086  false,
1087  4,
1088  ['Hello', 'together', '', 'are all there none'],
1089  ],
1090  'can use words as delimiter, do not remove empty, limit and multiple delimiter in last' => [
1091  'all there',
1092  'Helloall theretogether all there all there are all there none',
1093  false,
1094  3,
1095  ['Hello', 'together', 'all there are all there none'],
1096  ],
1097  'can use words as delimiter, remove empty' => [
1098  'all there',
1099  'Helloall theretogether all there all there are all there none',
1100  true,
1101  0,
1102  ['Hello', 'together', 'are', 'none'],
1103  ],
1104  'can use words as delimiter, remove empty and limit' => [
1105  'all there',
1106  'Helloall theretogether all there all there are all there none',
1107  true,
1108  3,
1109  ['Hello', 'together', 'are all there none'],
1110  ],
1111  'can use words as delimiter, remove empty and limit and multiple delimiter in last' => [
1112  'all there',
1113  'Helloall theretogether all there all there are all there none',
1114  true,
1115  4,
1116  ['Hello', 'together', 'are' , 'none'],
1117  ],
1118  'can use new line as delimiter' => [
1119  LF,
1120  "Hello\nall\ntogether",
1121  true,
1122  0,
1123  ['Hello', 'all', 'together'],
1124  ],
1125  'works with whitespace separator' => [
1126  "\t",
1127  " a b \t c \t \t d \t e \t u j \t s",
1128  false,
1129  0,
1130  ['a b', 'c', '', 'd', 'e', 'u j', 's'],
1131  ],
1132  'works with whitespace separator and limit' => [
1133  "\t",
1134  " a b \t c \t \t d \t e \t u j \t s",
1135  false,
1136  4,
1137  ['a b', 'c', '', "d \t e \t u j \t s"],
1138  ],
1139  'works with whitespace separator and remove empty' => [
1140  "\t",
1141  " a b \t c \t \t d \t e \t u j \t s",
1142  true,
1143  0,
1144  ['a b', 'c', 'd', 'e', 'u j', 's'],
1145  ],
1146  'works with whitespace separator remove empty and limit' => [
1147  "\t",
1148  " a b \t c \t \t d \t e \t u j \t s",
1149  true,
1150  3,
1151  ['a b', 'c', "d \t e \t u j \t s"],
1152  ],
1153  ];
1154  }
1155 
1157  // Tests concerning getBytesFromSizeMeasurement
1159 
1165  {
1166  return [
1167  '100 kilo Bytes' => ['102400', '100k'],
1168  '100 mega Bytes' => ['104857600', '100m'],
1169  '100 giga Bytes' => ['107374182400', '100g'],
1170  ];
1171  }
1172 
1177  public function ‪getBytesFromSizeMeasurementCalculatesCorrectByteValue($expected, $byteString): void
1178  {
1179  self::assertEquals($expected, GeneralUtility::getBytesFromSizeMeasurement($byteString));
1180  }
1181 
1183  // Tests concerning getIndpEnv
1185 
1189  {
1190  self::assertTrue(strlen(GeneralUtility::getIndpEnv('TYPO3_SITE_PATH')) >= 1);
1191  }
1192 
1197  {
1198  $result = GeneralUtility::getIndpEnv('TYPO3_SITE_PATH');
1199  self::assertEquals('/', $result[strlen($result) - 1]);
1200  }
1201 
1202  public static function ‪hostnameAndPortDataProvider(): array
1203  {
1204  return [
1205  'localhost ipv4 without port' => ['127.0.0.1', '127.0.0.1', ''],
1206  'localhost ipv4 with port' => ['127.0.0.1:81', '127.0.0.1', '81'],
1207  'localhost ipv6 without port' => ['[::1]', '[::1]', ''],
1208  'localhost ipv6 with port' => ['[::1]:81', '[::1]', '81'],
1209  'ipv6 without port' => ['[2001:DB8::1]', '[2001:DB8::1]', ''],
1210  'ipv6 with port' => ['[2001:DB8::1]:81', '[2001:DB8::1]', '81'],
1211  'hostname without port' => ['lolli.did.this', 'lolli.did.this', ''],
1212  'hostname with port' => ['lolli.did.this:42', 'lolli.did.this', '42'],
1213  ];
1214  }
1215 
1220  public function ‪getIndpEnvTypo3HostOnlyParsesHostnamesAndIpAddresses($httpHost, $expectedIp): void
1221  {
1222  $_SERVER['HTTP_HOST'] = $httpHost;
1223  self::assertEquals($expectedIp, GeneralUtility::getIndpEnv('TYPO3_HOST_ONLY'));
1224  }
1225 
1230  public function ‪getIndpEnvTypo3PortParsesHostnamesAndIpAddresses($httpHost, $dummy, $expectedPort): void
1231  {
1232  $_SERVER['HTTP_HOST'] = $httpHost;
1233  self::assertEquals($expectedPort, GeneralUtility::getIndpEnv('TYPO3_PORT'));
1234  }
1235 
1237  // Tests concerning underscoredToUpperCamelCase
1239 
1245  {
1246  return [
1247  'single word' => ['Blogexample', 'blogexample'],
1248  'multiple words' => ['BlogExample', 'blog_example'],
1249  ];
1250  }
1251 
1256  public function ‪underscoredToUpperCamelCase($expected, $inputString): void
1257  {
1258  self::assertEquals($expected, ‪GeneralUtility::underscoredToUpperCamelCase($inputString));
1259  }
1260 
1262  // Tests concerning underscoredToLowerCamelCase
1264 
1270  {
1271  return [
1272  'single word' => ['minimalvalue', 'minimalvalue'],
1273  'multiple words' => ['minimalValue', 'minimal_value'],
1274  ];
1275  }
1276 
1281  public function ‪underscoredToLowerCamelCase($expected, $inputString): void
1282  {
1283  self::assertEquals($expected, ‪GeneralUtility::underscoredToLowerCamelCase($inputString));
1284  }
1285 
1287  // Tests concerning camelCaseToLowerCaseUnderscored
1289 
1295  {
1296  return [
1297  'single word' => ['blogexample', 'blogexample'],
1298  'single word starting upper case' => ['blogexample', 'Blogexample'],
1299  'two words starting lower case' => ['minimal_value', 'minimalValue'],
1300  'two words starting upper case' => ['blog_example', 'BlogExample'],
1301  ];
1302  }
1303 
1308  public function ‪camelCaseToLowerCaseUnderscored($expected, $inputString): void
1309  {
1310  self::assertEquals($expected, ‪GeneralUtility::camelCaseToLowerCaseUnderscored($inputString));
1311  }
1312 
1314  // Tests concerning isValidUrl
1316 
1321  public function ‪validUrlValidResourceDataProvider(): array
1322  {
1323  return [
1324  'http' => ['http://www.example.org/'],
1325  'http without trailing slash' => ['http://qwe'],
1326  'http directory with trailing slash' => ['http://www.example/img/dir/'],
1327  'http directory without trailing slash' => ['http://www.example/img/dir'],
1328  'http index.html' => ['http://example.com/index.html'],
1329  'http index.php' => ['http://www.example.com/index.php'],
1330  'http test.png' => ['http://www.example/img/test.png'],
1331  'http username password querystring and anchor' => ['https://user:pw@www.example.org:80/path?arg=value#fragment'],
1332  'file' => ['file:///tmp/test.c'],
1333  'file directory' => ['file://foo/bar'],
1334  'ftp directory' => ['ftp://ftp.example.com/tmp/'],
1335  'mailto' => ['mailto:foo@bar.com'],
1336  'news' => ['news:news.php.net'],
1337  'telnet' => ['telnet://192.0.2.16:80/'],
1338  'ldap' => ['ldap://[2001:db8::7]/c=GB?objectClass?one'],
1339  'http punycode domain name' => ['http://www.xn--bb-eka.at'],
1340  'http punicode subdomain' => ['http://xn--h-zfa.oebb.at'],
1341  'http domain-name umlauts' => ['http://www.öbb.at'],
1342  'http subdomain umlauts' => ['http://äh.oebb.at'],
1343  ];
1344  }
1345 
1350  public function ‪validURLReturnsTrueForValidResource($url): void
1351  {
1352  self::assertTrue(‪GeneralUtility::isValidUrl($url));
1353  }
1354 
1361  {
1362  return [
1363  'http missing colon' => ['http//www.example/wrong/url/'],
1364  'http missing slash' => ['http:/www.example'],
1365  'hostname only' => ['www.example.org/'],
1366  'file missing protocol specification' => ['/tmp/test.c'],
1367  'slash only' => ['/'],
1368  'string http://' => ['http://'],
1369  'string http:/' => ['http:/'],
1370  'string http:' => ['http:'],
1371  'string http' => ['http'],
1372  'empty string' => [''],
1373  'string -1' => ['-1'],
1374  'string array()' => ['array()'],
1375  'random string' => ['qwe'],
1376  'http directory umlauts' => ['http://www.oebb.at/äöü/'],
1377  'prohibited input characters' => ['https://{$unresolved_constant}'],
1378  ];
1379  }
1380 
1385  public function ‪validURLReturnsFalseForInvalidResource($url): void
1386  {
1387  self::assertFalse(‪GeneralUtility::isValidUrl($url));
1388  }
1389 
1391  // Tests concerning isOnCurrentHost
1393 
1397  {
1398  $testUrl = GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL');
1399  self::assertTrue(‪GeneralUtility::isOnCurrentHost($testUrl));
1400  }
1401 
1407  public function ‪checkisOnCurrentHostInvalidHosts(): array
1408  {
1409  return [
1410  'empty string' => [''],
1411  'arbitrary string' => ['arbitrary string'],
1412  'localhost IP' => ['127.0.0.1'],
1413  'relative path' => ['./relpath/file.txt'],
1414  'absolute path' => ['/abspath/file.txt?arg=value'],
1415  'different host' => [GeneralUtility::getIndpEnv('TYPO3_REQUEST_HOST') . '.example.org'],
1416  ];
1417  }
1418 
1420  // Tests concerning sanitizeLocalUrl
1422 
1428  {
1429  return [
1430  'alt_intro.php' => ['alt_intro.php'],
1431  'alt_intro.php?foo=1&bar=2' => ['alt_intro.php?foo=1&bar=2'],
1432  '../index.php' => ['../index.php'],
1433  '../typo3/alt_intro.php' => ['../typo3/alt_intro.php'],
1434  '../~userDirectory/index.php' => ['../~userDirectory/index.php'],
1435  '../typo3/index.php?var1=test-case&var2=~user' => ['../typo3/index.php?var1=test-case&var2=~user'],
1436  ‪Environment::getPublicPath() . '/typo3/alt_intro.php' => [‪Environment::getPublicPath() . '/typo3/alt_intro.php'],
1437  ];
1438  }
1439 
1444  public function ‪sanitizeLocalUrlAcceptsNotEncodedValidPaths(string $path): void
1445  {
1448  true,
1449  false,
1454  ‪Environment::getBackendPath() . '/index.php',
1455  ‪Environment::isWindows() ? 'WINDOWS' : 'UNIX'
1456  );
1457  self::assertEquals($path, GeneralUtility::sanitizeLocalUrl($path));
1458  }
1459 
1464  public function ‪sanitizeLocalUrlAcceptsEncodedValidPaths(string $path): void
1465  {
1468  true,
1469  false,
1474  ‪Environment::getBackendPath() . '/index.php',
1475  ‪Environment::isWindows() ? 'WINDOWS' : 'UNIX'
1476  );
1477  self::assertEquals(rawurlencode($path), GeneralUtility::sanitizeLocalUrl(rawurlencode($path)));
1478  }
1479 
1486  {
1487  return [
1488  '/cms/typo3/alt_intro.php' => [
1489  '/cms/typo3/alt_intro.php',
1490  'localhost',
1491  '/cms/',
1492  ],
1493  '/cms/index.php' => [
1494  '/cms/index.php',
1495  'localhost',
1496  '/cms/',
1497  ],
1498  'http://localhost/typo3/alt_intro.php' => [
1499  'http://localhost/typo3/alt_intro.php',
1500  'localhost',
1501  '',
1502  ],
1503  'http://localhost/cms/typo3/alt_intro.php' => [
1504  'http://localhost/cms/typo3/alt_intro.php',
1505  'localhost',
1506  '/cms/',
1507  ],
1508  ];
1509  }
1510 
1515  public function ‪sanitizeLocalUrlAcceptsNotEncodedValidUrls(string $url, string $host, string $subDirectory): void
1516  {
1519  true,
1520  false,
1525  ‪Environment::getBackendPath() . '/index.php',
1526  ‪Environment::isWindows() ? 'WINDOWS' : 'UNIX'
1527  );
1528  $_SERVER['HTTP_HOST'] = $host;
1529  $_SERVER['SCRIPT_NAME'] = $subDirectory . 'typo3/index.php';
1530  self::assertEquals($url, GeneralUtility::sanitizeLocalUrl($url));
1531  }
1532 
1537  public function ‪sanitizeLocalUrlAcceptsEncodedValidUrls(string $url, string $host, string $subDirectory): void
1538  {
1541  true,
1542  false,
1547  ‪Environment::getBackendPath() . '/index.php',
1548  ‪Environment::isWindows() ? 'WINDOWS' : 'UNIX'
1549  );
1550  $_SERVER['HTTP_HOST'] = $host;
1551  $_SERVER['SCRIPT_NAME'] = $subDirectory . 'typo3/index.php';
1552  self::assertEquals(rawurlencode($url), GeneralUtility::sanitizeLocalUrl(rawurlencode($url)));
1553  }
1554 
1561  {
1562  return [
1563  'empty string' => [''],
1564  'http domain' => ['http://www.google.de/'],
1565  'https domain' => ['https://www.google.de/'],
1566  'domain without schema' => ['//www.google.de/'],
1567  'XSS attempt' => ['" onmouseover="alert(123)"'],
1568  'invalid URL, UNC path' => ['\\\\foo\\bar\\'],
1569  'invalid URL, HTML break out attempt' => ['" >blabuubb'],
1570  'base64 encoded string' => ['data:%20text/html;base64,PHNjcmlwdD5hbGVydCgnWFNTJyk8L3NjcmlwdD4='],
1571  ];
1572  }
1573 
1579  {
1582  true,
1583  false,
1588  ‪Environment::getBackendPath() . '/index.php',
1589  ‪Environment::isWindows() ? 'WINDOWS' : 'UNIX'
1590  );
1591  $_SERVER['HTTP_HOST'] = 'localhost';
1592  $_SERVER['SCRIPT_NAME'] = 'typo3/index.php';
1593  self::assertEquals('', GeneralUtility::sanitizeLocalUrl($url));
1594  }
1595 
1601  {
1604  true,
1605  false,
1610  ‪Environment::getPublicPath() . '/index.php',
1611  ‪Environment::isWindows() ? 'WINDOWS' : 'UNIX'
1612  );
1613  $_SERVER['HTTP_HOST'] = 'localhost';
1614  $_SERVER['SCRIPT_NAME'] = 'index.php';
1615  self::assertEquals('', GeneralUtility::sanitizeLocalUrl($url));
1616  }
1617 
1623  {
1624  self::assertEquals('', GeneralUtility::sanitizeLocalUrl(rawurlencode($url)));
1625  }
1626 
1628  // Tests concerning unlink_tempfile
1630 
1635  {
1636  $fixtureFile = __DIR__ . '/Fixtures/clear.gif';
1637  $testFilename = ‪Environment::getVarPath() . '/tests/' . ‪StringUtility::getUniqueId('test_') . '.gif';
1638  @copy($fixtureFile, $testFilename);
1639  GeneralUtility::unlink_tempfile($testFilename);
1640  $fileExists = file_exists($testFilename);
1641  self::assertFalse($fileExists);
1642  }
1643 
1647  public function ‪unlink_tempfileRemovesHiddenFile(): void
1648  {
1649  $fixtureFile = __DIR__ . '/Fixtures/clear.gif';
1650  $testFilename = ‪Environment::getVarPath() . '/tests/' . ‪StringUtility::getUniqueId('.test_') . '.gif';
1651  @copy($fixtureFile, $testFilename);
1652  GeneralUtility::unlink_tempfile($testFilename);
1653  $fileExists = file_exists($testFilename);
1654  self::assertFalse($fileExists);
1655  }
1656 
1661  {
1662  $fixtureFile = __DIR__ . '/Fixtures/clear.gif';
1663  $testFilename = $this->‪getTestDirectory() . '/' . ‪StringUtility::getUniqueId('test_') . '.gif';
1664  @copy($fixtureFile, $testFilename);
1665  $returnValue = GeneralUtility::unlink_tempfile($testFilename);
1666  self::assertTrue($returnValue);
1667  }
1668 
1673  {
1674  $returnValue = GeneralUtility::unlink_tempfile(‪Environment::getVarPath() . '/tests/' . ‪StringUtility::getUniqueId('i_do_not_exist'));
1675  self::assertNull($returnValue);
1676  }
1677 
1682  {
1683  $returnValue = GeneralUtility::unlink_tempfile('/tmp/typo3-unit-test-unlink_tempfile');
1684  self::assertNull($returnValue);
1685  }
1686 
1688  // Tests concerning tempnam
1690 
1695  {
1696  $filePath = GeneralUtility::tempnam('foo');
1697  $this->testFilesToDelete[] = $filePath;
1698  $fileName = basename($filePath);
1699  self::assertStringStartsWith('foo', $fileName);
1700  }
1701 
1706  {
1707  $filePath = GeneralUtility::tempnam('foo');
1708  $this->testFilesToDelete[] = $filePath;
1709  self::assertStringNotContainsString('\\', $filePath);
1710  }
1711 
1716  {
1717  $filePath = GeneralUtility::tempnam('foo');
1718  $this->testFilesToDelete[] = $filePath;
1719  self::assertStringStartsWith(‪Environment::getVarPath() . '/transient/', $filePath);
1720  }
1721 
1723  // Tests concerning removeDotsFromTS
1725 
1729  {
1730  $typoScript = [
1731  'propertyA.' => [
1732  'keyA.' => [
1733  'valueA' => 1,
1734  ],
1735  'keyB' => 2,
1736  ],
1737  'propertyB' => 3,
1738  ];
1739  $expectedResult = [
1740  'propertyA' => [
1741  'keyA' => [
1742  'valueA' => 1,
1743  ],
1744  'keyB' => 2,
1745  ],
1746  'propertyB' => 3,
1747  ];
1748  self::assertEquals($expectedResult, GeneralUtility::removeDotsFromTS($typoScript));
1749  }
1750 
1752  // Tests concerning implodeAttributes
1754 
1755  public function ‪implodeAttributesDataProvider(): \Iterator
1756  {
1757  yield 'Generic input without xhtml' => [
1758  ['hREf' => 'https://example.com', 'title' => 'above'],
1759  false,
1760  true,
1761  'hREf="https://example.com" title="above"',
1762  ];
1763  yield 'Generic input' => [
1764  ['hREf' => 'https://example.com', 'title' => 'above'],
1765  true,
1766  true,
1767  'href="https://example.com" title="above"',
1768  ];
1769  yield 'Generic input keeping empty values' => [
1770  ['hREf' => 'https://example.com', 'title' => ''],
1771  true,
1772  true, // keep empty values
1773  'href="https://example.com" title=""',
1774  ];
1775  yield 'Generic input removing empty values' => [
1776  ['hREf' => 'https://example.com', 'title' => '', 'nomodule' => null],
1777  true,
1778  false, // do not keep empty values
1779  'href="https://example.com"',
1780  ];
1781  }
1782 
1787  public function ‪implodeAttributesEscapesProperly(array $input, bool $xhtmlSafe, bool $keepEmptyValues, string $expected): void
1788  {
1789  self::assertSame($expected, GeneralUtility::implodeAttributes($input, $xhtmlSafe, $keepEmptyValues));
1790  }
1791 
1796  {
1797  $typoScript = [
1798  'propertyA.' => [
1799  'keyA' => 'getsOverridden',
1800  'keyA.' => [
1801  'valueA' => 1,
1802  ],
1803  'keyB' => 2,
1804  ],
1805  'propertyB' => 3,
1806  ];
1807  $expectedResult = [
1808  'propertyA' => [
1809  'keyA' => [
1810  'valueA' => 1,
1811  ],
1812  'keyB' => 2,
1813  ],
1814  'propertyB' => 3,
1815  ];
1816  self::assertEquals($expectedResult, GeneralUtility::removeDotsFromTS($typoScript));
1817  }
1818 
1823  {
1824  $typoScript = [
1825  'propertyA.' => [
1826  'keyA.' => [
1827  'valueA' => 1,
1828  ],
1829  'keyA' => 'willOverride',
1830  'keyB' => 2,
1831  ],
1832  'propertyB' => 3,
1833  ];
1834  $expectedResult = [
1835  'propertyA' => [
1836  'keyA' => 'willOverride',
1837  'keyB' => 2,
1838  ],
1839  'propertyB' => 3,
1840  ];
1841  self::assertEquals($expectedResult, GeneralUtility::removeDotsFromTS($typoScript));
1842  }
1843 
1845  // Tests concerning get_dirs
1847 
1851  {
1853  self::assertIsArray($directories);
1854  }
1855 
1860  {
1861  $path = 'foo';
1862  $result = ‪GeneralUtility::get_dirs($path);
1863  $expectedResult = 'error';
1864  self::assertEquals($expectedResult, $result);
1865  }
1866 
1868  // Tests concerning hmac
1870 
1873  public function ‪hmacReturnsHashOfProperLength(): void
1874  {
1875  $hmac = ‪GeneralUtility::hmac('message');
1876  self::assertTrue(!empty($hmac) && is_string($hmac));
1877  self::assertEquals(strlen($hmac), 40);
1878  }
1879 
1884  {
1885  $msg0 = 'message';
1886  $msg1 = 'message';
1887  self::assertEquals(‪GeneralUtility::hmac($msg0), ‪GeneralUtility::hmac($msg1));
1888  }
1889 
1894  {
1895  $msg0 = 'message0';
1896  $msg1 = 'message1';
1897  self::assertNotEquals(‪GeneralUtility::hmac($msg0), ‪GeneralUtility::hmac($msg1));
1898  }
1899 
1901  // Tests concerning quoteJSvalue
1903 
1906  public function ‪quoteJsValueDataProvider(): array
1907  {
1908  return [
1909  'Immune characters are returned as is' => [
1910  '._,',
1911  '._,',
1912  ],
1913  'Alphanumerical characters are returned as is' => [
1914  'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789',
1915  'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789',
1916  ],
1917  'Angle brackets and ampersand are encoded' => [
1918  '<>&',
1919  '\\u003C\\u003E\\u0026',
1920  ],
1921  'Quotes and backslashes are encoded' => [
1922  '"\'\\',
1923  '\\u0022\\u0027\\u005C',
1924  ],
1925  'Forward slashes are escaped' => [
1926  '</script>',
1927  '\\u003C\\/script\\u003E',
1928  ],
1929  'Empty string stays empty' => [
1930  '',
1931  '',
1932  ],
1933  'Exclamation mark and space are properly encoded' => [
1934  'Hello World!',
1935  'Hello\\u0020World\\u0021',
1936  ],
1937  'Whitespaces are properly encoded' => [
1938  "\t" . LF . CR . ' ',
1939  '\\u0009\\u000A\\u000D\\u0020',
1940  ],
1941  'Null byte is properly encoded' => [
1942  "\0",
1943  '\\u0000',
1944  ],
1945  'Umlauts are properly encoded' => [
1946  'ÜüÖöÄä',
1947  '\\u00dc\\u00fc\\u00d6\\u00f6\\u00c4\\u00e4',
1948  ],
1949  ];
1950  }
1951 
1956  public function ‪quoteJsValueTest(string $input, string $expected): void
1957  {
1958  self::assertSame('\'' . $expected . '\'', GeneralUtility::quoteJSvalue($input));
1959  }
1960 
1961  public static function ‪jsonEncodeForHtmlAttributeTestDataProvider(): array
1962  {
1963  return [
1964  [
1965  ['html' => '<tag attr="\\Vendor\\Package">value</tag>'],
1966  true,
1967  // cave: `\\\\` (four) actually required for PHP only, will be `\\` (two) in HTML
1968  '{&quot;html&quot;:&quot;\u003Ctag attr=\u0022\\\\Vendor\\\\Package\u0022\u003Evalue\u003C\/tag\u003E&quot;}',
1969  ],
1970  [
1971  ['html' => '<tag attr="\\Vendor\\Package">value</tag>'],
1972  false,
1973  // cave: `\\\\` (four) actually required for PHP only, will be `\\` (two) in HTML
1974  '{"html":"\u003Ctag attr=\u0022\\\\Vendor\\\\Package\u0022\u003Evalue\u003C\/tag\u003E"}',
1975  ],
1976  [
1977  ['spaces' => '|' . chr(9) . '|' . chr(10) . '|' . chr(13) . '|'],
1978  false,
1979  '{"spaces":"|\t|\n|\r|"}',
1980  ],
1981  ];
1982  }
1983 
1988  public function ‪jsonEncodeForHtmlAttributeTest($value, bool $useHtmlEntities, string $expectation): void
1989  {
1990  self::assertSame($expectation, GeneralUtility::jsonEncodeForHtmlAttribute($value, $useHtmlEntities));
1991  }
1992 
1993  public static function ‪jsonEncodeForJavaScriptTestDataProvider(): array
1994  {
1995  return [
1996  [
1997  ['html' => '<tag attr="\\Vendor\\Package">value</tag>'],
1998  // cave: `\\\\` (four) actually required for PHP only, will be `\\` (two) in JavaScript
1999  '{"html":"\u003Ctag attr=\u0022\\\\u005CVendor\\\\u005CPackage\u0022\u003Evalue\u003C\/tag\u003E"}',
2000  ],
2001  [
2002  ['spaces' => '|' . chr(9) . '|' . chr(10) . '|' . chr(13) . '|'],
2003  '{"spaces":"|\u0009|\u000A|\u000D|"}',
2004  ],
2005  ];
2006  }
2007 
2012  public function ‪jsonEncodeForJavaScriptTest($value, string $expectation): void
2013  {
2014  self::assertSame($expectation, GeneralUtility::jsonEncodeForJavaScript($value));
2015  }
2016 
2018  // Tests concerning fixPermissions
2020 
2024  public function ‪fixPermissionsSetsGroup(): void
2025  {
2026  if (‪Environment::isWindows()) {
2027  self::markTestSkipped(self::NO_FIX_PERMISSIONS_ON_WINDOWS);
2028  }
2029  // Create and prepare test file
2030  $filename = $this->‪getTestDirectory() . '/' . ‪StringUtility::getUniqueId('test_');
2032  $currentGroupId = posix_getegid();
2033  // Set target group and run method
2034  ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['createGroup'] = $currentGroupId;
2036  clearstatcache();
2037  self::assertEquals($currentGroupId, filegroup($filename));
2038  }
2039 
2044  {
2045  if (‪Environment::isWindows()) {
2046  self::markTestSkipped(self::NO_FIX_PERMISSIONS_ON_WINDOWS);
2047  }
2048  // Create and prepare test file
2049  $filename = $this->‪getTestDirectory() . '/' . ‪StringUtility::getUniqueId('test_');
2051  chmod($filename, 482);
2052  // Set target permissions and run method
2053  ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['fileCreateMask'] = '0660';
2054  $fixPermissionsResult = ‪GeneralUtilityFilesystemFixture::fixPermissions($filename);
2055  clearstatcache();
2056  self::assertTrue($fixPermissionsResult);
2057  self::assertEquals('0660', substr(decoct(fileperms($filename)), 2));
2058  }
2059 
2064  {
2065  if (‪Environment::isWindows()) {
2066  self::markTestSkipped(self::NO_FIX_PERMISSIONS_ON_WINDOWS);
2067  }
2068  // Create and prepare test file
2069  $filename = $this->‪getTestDirectory() . '/' . ‪StringUtility::getUniqueId('test_');
2071  chmod($filename, 482);
2072  // Set target permissions and run method
2073  ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['fileCreateMask'] = '0660';
2074  $fixPermissionsResult = ‪GeneralUtilityFilesystemFixture::fixPermissions($filename);
2075  clearstatcache();
2076  self::assertTrue($fixPermissionsResult);
2077  self::assertEquals('0660', substr(decoct(fileperms($filename)), 2));
2078  }
2079 
2084  {
2085  if (‪Environment::isWindows()) {
2086  self::markTestSkipped(self::NO_FIX_PERMISSIONS_ON_WINDOWS);
2087  }
2088  // Create and prepare test directory
2089  $directory = $this->‪getTestDirectory() . '/' . ‪StringUtility::getUniqueId('test_');
2091  chmod($directory, 1551);
2092  // Set target permissions and run method
2093  ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['folderCreateMask'] = '0770';
2094  $fixPermissionsResult = ‪GeneralUtilityFilesystemFixture::fixPermissions($directory);
2095  clearstatcache();
2096  self::assertTrue($fixPermissionsResult);
2097  self::assertEquals('0770', substr(decoct(fileperms($directory)), 1));
2098  }
2099 
2104  {
2105  if (‪Environment::isWindows()) {
2106  self::markTestSkipped(self::NO_FIX_PERMISSIONS_ON_WINDOWS);
2107  }
2108  // Create and prepare test directory
2109  $directory = $this->‪getTestDirectory() . '/' . ‪StringUtility::getUniqueId('test_');
2111  chmod($directory, 1551);
2112  // Set target permissions and run method
2113  ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['folderCreateMask'] = '0770';
2114  $fixPermissionsResult = ‪GeneralUtilityFilesystemFixture::fixPermissions($directory . '/');
2115  // Get actual permissions and clean up
2116  clearstatcache();
2117  self::assertTrue($fixPermissionsResult);
2118  self::assertEquals('0770', substr(decoct(fileperms($directory)), 1));
2119  }
2120 
2125  {
2126  if (‪Environment::isWindows()) {
2127  self::markTestSkipped(self::NO_FIX_PERMISSIONS_ON_WINDOWS);
2128  }
2129  // Create and prepare test directory
2130  $directory = $this->‪getTestDirectory() . '/' . ‪StringUtility::getUniqueId('test_');
2132  chmod($directory, 1551);
2133  // Set target permissions and run method
2134  ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['folderCreateMask'] = '0770';
2135  $fixPermissionsResult = ‪GeneralUtilityFilesystemFixture::fixPermissions($directory);
2136  // Get actual permissions and clean up
2137  clearstatcache();
2138  self::assertTrue($fixPermissionsResult);
2139  self::assertEquals('0770', substr(decoct(fileperms($directory)), 1));
2140  }
2141 
2146  {
2147  if (‪Environment::isWindows()) {
2148  self::markTestSkipped(self::NO_FIX_PERMISSIONS_ON_WINDOWS);
2149  }
2150  // Create and prepare test directory and file structure
2151  $baseDirectory = $this->‪getTestDirectory() . '/' . ‪StringUtility::getUniqueId('test_');
2153  chmod($baseDirectory, 1751);
2154  ‪GeneralUtilityFilesystemFixture::writeFileToTypo3tempDir($baseDirectory . '/file', '42');
2155  chmod($baseDirectory . '/file', 482);
2156  ‪GeneralUtilityFilesystemFixture::mkdir($baseDirectory . '/foo');
2157  chmod($baseDirectory . '/foo', 1751);
2158  ‪GeneralUtilityFilesystemFixture::writeFileToTypo3tempDir($baseDirectory . '/foo/file', '42');
2159  chmod($baseDirectory . '/foo/file', 482);
2160  ‪GeneralUtilityFilesystemFixture::mkdir($baseDirectory . '/.bar');
2161  chmod($baseDirectory . '/.bar', 1751);
2162  // Use this if writeFileToTypo3tempDir is fixed to create hidden files in subdirectories
2163  // \TYPO3\CMS\Core\Utility\GeneralUtility::writeFileToTypo3tempDir($baseDirectory . '/.bar/.file', '42');
2164  // \TYPO3\CMS\Core\Utility\GeneralUtility::writeFileToTypo3tempDir($baseDirectory . '/.bar/..file2', '42');
2165  touch($baseDirectory . '/.bar/.file', 42);
2166  chmod($baseDirectory . '/.bar/.file', 482);
2167  touch($baseDirectory . '/.bar/..file2', 42);
2168  chmod($baseDirectory . '/.bar/..file2', 482);
2169  // Set target permissions and run method
2170  ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['fileCreateMask'] = '0660';
2171  ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['folderCreateMask'] = '0770';
2172  $fixPermissionsResult = ‪GeneralUtilityFilesystemFixture::fixPermissions($baseDirectory, true);
2173  // Get actual permissions
2174  clearstatcache();
2175  $resultBaseDirectoryPermissions = substr(decoct(fileperms($baseDirectory)), 1);
2176  $resultBaseFilePermissions = substr(decoct(fileperms($baseDirectory . '/file')), 2);
2177  $resultFooDirectoryPermissions = substr(decoct(fileperms($baseDirectory . '/foo')), 1);
2178  $resultFooFilePermissions = substr(decoct(fileperms($baseDirectory . '/foo/file')), 2);
2179  $resultBarDirectoryPermissions = substr(decoct(fileperms($baseDirectory . '/.bar')), 1);
2180  $resultBarFilePermissions = substr(decoct(fileperms($baseDirectory . '/.bar/.file')), 2);
2181  $resultBarFile2Permissions = substr(decoct(fileperms($baseDirectory . '/.bar/..file2')), 2);
2182  // Test if everything was ok
2183  self::assertTrue($fixPermissionsResult);
2184  self::assertEquals('0770', $resultBaseDirectoryPermissions);
2185  self::assertEquals('0660', $resultBaseFilePermissions);
2186  self::assertEquals('0770', $resultFooDirectoryPermissions);
2187  self::assertEquals('0660', $resultFooFilePermissions);
2188  self::assertEquals('0770', $resultBarDirectoryPermissions);
2189  self::assertEquals('0660', $resultBarFilePermissions);
2190  self::assertEquals('0660', $resultBarFile2Permissions);
2191  }
2192 
2197  {
2198  if (‪Environment::isWindows()) {
2199  self::markTestSkipped(self::NO_FIX_PERMISSIONS_ON_WINDOWS);
2200  }
2201  // Create and prepare test file
2202  $filename = ‪Environment::getVarPath() . '/tests/../../../typo3temp/var/tests/' . ‪StringUtility::getUniqueId('test_');
2203  // Set target permissions and run method
2204  ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['fileCreateMask'] = '0660';
2205  $fixPermissionsResult = ‪GeneralUtility::fixPermissions($filename);
2206  self::assertFalse($fixPermissionsResult);
2207  }
2208 
2213  {
2214  if (‪Environment::isWindows()) {
2215  self::markTestSkipped(self::NO_FIX_PERMISSIONS_ON_WINDOWS);
2216  }
2217  $filename = 'typo3temp/var/tests/' . ‪StringUtility::getUniqueId('test_');
2219  $this->testFilesToDelete[] = ‪Environment::getPublicPath() . '/' . $filename;
2220  chmod(‪Environment::getPublicPath() . '/' . $filename, 482);
2221  // Set target permissions and run method
2222  ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['fileCreateMask'] = '0660';
2223  $fixPermissionsResult = ‪GeneralUtility::fixPermissions($filename);
2224  clearstatcache();
2225  self::assertTrue($fixPermissionsResult);
2226  self::assertEquals('0660', substr(decoct(fileperms(‪Environment::getPublicPath() . '/' . $filename)), 2));
2227  }
2228 
2233  {
2234  if (‪Environment::isWindows()) {
2235  self::markTestSkipped(self::NO_FIX_PERMISSIONS_ON_WINDOWS);
2236  }
2237  $filename = $this->‪getTestDirectory() . '/' . ‪StringUtility::getUniqueId('test_');
2239  chmod($filename, 482);
2240  unset(‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['fileCreateMask']);
2241  $fixPermissionsResult = ‪GeneralUtilityFilesystemFixture::fixPermissions($filename);
2242  clearstatcache();
2243  self::assertTrue($fixPermissionsResult);
2244  self::assertEquals('0644', substr(decoct(fileperms($filename)), 2));
2245  }
2246 
2251  {
2252  if (‪Environment::isWindows()) {
2253  self::markTestSkipped(self::NO_FIX_PERMISSIONS_ON_WINDOWS);
2254  }
2255  $directory = $this->‪getTestDirectory() . '/' . ‪StringUtility::getUniqueId('test_');
2257  chmod($directory, 1551);
2258  unset(‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['folderCreateMask']);
2259  $fixPermissionsResult = ‪GeneralUtilityFilesystemFixture::fixPermissions($directory);
2260  clearstatcache();
2261  self::assertTrue($fixPermissionsResult);
2262  self::assertEquals('0755', substr(decoct(fileperms($directory)), 1));
2263  }
2264 
2266  // Tests concerning mkdir
2268 
2271  public function ‪mkdirCreatesDirectory(): void
2272  {
2273  $directory = $this->‪getTestDirectory() . '/' . ‪StringUtility::getUniqueId('test_');
2274  $mkdirResult = ‪GeneralUtilityFilesystemFixture::mkdir($directory);
2275  clearstatcache();
2276  self::assertTrue($mkdirResult);
2277  self::assertDirectoryExists($directory);
2278  }
2279 
2283  public function ‪mkdirCreatesHiddenDirectory(): void
2284  {
2285  $directory = $this->‪getTestDirectory() . '/' . ‪StringUtility::getUniqueId('.test_');
2286  $mkdirResult = ‪GeneralUtilityFilesystemFixture::mkdir($directory);
2287  clearstatcache();
2288  self::assertTrue($mkdirResult);
2289  self::assertDirectoryExists($directory);
2290  }
2291 
2296  {
2297  $directory = $this->‪getTestDirectory() . '/' . ‪StringUtility::getUniqueId('test_') . '/';
2298  $mkdirResult = ‪GeneralUtilityFilesystemFixture::mkdir($directory);
2299  clearstatcache();
2300  self::assertTrue($mkdirResult);
2301  self::assertDirectoryExists($directory);
2302  }
2303 
2308  {
2309  if (‪Environment::isWindows()) {
2310  self::markTestSkipped(self::NO_FIX_PERMISSIONS_ON_WINDOWS);
2311  }
2312  $directory = $this->‪getTestDirectory() . '/' . ‪StringUtility::getUniqueId('test_');
2313  $oldUmask = umask(19);
2314  ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['folderCreateMask'] = '0772';
2316  clearstatcache();
2317  $resultDirectoryPermissions = substr(decoct(fileperms($directory)), 1);
2318  umask($oldUmask);
2319  self::assertEquals('0772', $resultDirectoryPermissions);
2320  }
2321 
2323  // Tests concerning writeFileToTypo3tempDir()
2325 
2331  {
2332  return [
2333  [
2334  ‪Environment::getPublicPath() . '/../path/this-path-has-more-than-60-characters-in-one-base-path-you-can-even-count-more',
2335  'Input filepath "' . ‪Environment::getPublicPath() . '/../path/this-path-has-more-than-60-characters-in-one-base-path-you-can-even-count-more" was generally invalid!',
2336  '',
2337  ],
2338  [
2339  ‪Environment::getPublicPath() . '/dummy/path/this-path-has-more-than-60-characters-in-one-base-path-you-can-even-count-more',
2340  '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!',
2341  '',
2342  ],
2343  [
2344  ‪Environment::getPublicPath() . '/dummy/path/this-path-has-more-than-60-characters-in-one-base-path-you-can-even-count-more',
2345  '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!',
2346  '',
2347  ],
2348  [
2349  '/dummy/path/awesome',
2350  '"/dummy/path/" was not within directory Environment::getPublicPath() + "/typo3temp/"',
2351  '',
2352  ],
2353  [
2355  '"' . ‪Environment::getLegacyConfigPath() . '/" was not within directory Environment::getPublicPath() + "/typo3temp/"',
2356  '',
2357  ],
2358  [
2359  ‪Environment::getPublicPath() . '/typo3temp/táylor/swíft',
2360  'Subdir, "táylor/", was NOT on the form "[[:alnum:]_]/+"',
2361  '',
2362  ],
2363  'Path instead of file given' => [
2364  ‪Environment::getPublicPath() . '/typo3temp/dummy/path/',
2365  'Calculated file location didn\'t match input "' . ‪Environment::getPublicPath() . '/typo3temp/dummy/path/".',
2366  ‪Environment::getPublicPath() . '/typo3temp/dummy/',
2367  ],
2368  ];
2369  }
2370 
2377  public function ‪writeFileToTypo3tempDirFailsWithInvalidPath(string $invalidFilePath, string $expectedResult, string $pathToCleanUp): void
2378  {
2379  if ($pathToCleanUp !== '') {
2380  $this->testFilesToDelete[] = $pathToCleanUp;
2381  }
2382  $result = ‪GeneralUtility::writeFileToTypo3tempDir($invalidFilePath, 'dummy content to be written');
2383  self::assertSame($result, $expectedResult);
2384  }
2385 
2391  {
2392  return [
2393  'Default text file' => [
2394  ‪Environment::getVarPath() . '/tests/paranoid/android.txt',
2395  ‪Environment::getVarPath() . '/tests/',
2396  ],
2397  'Html file extension' => [
2398  ‪Environment::getVarPath() . '/tests/karma.html',
2399  ‪Environment::getVarPath() . '/tests/',
2400  ],
2401  'No file extension' => [
2402  ‪Environment::getVarPath() . '/tests/no-surprises',
2403  ‪Environment::getVarPath() . '/tests/',
2404  ],
2405  'Deep directory' => [
2406  ‪Environment::getVarPath() . '/tests/climbing/up/the/walls',
2407  ‪Environment::getVarPath() . '/tests/',
2408  ],
2409  'File in typo3temp/var directory' => [
2410  ‪Environment::getPublicPath() . '/typo3temp/var/path/foo.txt',
2411  ‪Environment::getPublicPath() . '/typo3temp/var/path',
2412  ],
2413  ];
2414  }
2415 
2422  public function ‪writeFileToTypo3tempDirWorksWithValidPath(string $filePath, string $pathToCleanUp): void
2423  {
2424  if ($pathToCleanUp !== '') {
2425  $this->testFilesToDelete[] = $pathToCleanUp;
2426  }
2427 
2428  $dummyContent = 'Please could you stop the noise, I\'m trying to get some rest from all the unborn chicken voices in my head.';
2429 
2430  $result = ‪GeneralUtility::writeFileToTypo3tempDir($filePath, $dummyContent);
2431 
2432  self::assertNull($result);
2433  self::assertFileExists($filePath);
2434  self::assertStringEqualsFile($filePath, $dummyContent);
2435  }
2436 
2438  // Tests concerning mkdir_deep
2440 
2443  public function ‪mkdirDeepCreatesDirectory(): void
2444  {
2445  $directory = $this->‪getTestDirectory() . '/' . ‪StringUtility::getUniqueId('test_');
2446  ‪GeneralUtility::mkdir_deep($directory);
2447  self::assertDirectoryExists($directory);
2448  }
2449 
2454  {
2455  $directory = $this->‪getTestDirectory() . '/typo3temp/var/tests/' . ‪StringUtility::getUniqueId('test_');
2456  $subDirectory = $directory . '/foo';
2457  ‪GeneralUtility::mkdir_deep($subDirectory);
2458  self::assertDirectoryExists($subDirectory);
2459  }
2460 
2465  {
2466  return [
2467  'no double slash if concatenated with Environment::getPublicPath()' => ['fileadmin/testDir1'],
2468  'double slash if concatenated with Environment::getPublicPath()' => ['/fileadmin/testDir2'],
2469  ];
2470  }
2471 
2476  public function ‪mkdirDeepCreatesDirectoryWithDoubleSlashes($directoryToCreate): void
2477  {
2478  $testRoot = ‪Environment::getVarPath() . '/public/';
2479  $this->testFilesToDelete[] = $testRoot;
2480  $directory = $testRoot . $directoryToCreate;
2481  ‪GeneralUtility::mkdir_deep($directory);
2482  self::assertDirectoryExists($directory);
2483  }
2484 
2489  {
2490  if (‪Environment::isWindows()) {
2491  self::markTestSkipped(self::NO_FIX_PERMISSIONS_ON_WINDOWS);
2492  }
2493  $directory = ‪StringUtility::getUniqueId('mkdirdeeptest_');
2494  $oldUmask = umask(19);
2495  ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['folderCreateMask'] = '0777';
2496  ‪GeneralUtility::mkdir_deep(‪Environment::getVarPath() . '/tests/' . $directory);
2497  $this->testFilesToDelete[] = ‪Environment::getVarPath() . '/tests/' . $directory;
2498  clearstatcache();
2499  umask($oldUmask);
2500  self::assertEquals('777', substr(decoct(fileperms(‪Environment::getVarPath() . '/tests/' . $directory)), -3, 3));
2501  }
2502 
2507  {
2508  if (‪Environment::isWindows()) {
2509  self::markTestSkipped(self::NO_FIX_PERMISSIONS_ON_WINDOWS);
2510  }
2511  $directory = ‪StringUtility::getUniqueId('mkdirdeeptest_');
2512  $subDirectory = $directory . '/bar';
2513  ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['folderCreateMask'] = '0777';
2514  $oldUmask = umask(19);
2515  ‪GeneralUtility::mkdir_deep(‪Environment::getVarPath() . '/tests/' . $subDirectory);
2516  $this->testFilesToDelete[] = ‪Environment::getVarPath() . '/tests/' . $directory;
2517  clearstatcache();
2518  umask($oldUmask);
2519  self::assertEquals('777', substr(decoct(fileperms(‪Environment::getVarPath() . '/tests/' . $directory)), -3, 3));
2520  }
2521 
2526  {
2527  if (‪Environment::isWindows()) {
2528  self::markTestSkipped(self::NO_FIX_PERMISSIONS_ON_WINDOWS);
2529  }
2530  $baseDirectory = $this->‪getTestDirectory();
2531  $existingDirectory = ‪StringUtility::getUniqueId('test_existing_') . '/';
2532  $newSubDirectory = ‪StringUtility::getUniqueId('test_new_');
2533  @mkdir($baseDirectory . $existingDirectory);
2534  $this->testFilesToDelete[] = $baseDirectory . $existingDirectory;
2535  chmod($baseDirectory . $existingDirectory, 482);
2536  ‪GeneralUtility::mkdir_deep($baseDirectory . $existingDirectory . $newSubDirectory);
2537  self::assertEquals(742, (int)substr(decoct(fileperms($baseDirectory . $existingDirectory)), 2));
2538  }
2539 
2544  {
2545  $this->expectException(\RuntimeException::class);
2546  $this->expectExceptionCode(1170251401);
2547 
2548  ‪GeneralUtility::mkdir_deep('http://localhost');
2549  }
2550 
2555  {
2556  $this->expectException(\InvalidArgumentException::class);
2557  $this->expectExceptionCode(1303662955);
2558 
2559  // @phpstan-ignore-next-line We're explicitly checking the behavior for a contract violation.
2561  }
2562 
2564  // Tests concerning rmdir
2566 
2570  public function ‪rmdirRemovesFile(): void
2571  {
2572  $testRoot = ‪Environment::getVarPath() . '/tests/';
2573  $this->testFilesToDelete[] = $testRoot;
2574  ‪GeneralUtility::mkdir_deep($testRoot);
2575  $file = $testRoot . ‪StringUtility::getUniqueId('file_');
2576  touch($file);
2577  ‪GeneralUtility::rmdir($file);
2578  self::assertFileDoesNotExist($file);
2579  }
2580 
2584  public function ‪rmdirReturnTrueIfFileWasRemoved(): void
2585  {
2586  $file = $this->‪getTestDirectory() . '/' . ‪StringUtility::getUniqueId('file_');
2587  touch($file);
2588  self::assertTrue(‪GeneralUtility::rmdir($file));
2589  }
2590 
2595  {
2596  $file = ‪Environment::getVarPath() . '/tests/' . ‪StringUtility::getUniqueId('file_');
2597  self::assertFalse(‪GeneralUtility::rmdir($file));
2598  }
2599 
2603  public function ‪rmdirRemovesDirectory(): void
2604  {
2605  $directory = $this->‪getTestDirectory() . '/' . ‪StringUtility::getUniqueId('directory_');
2606  mkdir($directory);
2607  ‪GeneralUtility::rmdir($directory);
2608  self::assertFileDoesNotExist($directory);
2609  }
2610 
2615  {
2616  $directory = $this->‪getTestDirectory() . '/' . ‪StringUtility::getUniqueId('directory_') . '/';
2617  ‪GeneralUtility::mkdir_deep($directory);
2618  ‪GeneralUtility::rmdir($directory);
2619  self::assertFileDoesNotExist($directory);
2620  }
2621 
2626  {
2627  $directory = $this->‪getTestDirectory() . '/' . ‪StringUtility::getUniqueId('directory_') . '/';
2628  ‪GeneralUtility::mkdir_deep($directory);
2629  $file = ‪StringUtility::getUniqueId('file_');
2630  touch($directory . $file);
2631  $return = ‪GeneralUtility::rmdir($directory);
2632  self::assertFileExists($directory);
2633  self::assertFileExists($directory . $file);
2634  self::assertFalse($return);
2635  }
2636 
2641  {
2642  $directory = $this->‪getTestDirectory() . '/' . ‪StringUtility::getUniqueId('directory_') . '/';
2643  mkdir($directory);
2644  mkdir($directory . 'sub/');
2645  touch($directory . 'sub/file');
2646  $return = ‪GeneralUtility::rmdir($directory, true);
2647  self::assertFileDoesNotExist($directory);
2648  self::assertTrue($return);
2649  }
2650 
2654  public function ‪rmdirRemovesLinkToDirectory(): void
2655  {
2656  $existingDirectory = $this->‪getTestDirectory() . '/' . ‪StringUtility::getUniqueId('notExists_') . '/';
2657  mkdir($existingDirectory);
2658  $symlinkName = ‪Environment::getVarPath() . '/tests/' . ‪StringUtility::getUniqueId('link_');
2659  symlink($existingDirectory, $symlinkName);
2660  ‪GeneralUtility::rmdir($symlinkName, true);
2661  self::assertFalse(is_link($symlinkName));
2662  }
2663 
2667  public function ‪rmdirRemovesDeadLinkToDirectory(): void
2668  {
2669  $notExistingDirectory = $this->‪getTestDirectory() . '/' . ‪StringUtility::getUniqueId('notExists_') . '/';
2670  $symlinkName = $this->‪getTestDirectory() . '/' . ‪StringUtility::getUniqueId('link_');
2671  ‪GeneralUtility::mkdir_deep($notExistingDirectory);
2672  symlink($notExistingDirectory, $symlinkName);
2673  rmdir($notExistingDirectory);
2674 
2675  ‪GeneralUtility::rmdir($symlinkName, true);
2676  self::assertFalse(is_link($symlinkName));
2677  }
2678 
2682  public function ‪rmdirRemovesDeadLinkToFile(): void
2683  {
2684  $testDirectory = $this->‪getTestDirectory() . '/';
2685  $notExistingFile = $testDirectory . ‪StringUtility::getUniqueId('notExists_');
2686  $symlinkName = $testDirectory . ‪StringUtility::getUniqueId('link_');
2687  touch($notExistingFile);
2688  symlink($notExistingFile, $symlinkName);
2689  unlink($notExistingFile);
2690  ‪GeneralUtility::rmdir($symlinkName, true);
2691  self::assertFalse(is_link($symlinkName));
2692  }
2693 
2695  // Tests concerning getFilesInDir
2697 
2703  protected function ‪getFilesInDirCreateTestDirectory(): string
2704  {
2705  $path = ‪Environment::getVarPath() . '/FilesInDirTests';
2706  $this->testFilesToDelete[] = $path;
2707  mkdir($path);
2708  mkdir($path . '/subDirectory');
2709  file_put_contents($path . '/subDirectory/test.php', 'butter');
2710  file_put_contents($path . '/subDirectory/other.php', 'milk');
2711  file_put_contents($path . '/subDirectory/stuff.csv', 'honey');
2712  file_put_contents($path . '/excludeMe.txt', 'cocoa nibs');
2713  file_put_contents($path . '/double.setup.typoscript', 'cool TS');
2714  file_put_contents($path . '/testB.txt', 'olive oil');
2715  file_put_contents($path . '/testA.txt', 'eggs');
2716  file_put_contents($path . '/testC.txt', 'carrots');
2717  file_put_contents($path . '/test.js', 'oranges');
2718  file_put_contents($path . '/test.css', 'apples');
2719  file_put_contents($path . '/.secret.txt', 'sammon');
2720  return $path;
2721  }
2722 
2726  public function ‪getFilesInDirFindsRegularFile(): void
2727  {
2728  $path = $this->‪getFilesInDirCreateTestDirectory();
2729  $files = GeneralUtility::getFilesInDir($path);
2730  self::assertContains('testA.txt', $files);
2731  }
2732 
2736  public function ‪getFilesInDirFindsHiddenFile(): void
2737  {
2738  $path = $this->‪getFilesInDirCreateTestDirectory();
2739  $files = GeneralUtility::getFilesInDir($path);
2740  self::assertContains('.secret.txt', $files);
2741  }
2742 
2746  public function ‪fileExtensionDataProvider(): array
2747  {
2748  return [
2749  'no space' => [
2750  'setup.typoscript,txt,js,css',
2751  ],
2752  'spaces' => [
2753  'setup.typoscript, txt, js, css',
2754  ],
2755  'mixed' => [
2756  'setup.typoscript , txt,js, css',
2757  ],
2758  'wild' => [
2759  'setup.typoscript, txt, js , css',
2760  ],
2761  ];
2762  }
2763 
2768  public function ‪getFilesInDirByExtensionFindsFiles($fileExtensions): void
2769  {
2770  $path = $this->‪getFilesInDirCreateTestDirectory();
2771  $files = GeneralUtility::getFilesInDir($path, $fileExtensions);
2772  self::assertContains('double.setup.typoscript', $files);
2773  self::assertContains('testA.txt', $files);
2774  self::assertContains('test.js', $files);
2775  self::assertContains('test.css', $files);
2776  }
2777 
2782  {
2783  $path = $this->‪getFilesInDirCreateTestDirectory();
2784  $files = GeneralUtility::getFilesInDir($path, 'txt,js');
2785  self::assertContains('testA.txt', $files);
2786  self::assertContains('test.js', $files);
2787  self::assertNotContains('test.css', $files);
2788  }
2789 
2794  {
2795  $path = $this->‪getFilesInDirCreateTestDirectory();
2796  $files = GeneralUtility::getFilesInDir($path, '', false, '', 'excludeMe.*');
2797  self::assertContains('test.js', $files);
2798  self::assertNotContains('excludeMe.txt', $files);
2799  }
2800 
2804  public function ‪getFilesInDirCanPrependPath(): void
2805  {
2806  $path = $this->‪getFilesInDirCreateTestDirectory();
2807  self::assertContains(
2808  $path . '/testA.txt',
2809  GeneralUtility::getFilesInDir($path, '', true)
2810  );
2811  }
2812 
2817  {
2818  $path = $this->‪getFilesInDirCreateTestDirectory();
2819  self::assertSame(
2820  ['.secret.txt', 'double.setup.typoscript', 'excludeMe.txt', 'test.css', 'test.js', 'testA.txt', 'testB.txt', 'testC.txt'],
2821  array_values(GeneralUtility::getFilesInDir($path))
2822  );
2823  }
2824 
2829  {
2830  $path = $this->‪getFilesInDirCreateTestDirectory();
2831  self::assertArrayHasKey(
2832  md5($path . '/testA.txt'),
2833  GeneralUtility::getFilesInDir($path)
2834  );
2835  }
2836 
2841  {
2842  $path = $this->‪getFilesInDirCreateTestDirectory();
2843  self::assertNotContains(
2844  'subDirectory',
2845  GeneralUtility::getFilesInDir($path)
2846  );
2847  }
2848 
2855  public function ‪getFilesInDirDoesNotFindDotfiles(): void
2856  {
2857  $path = $this->‪getFilesInDirCreateTestDirectory();
2858  $files = GeneralUtility::getFilesInDir($path);
2859  self::assertNotContains('..', $files);
2860  self::assertNotContains('.', $files);
2861  }
2862 
2864  // Tests concerning split_fileref
2866 
2870  {
2871  $directoryName = ‪StringUtility::getUniqueId('test_') . '.com';
2872  $directoryPath = ‪Environment::getVarPath() . '/tests/';
2873  @mkdir($directoryPath, octdec(‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['folderCreateMask']));
2874  $directory = $directoryPath . $directoryName;
2875  mkdir($directory, octdec(‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['folderCreateMask']));
2876  $fileInfo = GeneralUtility::split_fileref($directory);
2877  $directoryCreated = is_dir($directory);
2878  rmdir($directory);
2879  self::assertTrue($directoryCreated);
2880  self::assertIsArray($fileInfo);
2881  self::assertEquals($directoryPath, $fileInfo['path']);
2882  self::assertEquals($directoryName, $fileInfo['file']);
2883  self::assertEquals($directoryName, $fileInfo['filebody']);
2884  self::assertEquals('', $fileInfo['fileext']);
2885  self::assertArrayNotHasKey('realFileext', $fileInfo);
2886  }
2887 
2892  {
2893  $testFile = 'fileadmin/media/someFile.png';
2894  $fileInfo = GeneralUtility::split_fileref($testFile);
2895  self::assertIsArray($fileInfo);
2896  self::assertEquals('fileadmin/media/', $fileInfo['path']);
2897  self::assertEquals('someFile.png', $fileInfo['file']);
2898  self::assertEquals('someFile', $fileInfo['filebody']);
2899  self::assertEquals('png', $fileInfo['fileext']);
2900  }
2901 
2903  // Tests concerning dirname
2905 
2909  public function ‪dirnameDataProvider(): array
2910  {
2911  return [
2912  'absolute path with multiple part and file' => ['/dir1/dir2/script.php', '/dir1/dir2'],
2913  'absolute path with one part' => ['/dir1/', '/dir1'],
2914  'absolute path to file without extension' => ['/dir1/something', '/dir1'],
2915  'relative path with one part and file' => ['dir1/script.php', 'dir1'],
2916  'relative one-character path with one part and file' => ['d/script.php', 'd'],
2917  'absolute zero-part path with file' => ['/script.php', ''],
2918  'empty string' => ['', ''],
2919  ];
2920  }
2921 
2928  public function ‪dirnameWithDataProvider(string $input, string $expectedValue): void
2929  {
2930  self::assertEquals($expectedValue, GeneralUtility::dirname($input));
2931  }
2932 
2934  // Tests concerning resolveBackPath
2936 
2940  public function ‪resolveBackPathDataProvider(): array
2941  {
2942  return [
2943  'empty path' => ['', ''],
2944  'this directory' => ['./', './'],
2945  'relative directory without ..' => ['dir1/dir2/dir3/', 'dir1/dir2/dir3/'],
2946  'relative path without ..' => ['dir1/dir2/script.php', 'dir1/dir2/script.php'],
2947  'absolute directory without ..' => ['/dir1/dir2/dir3/', '/dir1/dir2/dir3/'],
2948  'absolute path without ..' => ['/dir1/dir2/script.php', '/dir1/dir2/script.php'],
2949  'only one directory upwards without trailing slash' => ['..', '..'],
2950  'only one directory upwards with trailing slash' => ['../', '../'],
2951  'one level with trailing ..' => ['dir1/..', ''],
2952  'one level with trailing ../' => ['dir1/../', ''],
2953  'two levels with trailing ..' => ['dir1/dir2/..', 'dir1'],
2954  'two levels with trailing ../' => ['dir1/dir2/../', 'dir1/'],
2955  'leading ../ without trailing /' => ['../dir1', '../dir1'],
2956  'leading ../ with trailing /' => ['../dir1/', '../dir1/'],
2957  'leading ../ and inside path' => ['../dir1/dir2/../dir3/', '../dir1/dir3/'],
2958  'one times ../ in relative directory' => ['dir1/../dir2/', 'dir2/'],
2959  'one times ../ in absolute directory' => ['/dir1/../dir2/', '/dir2/'],
2960  'one times ../ in relative path' => ['dir1/../dir2/script.php', 'dir2/script.php'],
2961  'one times ../ in absolute path' => ['/dir1/../dir2/script.php', '/dir2/script.php'],
2962  'consecutive ../' => ['dir1/dir2/dir3/../../../dir4', 'dir4'],
2963  'distributed ../ with trailing /' => ['dir1/../dir2/dir3/../', 'dir2/'],
2964  'distributed ../ without trailing /' => ['dir1/../dir2/dir3/..', 'dir2'],
2965  'multiple distributed and consecutive ../ together' => ['dir1/dir2/dir3/dir4/../../dir5/dir6/dir7/../dir8/', 'dir1/dir2/dir5/dir6/dir8/'],
2966  'dirname with leading ..' => ['dir1/..dir2/dir3/', 'dir1/..dir2/dir3/'],
2967  'dirname with trailing ..' => ['dir1/dir2../dir3/', 'dir1/dir2../dir3/'],
2968  'more times upwards than downwards in directory' => ['dir1/../../', '../'],
2969  'more times upwards than downwards in path' => ['dir1/../../script.php', '../script.php'],
2970  ];
2971  }
2972 
2979  public function ‪resolveBackPathWithDataProvider(string $input, string $expectedValue): void
2980  {
2981  self::assertEquals($expectedValue, GeneralUtility::resolveBackPath($input));
2982  }
2983 
2985  // Tests concerning makeInstance, setSingletonInstance, addInstance, purgeInstances
2987 
2991  {
2992  $this->expectException(\InvalidArgumentException::class);
2993  $this->expectExceptionCode(1288965219);
2994 
2995  // @phpstan-ignore-next-line We're explicitly checking the behavior for a contract violation.
2996  GeneralUtility::makeInstance('');
2997  }
2998 
3003  {
3004  $this->expectException(\InvalidArgumentException::class);
3005  $this->expectExceptionCode(1288965219);
3006 
3007  // @phpstan-ignore-next-line We're explicitly checking the behavior for a contract violation.
3008  GeneralUtility::makeInstance(null);
3009  }
3010 
3015  {
3016  $this->expectException(\InvalidArgumentException::class);
3017  $this->expectExceptionCode(1288965219);
3018 
3019  // @phpstan-ignore-next-line We're explicitly checking the behavior for a contract violation.
3020  GeneralUtility::makeInstance(0);
3021  }
3022 
3027  {
3028  $this->expectException(\InvalidArgumentException::class);
3029  $this->expectExceptionCode(1288965219);
3030 
3031  // @phpstan-ignore-next-line We're explicitly checking the behavior for a contract violation.
3032  GeneralUtility::makeInstance([]);
3033  }
3034 
3039  {
3040  $this->expectException(\InvalidArgumentException::class);
3041  $this->expectExceptionCode(1288965219);
3042 
3043  // @phpstan-ignore-next-line We're explicitly checking the behavior for a contract violation.
3044  GeneralUtility::makeInstance(['foo']);
3045  }
3046 
3051  {
3052  $this->expectException(\InvalidArgumentException::class);
3053  $this->expectExceptionCode(1420281366);
3054 
3055  GeneralUtility::makeInstance('\\TYPO3\\CMS\\Backend\\Controller\\BackendController');
3056  }
3057 
3061  public function ‪makeInstanceReturnsClassInstance(): void
3062  {
3063  self::assertInstanceOf(\stdClass::class, GeneralUtility::makeInstance(\stdClass::class));
3064  }
3065 
3070  {
3071  $instance = GeneralUtility::makeInstance(TwoParametersConstructorFixture::class, 'one parameter', 'another parameter');
3072  self::assertEquals('one parameter', $instance->constructorParameter1, 'The first constructor parameter has not been set.');
3073  self::assertEquals('another parameter', $instance->constructorParameter2, 'The second constructor parameter has not been set.');
3074  }
3075 
3080  {
3082  ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects'][OriginalClassFixture::class] = ['className' => ReplacementClassFixture::class];
3083  self::assertInstanceOf(ReplacementClassFixture::class, GeneralUtility::makeInstance(OriginalClassFixture::class));
3084  }
3085 
3090  {
3092  ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects'][OriginalClassFixture::class] = ['className' => ReplacementClassFixture::class];
3093  ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects'][ReplacementClassFixture::class] = ['className' => OtherReplacementClassFixture::class];
3094  self::assertInstanceOf(OtherReplacementClassFixture::class, GeneralUtility::makeInstance(OriginalClassFixture::class));
3095  }
3096 
3101  {
3102  $className = \stdClass::class;
3103  self::assertNotSame(GeneralUtility::makeInstance($className), GeneralUtility::makeInstance($className));
3104  }
3105 
3110  {
3111  $className = get_class($this->createMock(SingletonInterface::class));
3112  self::assertSame(GeneralUtility::makeInstance($className), GeneralUtility::makeInstance($className));
3113  }
3114 
3119  {
3120  $className = get_class($this->createMock(SingletonInterface::class));
3121  $instance = GeneralUtility::makeInstance($className);
3122  GeneralUtility::purgeInstances();
3123  self::assertNotSame($instance, GeneralUtility::makeInstance($className));
3124  }
3125 
3129  public function ‪makeInstanceInjectsLogger(): void
3130  {
3131  $instance = GeneralUtility::makeInstance(GeneralUtilityMakeInstanceInjectLoggerFixture::class);
3132  self::assertInstanceOf(LoggerInterface::class, $instance->getLogger());
3133  }
3134 
3139  {
3140  $this->expectException(\InvalidArgumentException::class);
3141  $this->expectExceptionCode(1288967479);
3142 
3143  $instance = $this->createMock(SingletonInterface::class);
3144  // @phpstan-ignore-next-line We are explicitly testing with a contract violation here.
3145  GeneralUtility::setSingletonInstance('', $instance);
3146  }
3147 
3152  {
3153  $this->expectException(\InvalidArgumentException::class);
3154  $this->expectExceptionCode(1288967686);
3155 
3156  $instance = $this->getMockBuilder(SingletonInterface::class)
3157  ->addMethods(['foo'])
3158  ->getMock();
3159  $singletonClassName = get_class($this->createMock(SingletonInterface::class));
3160  GeneralUtility::setSingletonInstance($singletonClassName, $instance);
3161  }
3162 
3167  {
3168  $instance = $this->createMock(SingletonInterface::class);
3169  $singletonClassName = get_class($instance);
3170  GeneralUtility::setSingletonInstance($singletonClassName, $instance);
3171  self::assertSame($instance, GeneralUtility::makeInstance($singletonClassName));
3172  }
3173 
3178  {
3179  $instance1 = $this->createMock(SingletonInterface::class);
3180  $singletonClassName = get_class($instance1);
3181  $instance2 = new $singletonClassName();
3182  GeneralUtility::setSingletonInstance($singletonClassName, $instance1);
3183  GeneralUtility::setSingletonInstance($singletonClassName, $instance2);
3184  self::assertSame($instance2, GeneralUtility::makeInstance($singletonClassName));
3185  }
3186 
3191  {
3192  $instance = $this->createMock(SingletonInterface::class);
3193  $instanceClassName = get_class($instance);
3194  GeneralUtility::setSingletonInstance($instanceClassName, $instance);
3195  $registeredSingletonInstances = GeneralUtility::getSingletonInstances();
3196  self::assertArrayHasKey($instanceClassName, $registeredSingletonInstances);
3197  self::assertSame($registeredSingletonInstances[$instanceClassName], $instance);
3198  }
3199 
3204  {
3205  ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects'][SingletonClassFixture::class]['className'] = ExtendedSingletonClassFixture::class;
3206  $anotherInstance = new ‪ExtendedSingletonClassFixture();
3207  GeneralUtility::makeInstance(SingletonClassFixture::class);
3208  GeneralUtility::setSingletonInstance(SingletonClassFixture::class, $anotherInstance);
3209  $result = GeneralUtility::makeInstance(SingletonClassFixture::class);
3210  self::assertSame($anotherInstance, $result);
3211  self::assertEquals(ExtendedSingletonClassFixture::class, get_class($anotherInstance));
3212  }
3213 
3218  {
3219  $instance = $this->createMock(SingletonInterface::class);
3220  $instanceClassName = get_class($instance);
3221  GeneralUtility::setSingletonInstance($instanceClassName, $instance);
3222  GeneralUtility::resetSingletonInstances([]);
3223  $registeredSingletonInstances = GeneralUtility::getSingletonInstances();
3224  self::assertArrayNotHasKey($instanceClassName, $registeredSingletonInstances);
3225  }
3226 
3231  {
3232  $instance = $this->createMock(SingletonInterface::class);
3233  $instanceClassName = get_class($instance);
3234  GeneralUtility::resetSingletonInstances(
3235  [$instanceClassName => $instance]
3236  );
3237  $registeredSingletonInstances = GeneralUtility::getSingletonInstances();
3238  self::assertArrayHasKey($instanceClassName, $registeredSingletonInstances);
3239  self::assertSame($registeredSingletonInstances[$instanceClassName], $instance);
3240  }
3241 
3246  {
3247  $this->expectException(\InvalidArgumentException::class);
3248  $this->expectExceptionCode(1288967479);
3249 
3250  // @phpstan-ignore-next-line We are explicitly testing with a contract violation here.
3251  GeneralUtility::addInstance('', new \stdClass());
3252  }
3253 
3258  {
3259  $this->expectException(\InvalidArgumentException::class);
3260  $this->expectExceptionCode(1288967686);
3261 
3262  $instance = $this->getMockBuilder(\stdClass::class)
3263  ->addMethods(['bar'])
3264  ->getMock();
3265  $singletonClassName = get_class($this->createMock(\stdClass::class));
3266  GeneralUtility::addInstance($singletonClassName, $instance);
3267  }
3268 
3273  {
3274  $this->expectException(\InvalidArgumentException::class);
3275  $this->expectExceptionCode(1288969325);
3276 
3277  $instance = $this->createMock(SingletonInterface::class);
3278  GeneralUtility::addInstance(get_class($instance), $instance);
3279  }
3280 
3285  {
3286  $instance = $this->createMock(\stdClass::class);
3287  $className = get_class($instance);
3288  GeneralUtility::addInstance($className, $instance);
3289  self::assertSame($instance, GeneralUtility::makeInstance($className));
3290  }
3291 
3296  {
3297  $instance = $this->createMock(\stdClass::class);
3298  $className = get_class($instance);
3299  GeneralUtility::addInstance($className, $instance);
3300  self::assertNotSame(GeneralUtility::makeInstance($className), GeneralUtility::makeInstance($className));
3301  }
3302 
3307  {
3308  $instance1 = $this->createMock(\stdClass::class);
3309  $className = get_class($instance1);
3310  GeneralUtility::addInstance($className, $instance1);
3311  $instance2 = new $className();
3312  GeneralUtility::addInstance($className, $instance2);
3313  self::assertSame($instance1, GeneralUtility::makeInstance($className), 'The first returned instance does not match the first added instance.');
3314  self::assertSame($instance2, GeneralUtility::makeInstance($className), 'The second returned instance does not match the second added instance.');
3315  }
3316 
3320  public function ‪purgeInstancesDropsAddedInstance(): void
3321  {
3322  $instance = $this->createMock(\stdClass::class);
3323  $className = get_class($instance);
3324  GeneralUtility::addInstance($className, $instance);
3325  GeneralUtility::purgeInstances();
3326  self::assertNotSame($instance, GeneralUtility::makeInstance($className));
3327  }
3328 
3329  public function ‪getFileAbsFileNameDataProvider(): array
3330  {
3331  return [
3332  'relative path is prefixed with public path' => [
3333  'fileadmin/foo.txt',
3334  ‪Environment::getPublicPath() . '/fileadmin/foo.txt',
3335  ],
3336  'relative path, referencing current directory is prefixed with public path' => [
3337  './fileadmin/foo.txt',
3338  ‪Environment::getPublicPath() . '/./fileadmin/foo.txt',
3339  ],
3340  'relative paths with back paths are not allowed and returned empty' => [
3341  '../fileadmin/foo.txt',
3342  '',
3343  ],
3344  'absolute paths with back paths are not allowed and returned empty' => [
3345  ‪Environment::getPublicPath() . '/../sysext/core/Resources/Public/Icons/Extension.png',
3346  '',
3347  ],
3348  'allowed absolute paths are returned as is' => [
3349  ‪Environment::getPublicPath() . '/fileadmin/foo.txt',
3350  ‪Environment::getPublicPath() . '/fileadmin/foo.txt',
3351  ],
3352  'disallowed absolute paths are returned empty' => [
3353  '/somewhere/fileadmin/foo.txt',
3354  '',
3355  ],
3356  'EXT paths are resolved to absolute paths' => [
3357  'EXT:foo/Resources/Private/Templates/Home.html',
3358  '/path/to/foo/Resources/Private/Templates/Home.html',
3359  ],
3360  ];
3361  }
3362 
3367  public function ‪getFileAbsFileNameReturnsCorrectValues(string $path, string $expected): void
3368  {
3369  // build the dummy package "foo" for use in ExtensionManagementUtility::extPath('foo');
3370  $package = $this->getMockBuilder(Package::class)
3371  ->disableOriginalConstructor()
3372  ->onlyMethods(['getPackagePath'])
3373  ->getMock();
3374  $packageManager = $this->getMockBuilder(PackageManager::class)
3375  ->onlyMethods(['isPackageActive', 'getPackage', 'getActivePackages'])
3376  ->disableOriginalConstructor()
3377  ->getMock();
3378  $package
3379  ->method('getPackagePath')
3380  ->willReturn('/path/to/foo/');
3381  $packageManager
3382  ->method('getActivePackages')
3383  ->willReturn(['foo' => $package]);
3384  $packageManager
3385  ->method('isPackageActive')
3386  ->with(self::equalTo('foo'))
3387  ->willReturn(true);
3388  $packageManager
3389  ->method('getPackage')
3390  ->with('foo')
3391  ->willReturn($package);
3393 
3394  $result = GeneralUtility::getFileAbsFileName($path);
3395  self::assertEquals($expected, $result);
3396  }
3397 
3402  {
3403  $data = [
3404  'double slash in path' => ['path//path'],
3405  'backslash in path' => ['path\\path'],
3406  'directory up in path' => ['path/../path'],
3407  'directory up at the beginning' => ['../path'],
3408  'NUL character in path' => ['path' . "\0" . 'path'],
3409  'BS character in path' => ['path' . chr(8) . 'path'],
3410  'invalid UTF-8-sequence' => ["\xc0" . 'path/path'],
3411  'Could be overlong NUL in some UTF-8 implementations, invalid in RFC3629' => ["\xc0\x80" . 'path/path'],
3412  ];
3413 
3414  // Mixing with regular utf-8
3415  $utf8Characters = 'Ссылка/';
3416  foreach ($data as $key => $value) {
3417  $data[$key . ' with UTF-8 characters prepended'] = [$utf8Characters . $value[0]];
3418  $data[$key . ' with UTF-8 characters appended'] = [$value[0] . $utf8Characters];
3419  }
3420 
3421  // Encoding with UTF-16
3422  foreach ($data as $key => $value) {
3423  $data[$key . ' encoded with UTF-16'] = [mb_convert_encoding($value[0], 'UTF-16')];
3424  }
3425 
3426  return $data;
3427  }
3428 
3435  public function ‪validPathStrDetectsInvalidCharacters(string $path): void
3436  {
3437  self::assertFalse(GeneralUtility::validPathStr($path));
3438  }
3439 
3443  public function ‪validPathStrDataProvider(): array
3444  {
3445  $data = [
3446  'normal ascii path' => ['fileadmin/templates/myfile..xml'],
3447  'special character' => ['fileadmin/templates/Ссылка (fce).xml'],
3448  ];
3449 
3450  return $data;
3451  }
3452 
3459  public function ‪validPathStrWorksWithUnicodeFileNames($path): void
3460  {
3461  self::assertTrue(GeneralUtility::validPathStr($path));
3462  }
3463 
3465  // Tests concerning copyDirectory
3467 
3472  {
3473  $sourceDirectory = 'typo3temp/var/tests/' . ‪StringUtility::getUniqueId('test_') . '/';
3474  $absoluteSourceDirectory = ‪Environment::getPublicPath() . '/' . $sourceDirectory;
3475  $this->testFilesToDelete[] = $absoluteSourceDirectory;
3476  ‪GeneralUtility::mkdir($absoluteSourceDirectory);
3477 
3478  $targetDirectory = 'typo3temp/var/tests/' . ‪StringUtility::getUniqueId('test_') . '/';
3479  $absoluteTargetDirectory = ‪Environment::getPublicPath() . '/' . $targetDirectory;
3480  $this->testFilesToDelete[] = $absoluteTargetDirectory;
3481 
3482  ‪GeneralUtility::writeFileToTypo3tempDir($absoluteSourceDirectory . 'file', '42');
3483  ‪GeneralUtility::mkdir($absoluteSourceDirectory . 'foo');
3484  ‪GeneralUtility::writeFileToTypo3tempDir($absoluteSourceDirectory . 'foo/file', '42');
3485 
3486  GeneralUtility::copyDirectory($sourceDirectory, $targetDirectory);
3487 
3488  self::assertFileExists($absoluteTargetDirectory . 'file');
3489  self::assertFileExists($absoluteTargetDirectory . 'foo/file');
3490  }
3491 
3496  {
3497  $sourceDirectory = 'typo3temp/var/tests/' . ‪StringUtility::getUniqueId('test_') . '/';
3498  $absoluteSourceDirectory = ‪Environment::getPublicPath() . '/' . $sourceDirectory;
3499  $this->testFilesToDelete[] = $absoluteSourceDirectory;
3500  ‪GeneralUtility::mkdir($absoluteSourceDirectory);
3501 
3502  $targetDirectory = 'typo3temp/var/tests/' . ‪StringUtility::getUniqueId('test_') . '/';
3503  $absoluteTargetDirectory = ‪Environment::getPublicPath() . '/' . $targetDirectory;
3504  $this->testFilesToDelete[] = $absoluteTargetDirectory;
3505 
3506  ‪GeneralUtility::writeFileToTypo3tempDir($absoluteSourceDirectory . 'file', '42');
3507  ‪GeneralUtility::mkdir($absoluteSourceDirectory . 'foo');
3508  ‪GeneralUtility::writeFileToTypo3tempDir($absoluteSourceDirectory . 'foo/file', '42');
3509 
3510  GeneralUtility::copyDirectory($absoluteSourceDirectory, $absoluteTargetDirectory);
3511 
3512  self::assertFileExists($absoluteTargetDirectory . 'file');
3513  self::assertFileExists($absoluteTargetDirectory . 'foo/file');
3514  }
3515 
3517  // Tests concerning deprecation log
3520  // Tests concerning callUserFunction
3522 
3527  public function ‪callUserFunctionWillThrowExceptionForInvalidParameters(string $functionName, int $expectedException): void
3528  {
3529  $this->expectException(\InvalidArgumentException::class);
3530  $this->expectExceptionCode($expectedException);
3531 
3532  $inputData = ['foo' => 'bar'];
3533  GeneralUtility::callUserFunction($functionName, $inputData, $this);
3534  }
3535 
3541  {
3542  return [
3543  'Function is not prefixed' => [self::class . '->calledUserFunction', 1294585865],
3544  'Class doesn\'t exists' => ['t3lib_divTest21345->user_calledUserFunction', 1294585866],
3545  'No method name' => [self::class, 1294585867],
3546  'No class name' => ['->user_calledUserFunction', 1294585866],
3547  'No function name' => ['', 1294585867],
3548  ];
3549  }
3550 
3558  public function ‪callUserFunctionCanCallFunction(): void
3559  {
3560  $inputData = ['foo' => 'bar'];
3561  $result = GeneralUtility::callUserFunction(static function () {
3562  return 'Worked fine';
3563  }, $inputData, $this, '');
3564  self::assertEquals('Worked fine', $result);
3565  }
3566 
3570  public function ‪callUserFunctionCanCallMethod(): void
3571  {
3572  $inputData = ['foo' => 'bar'];
3573  $result = GeneralUtility::callUserFunction(self::class . '->user_calledUserFunction', $inputData, $this);
3574  self::assertEquals('Worked fine', $result);
3575  }
3576 
3577  public function ‪user_calledUserFunction(): string
3578  {
3579  return 'Worked fine';
3580  }
3581 
3585  public function ‪callUserFunctionAcceptsClosures(): void
3586  {
3587  $inputData = ['foo' => 'bar'];
3588  $closure = static function ($parameters, $reference) use ($inputData) {
3589  $reference->assertEquals($inputData, $parameters, 'Passed data doesn\'t match expected output');
3590  return 'Worked fine';
3591  };
3592  self::assertEquals('Worked fine', GeneralUtility::callUserFunction($closure, $inputData, $this));
3593  }
3594 
3598  public function ‪callUserFunctionTrimsSpaces(): void
3599  {
3600  $inputData = ['foo' => 'bar'];
3601  $result = GeneralUtility::callUserFunction("\t" . self::class . '->user_calledUserFunction ', $inputData, $this);
3602  self::assertEquals('Worked fine', $result);
3603  }
3604 
3609  {
3610  $directory = $this->‪getTestDirectory() . '/' . ‪StringUtility::getUniqueId('directory_');
3611  mkdir($directory);
3612  $filesAndDirectories = GeneralUtility::getAllFilesAndFoldersInPath([], $directory, '', true);
3613  $check = true;
3614  foreach ($filesAndDirectories as $md5 => $path) {
3615  if (!preg_match('/^[a-f0-9]{32}$/', $md5)) {
3616  $check = false;
3617  }
3618  }
3619  ‪GeneralUtility::rmdir($directory);
3620  self::assertTrue($check);
3621  }
3622 
3630  {
3631  $input = [
3632  'el' => [],
3633  ];
3634 
3635  ‪$output = GeneralUtility::array2xml($input);
3636 
3637  self::assertEquals('<phparray>
3638  <el type="array"></el>
3639 </phparray>', ‪$output);
3640  }
3641 
3645  public function ‪xml2arrayUsesCache(): void
3646  {
3647  $cacheMock = $this->createMock(FrontendInterface::class);
3648  $cacheMock->method('getIdentifier')->willReturn('runtime');
3649  $cacheMock->expects(self::atLeastOnce())->method('get')->with('generalUtilityXml2Array')->willReturn(false);
3650  $cacheMock->expects(self::atLeastOnce())->method('set')->with('generalUtilityXml2Array', self::anything());
3651  $cacheManager = new ‪CacheManager();
3652  $cacheManager->registerCache($cacheMock);
3653  GeneralUtility::setSingletonInstance(CacheManager::class, $cacheManager);
3654  ‪GeneralUtility::xml2array('<?xml version="1.0" encoding="utf-8" standalone="yes"?>', 'T3:');
3655  }
3656 
3661  {
3662  $headerVariants = [
3663  'utf-8' => '<?xml version="1.0" encoding="utf-8" standalone="yes"?>',
3664  'UTF-8' => '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>',
3665  'no-encoding' => '<?xml version="1.0" standalone="yes"?>',
3666  'iso-8859-1' => '<?xml version="1.0" encoding="iso-8859-1" standalone="yes"?>',
3667  'ISO-8859-1' => '<?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?>',
3668  ];
3669  $data = [];
3670  foreach ($headerVariants as $identifier => $headerVariant) {
3671  $data += [
3672  'inputWithoutWhitespaces-' . $identifier => [
3673  $headerVariant . '<T3FlexForms>
3674  <data>
3675  <field index="settings.persistenceIdentifier">
3676  <value index="vDEF">egon</value>
3677  </field>
3678  </data>
3679  </T3FlexForms>',
3680  ],
3681  'inputWithPrecedingWhitespaces-' . $identifier => [
3682  CR . ' ' . $headerVariant . '<T3FlexForms>
3683  <data>
3684  <field index="settings.persistenceIdentifier">
3685  <value index="vDEF">egon</value>
3686  </field>
3687  </data>
3688  </T3FlexForms>',
3689  ],
3690  'inputWithTrailingWhitespaces-' . $identifier => [
3691  $headerVariant . '<T3FlexForms>
3692  <data>
3693  <field index="settings.persistenceIdentifier">
3694  <value index="vDEF">egon</value>
3695  </field>
3696  </data>
3697  </T3FlexForms>' . CR . ' ',
3698  ],
3699  'inputWithPrecedingAndTrailingWhitespaces-' . $identifier => [
3700  CR . ' ' . $headerVariant . '<T3FlexForms>
3701  <data>
3702  <field index="settings.persistenceIdentifier">
3703  <value index="vDEF">egon</value>
3704  </field>
3705  </data>
3706  </T3FlexForms>' . CR . ' ',
3707  ],
3708  ];
3709  }
3710  return $data;
3711  }
3712 
3717  public function ‪xml2arrayProcessHandlesWhitespaces(string $input): void
3718  {
3719  $expected = [
3720  'data' => [
3721  'settings.persistenceIdentifier' => [
3722  'vDEF' => 'egon',
3723  ],
3724  ],
3725  ];
3726  self::assertSame($expected, ‪GeneralUtility::xml2arrayProcess($input));
3727  }
3728 
3733  {
3734  return [
3735  'inputWithNameSpaceOnRootLevel' => [
3736  '<?xml version="1.0" encoding="utf-8" standalone="yes"?>
3737  <T3:T3FlexForms>
3738  <data>
3739  <field index="settings.persistenceIdentifier">
3740  <value index="vDEF">egon</value>
3741  </field>
3742  </data>
3743  </T3:T3FlexForms>',
3744  ],
3745  'inputWithNameSpaceOnNonRootLevel' => [
3746  '<?xml version="1.0" encoding="utf-8" standalone="yes"?>
3747  <T3FlexForms>
3748  <data>
3749  <T3:field index="settings.persistenceIdentifier">
3750  <value index="vDEF">egon</value>
3751  </T3:field>
3752  </data>
3753  </T3FlexForms>',
3754  ],
3755  'inputWithNameSpaceOnRootAndNonRootLevel' => [
3756  '<?xml version="1.0" encoding="utf-8" standalone="yes"?>
3757  <T3:T3FlexForms>
3758  <data>
3759  <T3:field index="settings.persistenceIdentifier">
3760  <value index="vDEF">egon</value>
3761  </T3:field>
3762  </data>
3763  </T3:T3FlexForms>',
3764  ],
3765  ];
3766  }
3767 
3772  public function ‪xml2arrayProcessHandlesTagNamespaces(string $input): void
3773  {
3774  $expected = [
3775  'data' => [
3776  'settings.persistenceIdentifier' => [
3777  'vDEF' => 'egon',
3778  ],
3779  ],
3780  ];
3781  self::assertSame($expected, ‪GeneralUtility::xml2arrayProcess($input, 'T3:'));
3782  }
3783 
3788  {
3789  return [
3790  'input' => [
3791  '<?xml version="1.0" encoding="utf-8" standalone="yes"?>
3792  <T3FlexForms>
3793  <data>
3794  <field index="settings.persistenceIdentifier">
3795  <value index="vDEF">egon</value>
3796  </field>
3797  </data>
3798  </T3FlexForms>',
3799  'T3FlexForms',
3800  ],
3801  'input-with-root-namespace' => [
3802  '<?xml version="1.0" encoding="utf-8" standalone="yes"?>
3803  <T3:T3FlexForms>
3804  <data>
3805  <field index="settings.persistenceIdentifier">
3806  <value index="vDEF">egon</value>
3807  </field>
3808  </data>
3809  </T3:T3FlexForms>',
3810  'T3:T3FlexForms',
3811  ],
3812  'input-with-namespace' => [
3813  '<?xml version="1.0" encoding="utf-8" standalone="yes"?>
3814  <T3FlexForms>
3815  <data>
3816  <T3:field index="settings.persistenceIdentifier">
3817  <value index="vDEF">egon</value>
3818  </T3:field>
3819  </data>
3820  </T3FlexForms>',
3821  'T3FlexForms',
3822  ],
3823  ];
3824  }
3825 
3830  public function ‪xml2arrayProcessHandlesDocumentTag(string $input, string $docTag): void
3831  {
3832  $expected = [
3833  'data' => [
3834  'settings.persistenceIdentifier' => [
3835  'vDEF' => 'egon',
3836  ],
3837  ],
3838  '_DOCUMENT_TAG' => $docTag,
3839  ];
3840  self::assertSame($expected, ‪GeneralUtility::xml2arrayProcess($input, '', true));
3841  }
3842 
3847  {
3848  return [
3849  '1mb' => [
3850  '<?xml version="1.0" encoding="utf-8" standalone="yes"?>
3851  <T3:T3FlexForms>
3852  <data>
3853  <field index="settings.persistenceIdentifier">
3854  <value index="vDEF">' . str_repeat('1', 1024 * 1024) . '</value>
3855  </field>
3856  </data>
3857  </T3:T3FlexForms>',
3858  str_repeat('1', 1024 * 1024),
3859  ],
3860  '5mb' => [
3861  '<?xml version="1.0" encoding="utf-8" standalone="yes"?>
3862  <T3:T3FlexForms>
3863  <data>
3864  <field index="settings.persistenceIdentifier">
3865  <value index="vDEF">' . str_repeat('1', 5 * 1024 * 1024) . '</value>
3866  </field>
3867  </data>
3868  </T3:T3FlexForms>',
3869  str_repeat('1', 5 * 1024 * 1024),
3870  ],
3871  ];
3872  }
3873 
3878  public function ‪xml2ArrayProcessHandlesBigXmlContent(string $input, string $testValue): void
3879  {
3880  $expected = [
3881  'data' => [
3882  'settings.persistenceIdentifier' => [
3883  'vDEF' => $testValue,
3884  ],
3885  ],
3886  ];
3887  self::assertSame($expected, ‪GeneralUtility::xml2arrayProcess($input));
3888  }
3889 
3894  {
3895  $prefix = '<?xml version="1.0" encoding="utf-8" standalone="yes"?><T3FlexForms><field index="index">';
3896  $suffix = '</field></T3FlexForms>';
3897  return [
3898  'no-type string' => [
3899  $prefix . '<value index="vDEF">foo bar</value>' . $suffix,
3900  'foo bar',
3901  ],
3902  'no-type integer' => [
3903  $prefix . '<value index="vDEF">123</value>' . $suffix,
3904  '123',
3905  ],
3906  'no-type double' => [
3907  $prefix . '<value index="vDEF">1.23</value>' . $suffix,
3908  '1.23',
3909  ],
3910  'integer integer' => [
3911  $prefix . '<value index="vDEF" type="integer">123</value>' . $suffix,
3912  123,
3913  ],
3914  'integer double' => [
3915  $prefix . '<value index="vDEF" type="integer">1.23</value>' . $suffix,
3916  1,
3917  ],
3918  'double integer' => [
3919  $prefix . '<value index="vDEF" type="double">123</value>' . $suffix,
3920  123.0,
3921  ],
3922  'double double' => [
3923  $prefix . '<value index="vDEF" type="double">1.23</value>' . $suffix,
3924  1.23,
3925  ],
3926  'boolean 0' => [
3927  $prefix . '<value index="vDEF" type="boolean">0</value>' . $suffix,
3928  false,
3929  ],
3930  'boolean 1' => [
3931  $prefix . '<value index="vDEF" type="boolean">1</value>' . $suffix,
3932  true,
3933  ],
3934  'boolean true' => [
3935  $prefix . '<value index="vDEF" type="boolean">true</value>' . $suffix,
3936  true,
3937  ],
3938  'boolean false' => [
3939  $prefix . '<value index="vDEF" type="boolean">false</value>' . $suffix,
3940  true, // sic(!)
3941  ],
3942  'NULL' => [
3943  $prefix . '<value index="vDEF" type="NULL"></value>' . $suffix,
3944  null,
3945  ],
3946  'NULL string' => [
3947  $prefix . '<value index="vDEF" type="NULL">foo bar</value>' . $suffix,
3948  null,
3949  ],
3950  'NULL integer' => [
3951  $prefix . '<value index="vDEF" type="NULL">123</value>' . $suffix,
3952  null,
3953  ],
3954  'NULL double' => [
3955  $prefix . '<value index="vDEF" type="NULL">1.23</value>' . $suffix,
3956  null,
3957  ],
3958  'array' => [
3959  $prefix . '<value index="vDEF" type="array"></value>' . $suffix,
3960  [],
3961  ],
3962  ];
3963  }
3964 
3969  public function ‪xml2ArrayProcessHandlesAttributeTypes(string $input, mixed $expected): void
3970  {
3971  $result = ‪GeneralUtility::xml2arrayProcess($input);
3972  self::assertSame($expected, $result['index']['vDEF']);
3973  }
3974 
3975  public function ‪locationHeaderUrlDataProvider(): array
3976  {
3977  return [
3978  'simple relative path' => [
3979  'foo',
3980  'foo.bar.test',
3981  'http://foo.bar.test/foo',
3982  ],
3983  'path beginning with slash' => [
3984  '/foo',
3985  'foo.bar.test',
3986  'http://foo.bar.test/foo',
3987  ],
3988  'path with full domain and https scheme' => [
3989  'https://example.com/foo',
3990  'foo.bar.test',
3991  'https://example.com/foo',
3992  ],
3993  'path with full domain and http scheme' => [
3994  'http://example.com/foo',
3995  'foo.bar.test',
3996  'http://example.com/foo',
3997  ],
3998  'path with full domain and relative scheme' => [
3999  '//example.com/foo',
4000  'foo.bar.test',
4001  '//example.com/foo',
4002  ],
4003  ];
4004  }
4005 
4011  public function ‪locationHeaderUrl(string $path, string $host, string $expected): void
4012  {
4015  true,
4016  false,
4022  ‪Environment::isWindows() ? 'WINDOWS' : 'UNIX'
4023  );
4024  $_SERVER['HTTP_HOST'] = $host;
4025  $_SERVER['SCRIPT_NAME'] = '/index.php';
4026  $result = GeneralUtility::locationHeaderUrl($path);
4027  self::assertSame($expected, $result);
4028  }
4029 
4034  {
4035  ‪$GLOBALS['TYPO3_CONF_VARS']['BE']['versionNumberInFilename'] = true;
4036 
4037  $uniqueFilename = ‪StringUtility::getUniqueId() . 'backend';
4038  $testFileDirectory = ‪Environment::getVarPath() . '/tests/';
4039  $testFilepath = $testFileDirectory . $uniqueFilename . '.css';
4040  $this->testFilesToDelete[] = $testFilepath;
4041  ‪GeneralUtility::mkdir_deep($testFileDirectory);
4042  touch($testFilepath);
4043 
4044  $versionedFilename = GeneralUtility::createVersionNumberedFilename($testFilepath);
4045 
4046  self::assertMatchesRegularExpression('/^.*\/tests\/' . $uniqueFilename . '\.[0-9]+\.css/', $versionedFilename);
4047  }
4048 
4053  {
4056  true,
4057  false,
4062  ‪Environment::getPublicPath() . '/index.php',
4063  ‪Environment::isWindows() ? 'WINDOWS' : 'UNIX'
4064  );
4065  $request = new ‪ServerRequest('https://www.example.com', 'GET');
4066  ‪$GLOBALS['TYPO3_REQUEST'] = $request->withAttribute('applicationType', ‪SystemEnvironmentBuilder::REQUESTTYPE_FE);
4067  $uniqueFilename = ‪StringUtility::getUniqueId('main_');
4068  $testFileDirectory = ‪Environment::getPublicPath() . '/static/';
4069  $testFilepath = $testFileDirectory . $uniqueFilename . '.css';
4070  ‪GeneralUtility::mkdir_deep($testFileDirectory);
4071  touch($testFilepath);
4072 
4073  ‪$GLOBALS['TYPO3_CONF_VARS']['FE']['versionNumberInFilename'] = 'querystring';
4074  $incomingFileName = '/' . ‪PathUtility::stripPathSitePrefix($testFilepath);
4075  $versionedFilename = GeneralUtility::createVersionNumberedFilename($incomingFileName);
4076  self::assertStringContainsString('.css?', $versionedFilename);
4077  self::assertStringStartsWith('/static/main_', $versionedFilename);
4078 
4079  $incomingFileName = ‪PathUtility::stripPathSitePrefix($testFilepath);
4080  $versionedFilename = GeneralUtility::createVersionNumberedFilename($incomingFileName);
4081  self::assertStringContainsString('.css?', $versionedFilename);
4082  self::assertStringStartsWith('static/main_', $versionedFilename);
4083 
4084  ‪GeneralUtility::rmdir($testFileDirectory, true);
4085  }
4086 }
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\resolveBackPathWithDataProvider
‪resolveBackPathWithDataProvider(string $input, string $expectedValue)
Definition: GeneralUtilityTest.php:2979
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\validPathStrInvalidCharactersDataProvider
‪validPathStrInvalidCharactersDataProvider()
Definition: GeneralUtilityTest.php:3401
‪TYPO3\CMS\Core\Utility\GeneralUtility\underscoredToLowerCamelCase
‪static string underscoredToLowerCamelCase($string)
Definition: GeneralUtility.php:741
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\cmpFqdnInvalidDataProvider
‪static array cmpFqdnInvalidDataProvider()
Definition: GeneralUtilityTest.php:444
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\jsonEncodeForHtmlAttributeTestDataProvider
‪static jsonEncodeForHtmlAttributeTestDataProvider()
Definition: GeneralUtilityTest.php:1961
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\xml2arrayProcessHandlesDocumentTag
‪xml2arrayProcessHandlesDocumentTag(string $input, string $docTag)
Definition: GeneralUtilityTest.php:3830
‪TYPO3\CMS\Core\Utility\GeneralUtility\xml2array
‪static mixed xml2array($string, $NSprefix='', $reportDocTag=false)
Definition: GeneralUtility.php:1344
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\makeInstanceWithZeroStringClassNameThrowsException
‪makeInstanceWithZeroStringClassNameThrowsException()
Definition: GeneralUtilityTest.php:3014
‪TYPO3\CMS\Core\Utility\GeneralUtility\validIP
‪static bool validIP($ip)
Definition: GeneralUtility.php:399
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\createVersionNumberedFilenameDoesNotResolveBackpathForAbsolutePath
‪createVersionNumberedFilenameDoesNotResolveBackpathForAbsolutePath()
Definition: GeneralUtilityTest.php:4033
‪TYPO3\CMS\Core\Utility\PathUtility\stripPathSitePrefix
‪static stripPathSitePrefix(string $path)
Definition: PathUtility.php:428
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\makeInstanceResolvesConfiguredImplementationsRecursively
‪makeInstanceResolvesConfiguredImplementationsRecursively()
Definition: GeneralUtilityTest.php:3089
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\getSingletonInstancesContainsPreviouslySetSingletonInstance
‪getSingletonInstancesContainsPreviouslySetSingletonInstance()
Definition: GeneralUtilityTest.php:3190
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\rmdirDoesNotRemoveDirectoryWithFilesAndReturnsFalseIfRecursiveDeletionIsOff
‪rmdirDoesNotRemoveDirectoryWithFilesAndReturnsFalseIfRecursiveDeletionIsOff()
Definition: GeneralUtilityTest.php:2625
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\xml2ArrayProcessHandlesBigXmlContent
‪xml2ArrayProcessHandlesBigXmlContent(string $input, string $testValue)
Definition: GeneralUtilityTest.php:3878
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\underscoredToLowerCamelCase
‪underscoredToLowerCamelCase($expected, $inputString)
Definition: GeneralUtilityTest.php:1281
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\callUserFunctionInvalidParameterDataprovider
‪callUserFunctionInvalidParameterDataprovider()
Definition: GeneralUtilityTest.php:3540
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\validPathStrDataProvider
‪validPathStrDataProvider()
Definition: GeneralUtilityTest.php:3443
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\jsonEncodeForJavaScriptTest
‪jsonEncodeForJavaScriptTest($value, string $expectation)
Definition: GeneralUtilityTest.php:2012
‪TYPO3\CMS\Core\Utility\PathUtility
Definition: PathUtility.php:27
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\cmpIPv6DataProviderNotMatching
‪static array cmpIPv6DataProviderNotMatching()
Definition: GeneralUtilityTest.php:300
‪TYPO3\CMS\Core\Tests\Unit\Utility\Fixtures\GeneralUtilityFilesystemFixture\writeFileToTypo3tempDir
‪static writeFileToTypo3tempDir($filepath, $content)
Definition: GeneralUtilityFilesystemFixture.php:54
‪TYPO3\CMS\Core\Tests\Unit\Utility\Fixtures\GeneralUtilityMakeInstanceInjectLoggerFixture
Definition: GeneralUtilityMakeInstanceInjectLoggerFixture.php:28
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\getFilesInDirReturnsArrayWithMd5OfElementAndPathAsArrayKey
‪getFilesInDirReturnsArrayWithMd5OfElementAndPathAsArrayKey()
Definition: GeneralUtilityTest.php:2828
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\implodeArrayForUrlCanSkipEmptyParameters
‪implodeArrayForUrlCanSkipEmptyParameters()
Definition: GeneralUtilityTest.php:802
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\sanitizeLocalUrlAcceptsNotEncodedValidPaths
‪sanitizeLocalUrlAcceptsNotEncodedValidPaths(string $path)
Definition: GeneralUtilityTest.php:1444
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\explodeUrl2ArrayTransformsParameterStringToFlatArrayDataProvider
‪explodeUrl2ArrayTransformsParameterStringToFlatArrayDataProvider()
Definition: GeneralUtilityTest.php:819
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\makeInstanceWithBeginningSlashInClassNameThrowsException
‪makeInstanceWithBeginningSlashInClassNameThrowsException()
Definition: GeneralUtilityTest.php:3050
‪TYPO3\CMS\Core\Tests\Unit\Utility\Fixtures\GeneralUtilityFixture\resetFinalClassNameCache
‪static resetFinalClassNameCache()
Definition: GeneralUtilityFixture.php:30
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\getFileAbsFileNameDataProvider
‪getFileAbsFileNameDataProvider()
Definition: GeneralUtilityTest.php:3329
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\underscoredToLowerCamelCaseDataProvider
‪array underscoredToLowerCamelCaseDataProvider()
Definition: GeneralUtilityTest.php:1269
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\copyDirectoryCopiesFilesAndDirectoriesWithRelativePaths
‪copyDirectoryCopiesFilesAndDirectoriesWithRelativePaths()
Definition: GeneralUtilityTest.php:3471
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\validIpReturnsTrueForValidIp
‪validIpReturnsTrueForValidIp($ip)
Definition: GeneralUtilityTest.php:374
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\array2xmlConvertsEmptyArraysToElementWithoutContent
‪array2xmlConvertsEmptyArraysToElementWithoutContent()
Definition: GeneralUtilityTest.php:3629
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\cmpFqdnReturnsTrue
‪cmpFqdnReturnsTrue($baseHost, $list)
Definition: GeneralUtilityTest.php:434
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\invalidIpDataProvider
‪static array invalidIpDataProvider()
Definition: GeneralUtilityTest.php:384
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\hmacReturnsEqualHashesForEqualInput
‪hmacReturnsEqualHashesForEqualInput()
Definition: GeneralUtilityTest.php:1883
‪TYPO3\CMS\Core\Tests\Unit\Utility\Fixtures\GeneralUtilityFixture
Definition: GeneralUtilityFixture.php:26
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\mkdirCreatesHiddenDirectory
‪mkdirCreatesHiddenDirectory()
Definition: GeneralUtilityTest.php:2283
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\hmacReturnsNoEqualHashesForNonEqualInput
‪hmacReturnsNoEqualHashesForNonEqualInput()
Definition: GeneralUtilityTest.php:1893
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\NO_FIX_PERMISSIONS_ON_WINDOWS
‪const NO_FIX_PERMISSIONS_ON_WINDOWS
Definition: GeneralUtilityTest.php:47
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\makeInstanceWithEmptyArrayThrowsException
‪makeInstanceWithEmptyArrayThrowsException()
Definition: GeneralUtilityTest.php:3026
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\validEmailValidDataProvider
‪array validEmailValidDataProvider()
Definition: GeneralUtilityTest.php:657
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\htmlspecialcharsDecodeReturnsDecodedString
‪htmlspecialcharsDecodeReturnsDecodedString()
Definition: GeneralUtilityTest.php:641
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\rmdirRemovesDirectoriesRecursiveAndReturnsTrue
‪rmdirRemovesDirectoriesRecursiveAndReturnsTrue()
Definition: GeneralUtilityTest.php:2640
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\locationHeaderUrl
‪locationHeaderUrl(string $path, string $host, string $expected)
Definition: GeneralUtilityTest.php:4011
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\getAllFilesAndFoldersInPathReturnsArrayWithMd5Keys
‪getAllFilesAndFoldersInPathReturnsArrayWithMd5Keys()
Definition: GeneralUtilityTest.php:3608
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\mkdirDeepCreatesDirectoryWithDoubleSlashes
‪mkdirDeepCreatesDirectoryWithDoubleSlashes($directoryToCreate)
Definition: GeneralUtilityTest.php:2476
‪TYPO3\CMS\Core\Tests\Unit\Utility\Fixtures\SingletonClassFixture
Definition: SingletonClassFixture.php:26
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\fixPermissionsSetsGroup
‪fixPermissionsSetsGroup()
Definition: GeneralUtilityTest.php:2024
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\implodeArrayForUrlBuildsValidParameterString
‪implodeArrayForUrlBuildsValidParameterString($name, $input, $expected)
Definition: GeneralUtilityTest.php:794
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\gpDataProvider
‪gpDataProvider()
Definition: GeneralUtilityTest.php:117
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\setSingletonInstanceMakesMakeInstanceReturnThatInstance
‪setSingletonInstanceMakesMakeInstanceReturnThatInstance()
Definition: GeneralUtilityTest.php:3166
‪TYPO3\CMS\Core\Core\SystemEnvironmentBuilder
Definition: SystemEnvironmentBuilder.php:41
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\sanitizeLocalUrlValidUrlsDataProvider
‪array sanitizeLocalUrlValidUrlsDataProvider()
Definition: GeneralUtilityTest.php:1485
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\rmdirRemovesFile
‪rmdirRemovesFile()
Definition: GeneralUtilityTest.php:2570
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\validEmailInvalidDataProvider
‪array validEmailInvalidDataProvider()
Definition: GeneralUtilityTest.php:693
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\makeInstanceInjectsLogger
‪makeInstanceInjectsLogger()
Definition: GeneralUtilityTest.php:3129
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\writeFileToTypo3tempDirFailsWithInvalidPath
‪writeFileToTypo3tempDirFailsWithInvalidPath(string $invalidFilePath, string $expectedResult, string $pathToCleanUp)
Definition: GeneralUtilityTest.php:2377
‪TYPO3\CMS\Core\Utility\GeneralUtility\_POST
‪static mixed _POST($var=null)
Definition: GeneralUtility.php:165
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\copyDirectoryCopiesFilesAndDirectoriesWithAbsolutePaths
‪copyDirectoryCopiesFilesAndDirectoriesWithAbsolutePaths()
Definition: GeneralUtilityTest.php:3495
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\callUserFunctionCanCallMethod
‪callUserFunctionCanCallMethod()
Definition: GeneralUtilityTest.php:3570
‪TYPO3\CMS\Core\Core\Environment\getPublicPath
‪static getPublicPath()
Definition: Environment.php:187
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\getDirsReturnsStringErrorOnPathFailure
‪getDirsReturnsStringErrorOnPathFailure()
Definition: GeneralUtilityTest.php:1859
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\createVersionNumberedFilenameKeepsInvalidAbsolutePathInFrontendAndAddsQueryString
‪createVersionNumberedFilenameKeepsInvalidAbsolutePathInFrontendAndAddsQueryString()
Definition: GeneralUtilityTest.php:4052
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\unlink_tempfileRemovesValidFileInTypo3temp
‪unlink_tempfileRemovesValidFileInTypo3temp()
Definition: GeneralUtilityTest.php:1634
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\addInstanceMakesMakeInstanceReturnThatInstance
‪addInstanceMakesMakeInstanceReturnThatInstance()
Definition: GeneralUtilityTest.php:3284
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\callUserFunctionWillThrowExceptionForInvalidParameters
‪callUserFunctionWillThrowExceptionForInvalidParameters(string $functionName, int $expectedException)
Definition: GeneralUtilityTest.php:3527
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\expandListExpandsIntegerRangesDataProvider
‪expandListExpandsIntegerRangesDataProvider()
Definition: GeneralUtilityTest.php:522
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\xml2arrayUsesCache
‪xml2arrayUsesCache()
Definition: GeneralUtilityTest.php:3645
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\getFilesInDirByExtensionDoesNotFindFilesWithOtherExtensions
‪getFilesInDirByExtensionDoesNotFindFilesWithOtherExtensions()
Definition: GeneralUtilityTest.php:2781
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\getFilesInDirDoesSortAlphabeticallyByDefault
‪getFilesInDirDoesSortAlphabeticallyByDefault()
Definition: GeneralUtilityTest.php:2816
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\sanitizeLocalUrlDeniesPlainInvalidUrlsInBackendContext
‪sanitizeLocalUrlDeniesPlainInvalidUrlsInBackendContext(string $url)
Definition: GeneralUtilityTest.php:1578
‪TYPO3\CMS\Core\Tests\Unit\Utility\Fixtures\ExtendedSingletonClassFixture
Definition: ExtendedSingletonClassFixture.php:24
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\fixPermissionsSetsPermissionsToHiddenFile
‪fixPermissionsSetsPermissionsToHiddenFile()
Definition: GeneralUtilityTest.php:2063
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\makeInstanceCalledTwoTimesForSingletonClassReturnsSameInstance
‪makeInstanceCalledTwoTimesForSingletonClassReturnsSameInstance()
Definition: GeneralUtilityTest.php:3109
‪TYPO3\CMS\Core\Utility\GeneralUtility\_GP
‪static mixed _GP($var)
Definition: GeneralUtility.php:106
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\explodeUrl2ArrayTransformsParameterStringToFlatArray
‪explodeUrl2ArrayTransformsParameterStringToFlatArray(string $input, array $expected)
Definition: GeneralUtilityTest.php:836
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\sanitizeLocalUrlInvalidDataProvider
‪array sanitizeLocalUrlInvalidDataProvider()
Definition: GeneralUtilityTest.php:1560
‪TYPO3\CMS\Core\Tests\Unit\Utility
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\quoteJsValueTest
‪quoteJsValueTest(string $input, string $expected)
Definition: GeneralUtilityTest.php:1956
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\canRetrieveGlobalInputsThroughPost
‪canRetrieveGlobalInputsThroughPost($key, $post, $expected)
Definition: GeneralUtilityTest.php:198
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\rmdirRemovesDirectoryWithTrailingSlash
‪rmdirRemovesDirectoryWithTrailingSlash()
Definition: GeneralUtilityTest.php:2614
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\splitFileRefReturnsFileTypeForFilesWithoutPathSite
‪splitFileRefReturnsFileTypeForFilesWithoutPathSite()
Definition: GeneralUtilityTest.php:2891
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\camelCaseToLowerCaseUnderscored
‪camelCaseToLowerCaseUnderscored($expected, $inputString)
Definition: GeneralUtilityTest.php:1308
‪TYPO3\CMS\Core\Tests\Unit\Utility\Fixtures\GeneralUtilityFilesystemFixture
Definition: GeneralUtilityFilesystemFixture.php:26
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\getIndpEnvTypo3HostOnlyParsesHostnamesAndIpAddresses
‪getIndpEnvTypo3HostOnlyParsesHostnamesAndIpAddresses($httpHost, $expectedIp)
Definition: GeneralUtilityTest.php:1220
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\makeInstanceWithEmptyClassNameThrowsException
‪makeInstanceWithEmptyClassNameThrowsException()
Definition: GeneralUtilityTest.php:2990
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\jsonEncodeForHtmlAttributeTest
‪jsonEncodeForHtmlAttributeTest($value, bool $useHtmlEntities, string $expectation)
Definition: GeneralUtilityTest.php:1988
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\callUserFunctionTrimsSpaces
‪callUserFunctionTrimsSpaces()
Definition: GeneralUtilityTest.php:3598
‪TYPO3\CMS\Core\Core\Environment\getCurrentScript
‪static getCurrentScript()
Definition: Environment.php:220
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\fixPermissionsSetsDefaultPermissionsToFile
‪fixPermissionsSetsDefaultPermissionsToFile()
Definition: GeneralUtilityTest.php:2232
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\isConnected
‪bool isConnected()
Definition: GeneralUtilityTest.php:76
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\sanitizeLocalUrlAcceptsNotEncodedValidUrls
‪sanitizeLocalUrlAcceptsNotEncodedValidUrls(string $url, string $host, string $subDirectory)
Definition: GeneralUtilityTest.php:1515
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\trimExplodeReturnsCorrectResult
‪trimExplodeReturnsCorrectResult(string $delimiter, string $testString, bool $removeEmpty, int $limit, array $expectedResult)
Definition: GeneralUtilityTest.php:935
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\getFileAbsFileNameReturnsCorrectValues
‪getFileAbsFileNameReturnsCorrectValues(string $path, string $expected)
Definition: GeneralUtilityTest.php:3367
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\cmpIPv4DataProviderMatching
‪static array cmpIPv4DataProviderMatching()
Definition: GeneralUtilityTest.php:212
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\callUserFunctionAcceptsClosures
‪callUserFunctionAcceptsClosures()
Definition: GeneralUtilityTest.php:3585
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\makeInstancePassesParametersToConstructor
‪makeInstancePassesParametersToConstructor()
Definition: GeneralUtilityTest.php:3069
‪TYPO3\CMS\Core\Utility\GeneralUtility\camelCaseToLowerCaseUnderscored
‪static string camelCaseToLowerCaseUnderscored($string)
Definition: GeneralUtility.php:753
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\xml2arrayProcessHandlesWhitespacesDataProvider
‪string[][] xml2arrayProcessHandlesWhitespacesDataProvider()
Definition: GeneralUtilityTest.php:3660
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\normalizeCompressIPv6DataProviderCorrect
‪static array normalizeCompressIPv6DataProviderCorrect()
Definition: GeneralUtilityTest.php:331
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\inListForItemContainedReturnsTrueDataProvider
‪inListForItemContainedReturnsTrueDataProvider()
Definition: GeneralUtilityTest.php:476
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\mkdirDeepDoesNotChangePermissionsOfExistingSubDirectories
‪mkdirDeepDoesNotChangePermissionsOfExistingSubDirectories()
Definition: GeneralUtilityTest.php:2525
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\xml2arrayProcessHandlesDocumentTagDataProvider
‪array[] xml2arrayProcessHandlesDocumentTagDataProvider()
Definition: GeneralUtilityTest.php:3787
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\mkdirCreatesDirectory
‪mkdirCreatesDirectory()
Definition: GeneralUtilityTest.php:2271
‪TYPO3\CMS\Core\Core\Environment\getVarPath
‪static getVarPath()
Definition: Environment.php:197
‪TYPO3\CMS\Core\Utility\GeneralUtility\normalizeIPv6
‪static string normalizeIPv6($address)
Definition: GeneralUtility.php:335
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\normalizeIPv6CorrectlyNormalizesAddresses
‪normalizeIPv6CorrectlyNormalizesAddresses($compressed, $normalized)
Definition: GeneralUtilityTest.php:347
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\user_calledUserFunction
‪user_calledUserFunction()
Definition: GeneralUtilityTest.php:3577
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\mkdirDeepThrowsExceptionIfBaseDirectoryIsNotOfTypeString
‪mkdirDeepThrowsExceptionIfBaseDirectoryIsNotOfTypeString()
Definition: GeneralUtilityTest.php:2554
‪TYPO3\CMS\Core\Core\Environment\getBackendPath
‪static getBackendPath()
Definition: Environment.php:245
‪TYPO3\CMS\Core\Core\Environment\getLegacyConfigPath
‪static getLegacyConfigPath()
Definition: Environment.php:277
‪TYPO3\CMS\Core\Tests\Unit\Utility\Fixtures\TwoParametersConstructorFixture
Definition: TwoParametersConstructorFixture.php:24
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\rmdirRemovesDirectory
‪rmdirRemovesDirectory()
Definition: GeneralUtilityTest.php:2603
‪TYPO3\CMS\Core\Tests\Unit\Utility\Fixtures\ReplacementClassFixture
Definition: ReplacementClassFixture.php:24
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\hostnameAndPortDataProvider
‪static hostnameAndPortDataProvider()
Definition: GeneralUtilityTest.php:1202
‪TYPO3\CMS\Core\Utility\GeneralUtility\implodeArrayForUrl
‪static string implodeArrayForUrl($name, array $theArray, $str='', $skipBlank=false, $rawurlencodeParamName=false)
Definition: GeneralUtility.php:936
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\xml2ArrayProcessHandlesAttributeTypes
‪xml2ArrayProcessHandlesAttributeTypes(string $input, mixed $expected)
Definition: GeneralUtilityTest.php:3969
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\inListForItemNotContainedReturnsFalse
‪inListForItemNotContainedReturnsFalse(string $haystack)
Definition: GeneralUtilityTest.php:490
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\addInstanceForClassThatIsNoSubclassOfProvidedClassThrowsException
‪addInstanceForClassThatIsNoSubclassOfProvidedClassThrowsException()
Definition: GeneralUtilityTest.php:3257
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\fixPermissionsDoesNotSetPermissionsToNotAllowedPath
‪fixPermissionsDoesNotSetPermissionsToNotAllowedPath()
Definition: GeneralUtilityTest.php:2196
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\mkdirDeepFixesPermissionsOfCreatedDirectory
‪mkdirDeepFixesPermissionsOfCreatedDirectory()
Definition: GeneralUtilityTest.php:2488
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\validEmailReturnsTrueForValidMailAddress
‪validEmailReturnsTrueForValidMailAddress($address)
Definition: GeneralUtilityTest.php:683
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\getAndPostDataProvider
‪getAndPostDataProvider()
Definition: GeneralUtilityTest.php:174
‪TYPO3\CMS\Core\Core\Environment\getConfigPath
‪static getConfigPath()
Definition: Environment.php:212
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\getFilesInDirCreateTestDirectory
‪string getFilesInDirCreateTestDirectory()
Definition: GeneralUtilityTest.php:2703
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\formatSizeDataProvider
‪formatSizeDataProvider()
Definition: GeneralUtilityTest.php:561
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\sanitizeLocalUrlDeniesPlainInvalidUrlsInFrontendContext
‪sanitizeLocalUrlDeniesPlainInvalidUrlsInFrontendContext(string $url)
Definition: GeneralUtilityTest.php:1600
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\getIndpEnvTypo3PortParsesHostnamesAndIpAddresses
‪getIndpEnvTypo3PortParsesHostnamesAndIpAddresses($httpHost, $dummy, $expectedPort)
Definition: GeneralUtilityTest.php:1230
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\unlink_tempfileRemovesHiddenFile
‪unlink_tempfileRemovesHiddenFile()
Definition: GeneralUtilityTest.php:1647
‪TYPO3\CMS\Core\Utility\GeneralUtility\get_dirs
‪static string[] string null get_dirs($path)
Definition: GeneralUtility.php:1844
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\getFilesInDirDoesNotFindDirectories
‪getFilesInDirDoesNotFindDirectories()
Definition: GeneralUtilityTest.php:2840
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\makeInstanceCalledTwoTimesForSingletonClassWithPurgeInstancesInbetweenReturnsDifferentInstances
‪makeInstanceCalledTwoTimesForSingletonClassWithPurgeInstancesInbetweenReturnsDifferentInstances()
Definition: GeneralUtilityTest.php:3118
‪TYPO3\CMS\Core\Utility\ExtensionManagementUtility
Definition: ExtensionManagementUtility.php:40
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\fixPermissionsSetsPermissionsToHiddenDirectory
‪fixPermissionsSetsPermissionsToHiddenDirectory()
Definition: GeneralUtilityTest.php:2124
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\setUp
‪setUp()
Definition: GeneralUtilityTest.php:55
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\makeInstanceWithNullClassNameThrowsException
‪makeInstanceWithNullClassNameThrowsException()
Definition: GeneralUtilityTest.php:3002
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\getFilesInDirDoesNotFindDotfiles
‪getFilesInDirDoesNotFindDotfiles()
Definition: GeneralUtilityTest.php:2855
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\intExplodeDataProvider
‪intExplodeDataProvider()
Definition: GeneralUtilityTest.php:738
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\setSingletonInstanceForClassThatIsNoSubclassOfProvidedClassThrowsException
‪setSingletonInstanceForClassThatIsNoSubclassOfProvidedClassThrowsException()
Definition: GeneralUtilityTest.php:3151
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\implodeArrayForUrlCanUrlEncodeKeyNames
‪implodeArrayForUrlCanUrlEncodeKeyNames()
Definition: GeneralUtilityTest.php:812
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\mkdirDeepFixesPermissionsOnNewParentDirectory
‪mkdirDeepFixesPermissionsOnNewParentDirectory()
Definition: GeneralUtilityTest.php:2506
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\$resetSingletonInstances
‪bool $resetSingletonInstances
Definition: GeneralUtilityTest.php:49
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\xml2ArrayProcessHandlesBigXmlContentDataProvider
‪array[] xml2ArrayProcessHandlesBigXmlContentDataProvider()
Definition: GeneralUtilityTest.php:3846
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\fixPermissionsSetsDefaultPermissionsToDirectory
‪fixPermissionsSetsDefaultPermissionsToDirectory()
Definition: GeneralUtilityTest.php:2250
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\inListForItemNotContainedReturnsFalseDataProvider
‪inListForItemNotContainedReturnsFalseDataProvider()
Definition: GeneralUtilityTest.php:498
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\cmpFqdnValidDataProvider
‪static array cmpFqdnValidDataProvider()
Definition: GeneralUtilityTest.php:414
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\trimExplodeReturnsCorrectResultDataProvider
‪trimExplodeReturnsCorrectResultDataProvider()
Definition: GeneralUtilityTest.php:940
‪TYPO3\CMS\Core\Utility\GeneralUtility\cmpFQDN
‪static bool cmpFQDN($baseHost, $list)
Definition: GeneralUtility.php:437
‪TYPO3\CMS\Core\Core\Environment\getProjectPath
‪static string getProjectPath()
Definition: Environment.php:160
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest
Definition: GeneralUtilityTest.php:46
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\validURLReturnsTrueForValidResource
‪validURLReturnsTrueForValidResource($url)
Definition: GeneralUtilityTest.php:1350
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\mkdirDeepCreatesDirectoryWithAndWithoutDoubleSlashesDataProvider
‪mkdirDeepCreatesDirectoryWithAndWithoutDoubleSlashesDataProvider()
Definition: GeneralUtilityTest.php:2464
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\tearDown
‪tearDown()
Definition: GeneralUtilityTest.php:61
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\fixPermissionsCorrectlySetsPermissionsRecursive
‪fixPermissionsCorrectlySetsPermissionsRecursive()
Definition: GeneralUtilityTest.php:2145
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\fixPermissionsSetsPermissionsWithRelativeFileReference
‪fixPermissionsSetsPermissionsWithRelativeFileReference()
Definition: GeneralUtilityTest.php:2212
‪TYPO3\CMS\Core\Utility\GeneralUtility\fixPermissions
‪static mixed fixPermissions($path, $recursive=false)
Definition: GeneralUtility.php:1575
‪TYPO3\CMS\Core\Utility\ExtensionManagementUtility\setPackageManager
‪static setPackageManager(PackageManager $packageManager)
Definition: ExtensionManagementUtility.php:61
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\xml2arrayProcessHandlesTagNamespacesDataProvider
‪string[][] xml2arrayProcessHandlesTagNamespacesDataProvider()
Definition: GeneralUtilityTest.php:3732
‪TYPO3\CMS\Core\Utility\GeneralUtility\mkdir_deep
‪static mkdir_deep($directory)
Definition: GeneralUtility.php:1734
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\validIpReturnsFalseForInvalidIp
‪validIpReturnsFalseForInvalidIp($ip)
Definition: GeneralUtilityTest.php:401
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\getBytesFromSizeMeasurementCalculatesCorrectByteValue
‪getBytesFromSizeMeasurementCalculatesCorrectByteValue($expected, $byteString)
Definition: GeneralUtilityTest.php:1177
‪TYPO3\CMS\Core\Utility\GeneralUtility\expandList
‪static string expandList($list)
Definition: GeneralUtility.php:530
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\sanitizeLocalUrlDeniesEncodedInvalidUrls
‪sanitizeLocalUrlDeniesEncodedInvalidUrls($url)
Definition: GeneralUtilityTest.php:1622
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\writeFileToTypo3tempDirWorksWithValidPath
‪writeFileToTypo3tempDirWorksWithValidPath(string $filePath, string $pathToCleanUp)
Definition: GeneralUtilityTest.php:2422
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\tempnamReturnsPathStartingWithGivenPrefix
‪tempnamReturnsPathStartingWithGivenPrefix()
Definition: GeneralUtilityTest.php:1694
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\underscoredToUpperCamelCaseDataProvider
‪array underscoredToUpperCamelCaseDataProvider()
Definition: GeneralUtilityTest.php:1244
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\makeInstanceWithNonEmptyArrayThrowsException
‪makeInstanceWithNonEmptyArrayThrowsException()
Definition: GeneralUtilityTest.php:3038
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\rmdirRemovesDeadLinkToDirectory
‪rmdirRemovesDeadLinkToDirectory()
Definition: GeneralUtilityTest.php:2667
‪TYPO3\CMS\Core\Package\Package
Definition: Package.php:28
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\validFilePathForTypo3tempDirDataProvider
‪validFilePathForTypo3tempDirDataProvider()
Definition: GeneralUtilityTest.php:2390
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\validPathStrDetectsInvalidCharacters
‪validPathStrDetectsInvalidCharacters(string $path)
Definition: GeneralUtilityTest.php:3435
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\getTestDirectory
‪getTestDirectory(string $prefix='root_')
Definition: GeneralUtilityTest.php:91
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\unlink_tempfileReturnsTrueIfFileWasRemoved
‪unlink_tempfileReturnsTrueIfFileWasRemoved()
Definition: GeneralUtilityTest.php:1660
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\removeDotsFromTypoScriptSucceedsWithDottedArray
‪removeDotsFromTypoScriptSucceedsWithDottedArray()
Definition: GeneralUtilityTest.php:1728
‪TYPO3\CMS\Core\Utility\GeneralUtility\_GET
‪static mixed _GET($var=null)
Definition: GeneralUtility.php:145
‪TYPO3\CMS\Core\Utility\GeneralUtility\hmac
‪static string hmac($input, $additionalSecret='')
Definition: GeneralUtility.php:570
‪TYPO3\CMS\Core\Cache\CacheManager
Definition: CacheManager.php:36
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\sanitizeLocalUrlValidPathsDataProvider
‪array sanitizeLocalUrlValidPathsDataProvider()
Definition: GeneralUtilityTest.php:1427
‪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:100
‪TYPO3\CMS\Core\Utility\GeneralUtility\cmpIPv6
‪static bool cmpIPv6($baseIP, $list)
Definition: GeneralUtility.php:280
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\validIpDataProvider
‪static array validIpDataProvider()
Definition: GeneralUtilityTest.php:360
‪TYPO3\CMS\Core\Http\ServerRequest
Definition: ServerRequest.php:37
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\mkdirCreatesDirectoryWithTrailingSlash
‪mkdirCreatesDirectoryWithTrailingSlash()
Definition: GeneralUtilityTest.php:2295
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\tempnamReturnsAbsolutePathInVarPath
‪tempnamReturnsAbsolutePathInVarPath()
Definition: GeneralUtilityTest.php:1715
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\unlink_tempfileReturnsNullIfFileDoesNotExist
‪unlink_tempfileReturnsNullIfFileDoesNotExist()
Definition: GeneralUtilityTest.php:1672
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\validEmailReturnsFalseForInvalidMailAddress
‪validEmailReturnsFalseForInvalidMailAddress($address)
Definition: GeneralUtilityTest.php:729
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\sanitizeLocalUrlAcceptsEncodedValidUrls
‪sanitizeLocalUrlAcceptsEncodedValidUrls(string $url, string $host, string $subDirectory)
Definition: GeneralUtilityTest.php:1537
‪TYPO3\CMS\Core\Utility\GeneralUtility\xml2arrayProcess
‪static mixed xml2arrayProcess($string, $NSprefix='', $reportDocTag=false)
Definition: GeneralUtility.php:1367
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\callUserFunctionCanCallFunction
‪callUserFunctionCanCallFunction()
Definition: GeneralUtilityTest.php:3558
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\makeInstanceInstanciatesConfiguredImplementation
‪makeInstanceInstanciatesConfiguredImplementation()
Definition: GeneralUtilityTest.php:3079
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\rmdirReturnTrueIfFileWasRemoved
‪rmdirReturnTrueIfFileWasRemoved()
Definition: GeneralUtilityTest.php:2584
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\fileExtensionDataProvider
‪fileExtensionDataProvider()
Definition: GeneralUtilityTest.php:2746
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\canRetrieveValueWithGP
‪canRetrieveValueWithGP($key, $get, $post, $expected)
Definition: GeneralUtilityTest.php:106
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\mkdirSetsPermissionsOfCreatedDirectory
‪mkdirSetsPermissionsOfCreatedDirectory()
Definition: GeneralUtilityTest.php:2307
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\setSingletonInstanceReturnsFinalClassNameWithOverriddenClass
‪setSingletonInstanceReturnsFinalClassNameWithOverriddenClass()
Definition: GeneralUtilityTest.php:3203
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\mkdirDeepCreatesDirectory
‪mkdirDeepCreatesDirectory()
Definition: GeneralUtilityTest.php:2443
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\underscoredToUpperCamelCase
‪underscoredToUpperCamelCase($expected, $inputString)
Definition: GeneralUtilityTest.php:1256
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\getFilesInDirCanPrependPath
‪getFilesInDirCanPrependPath()
Definition: GeneralUtilityTest.php:2804
‪TYPO3\CMS\Core\Tests\Unit\Utility\AccessibleProxies\ExtensionManagementUtilityAccessibleProxy\getPackageManager
‪static getPackageManager()
Definition: ExtensionManagementUtilityAccessibleProxy.php:35
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\isOnCurrentHostReturnsTrueWithCurrentHost
‪isOnCurrentHostReturnsTrueWithCurrentHost()
Definition: GeneralUtilityTest.php:1396
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\inListForItemContainedReturnsTrue
‪inListForItemContainedReturnsTrue(string $haystack)
Definition: GeneralUtilityTest.php:468
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\cmpIPv6DataProviderMatching
‪static array cmpIPv6DataProviderMatching()
Definition: GeneralUtilityTest.php:270
‪TYPO3\CMS\Core\Utility\GeneralUtility\trimExplode
‪static string[] trimExplode($delim, $string, $removeEmptyValues=false, $limit=0)
Definition: GeneralUtility.php:898
‪TYPO3\CMS\Core\Tests\Unit\Utility\Fixtures\OriginalClassFixture
Definition: OriginalClassFixture.php:24
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\mkdirDeepCreatesSubdirectoriesRecursive
‪mkdirDeepCreatesSubdirectoriesRecursive()
Definition: GeneralUtilityTest.php:2453
‪$output
‪$output
Definition: annotationChecker.php:117
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\jsonEncodeForJavaScriptTestDataProvider
‪static jsonEncodeForJavaScriptTestDataProvider()
Definition: GeneralUtilityTest.php:1993
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\purgeInstancesDropsAddedInstance
‪purgeInstancesDropsAddedInstance()
Definition: GeneralUtilityTest.php:3320
‪TYPO3\CMS\Core\Utility\GeneralUtility\isValidUrl
‪static bool isValidUrl($url)
Definition: GeneralUtility.php:783
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\xml2arrayProcessHandlesTagNamespaces
‪xml2arrayProcessHandlesTagNamespaces(string $input)
Definition: GeneralUtilityTest.php:3772
‪TYPO3\CMS\Core\Cache\Frontend\FrontendInterface
Definition: FrontendInterface.php:22
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\mkdirDeepThrowsExceptionIfDirectoryCreationFails
‪mkdirDeepThrowsExceptionIfDirectoryCreationFails()
Definition: GeneralUtilityTest.php:2543
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\cmpIPv4DataProviderNotMatching
‪static array cmpIPv4DataProviderNotMatching()
Definition: GeneralUtilityTest.php:241
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\getIndpEnvTypo3SitePathReturnNonEmptyString
‪getIndpEnvTypo3SitePathReturnNonEmptyString()
Definition: GeneralUtilityTest.php:1188
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\validPathStrWorksWithUnicodeFileNames
‪validPathStrWorksWithUnicodeFileNames($path)
Definition: GeneralUtilityTest.php:3459
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\validURLReturnsFalseForInvalidResource
‪validURLReturnsFalseForInvalidResource($url)
Definition: GeneralUtilityTest.php:1385
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\cmpFqdnReturnsFalse
‪cmpFqdnReturnsFalse($baseHost, $list)
Definition: GeneralUtilityTest.php:456
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\revExplodeDataProvider
‪revExplodeDataProvider()
Definition: GeneralUtilityTest.php:841
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\cmpIPv4ReturnsTrueForMatchingAddress
‪cmpIPv4ReturnsTrueForMatchingAddress($ip, $list)
Definition: GeneralUtilityTest.php:231
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\hmacReturnsHashOfProperLength
‪hmacReturnsHashOfProperLength()
Definition: GeneralUtilityTest.php:1873
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\removeDotsFromTypoScriptOverridesWithScalar
‪removeDotsFromTypoScriptOverridesWithScalar()
Definition: GeneralUtilityTest.php:1822
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\getDirsReturnsArrayOfDirectoriesFromGivenDirectory
‪getDirsReturnsArrayOfDirectoriesFromGivenDirectory()
Definition: GeneralUtilityTest.php:1850
‪TYPO3\CMS\Core\SingletonInterface
Definition: SingletonInterface.php:23
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\gpMergedDataProvider
‪gpMergedDataProvider()
Definition: GeneralUtilityTest.php:152
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:25
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\camelCaseToLowerCaseUnderscoredDataProvider
‪array camelCaseToLowerCaseUnderscoredDataProvider()
Definition: GeneralUtilityTest.php:1294
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\fixPermissionsSetsPermissionsToDirectory
‪fixPermissionsSetsPermissionsToDirectory()
Definition: GeneralUtilityTest.php:2083
‪TYPO3\CMS\Core\Utility\GeneralUtility\revExplode
‪static string[] revExplode($delimiter, $string, $count=0)
Definition: GeneralUtility.php:864
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\getFilesInDirByExtensionFindsFiles
‪getFilesInDirByExtensionFindsFiles($fileExtensions)
Definition: GeneralUtilityTest.php:2768
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\revExplodeCorrectlyExplodesStringForGivenPartsCount
‪revExplodeCorrectlyExplodesStringForGivenPartsCount($delimiter, $testString, $count, $expectedArray)
Definition: GeneralUtilityTest.php:911
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\resolveBackPathDataProvider
‪array array[] resolveBackPathDataProvider()
Definition: GeneralUtilityTest.php:2940
‪TYPO3\CMS\Core\Core\Environment
Definition: Environment.php:41
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\cmpIPv6ReturnsFalseForNotMatchingAddress
‪cmpIPv6ReturnsFalseForNotMatchingAddress($ip, $list)
Definition: GeneralUtilityTest.php:318
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\validUrlValidResourceDataProvider
‪array validUrlValidResourceDataProvider()
Definition: GeneralUtilityTest.php:1321
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\sanitizeLocalUrlAcceptsEncodedValidPaths
‪sanitizeLocalUrlAcceptsEncodedValidPaths(string $path)
Definition: GeneralUtilityTest.php:1464
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\splitCalcDataProvider
‪array splitCalcDataProvider()
Definition: GeneralUtilityTest.php:608
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\getFilesInDirExcludesFilesMatchingPattern
‪getFilesInDirExcludesFilesMatchingPattern()
Definition: GeneralUtilityTest.php:2793
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\checkisOnCurrentHostInvalidHosts
‪array checkisOnCurrentHostInvalidHosts()
Definition: GeneralUtilityTest.php:1407
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\setSingletonInstanceCalledTwoTimesMakesMakeInstanceReturnLastSetInstance
‪setSingletonInstanceCalledTwoTimesMakesMakeInstanceReturnLastSetInstance()
Definition: GeneralUtilityTest.php:3177
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\resetSingletonInstancesResetsPreviouslySetInstance
‪resetSingletonInstancesResetsPreviouslySetInstance()
Definition: GeneralUtilityTest.php:3217
‪TYPO3\CMS\Core\Utility\GeneralUtility\intExplode
‪static int[] intExplode($delimiter, $string, $removeEmptyValues=false, $limit=0)
Definition: GeneralUtility.php:827
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\resetSingletonInstancesSetsGivenInstance
‪resetSingletonInstancesSetsGivenInstance()
Definition: GeneralUtilityTest.php:3230
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\isValidUrlInvalidResourceDataProvider
‪array isValidUrlInvalidResourceDataProvider()
Definition: GeneralUtilityTest.php:1360
‪TYPO3\CMS\Core\Utility\GeneralUtility\cmpIPv4
‪static bool cmpIPv4($baseIP, $list)
Definition: GeneralUtility.php:231
‪TYPO3\CMS\Core\Utility\GeneralUtility\rmdir
‪static bool rmdir($path, $removeNonEmpty=false)
Definition: GeneralUtility.php:1787
‪TYPO3\CMS\Core\Utility\GeneralUtility\_GPmerged
‪static array _GPmerged($parameter)
Definition: GeneralUtility.php:127
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\makeInstanceCalledTwoTimesAfterAddInstanceReturnTwoDifferentInstances
‪makeInstanceCalledTwoTimesAfterAddInstanceReturnTwoDifferentInstances()
Definition: GeneralUtilityTest.php:3295
‪TYPO3\CMS\Core\Tests\Unit\Utility\Fixtures\OtherReplacementClassFixture
Definition: OtherReplacementClassFixture.php:24
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\removeDotsFromTypoScriptOverridesSubArray
‪removeDotsFromTypoScriptOverridesSubArray()
Definition: GeneralUtilityTest.php:1795
‪TYPO3\CMS\Core\Utility\GeneralUtility\inList
‪static bool inList($list, $item)
Definition: GeneralUtility.php:518
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\$backupEnvironment
‪bool $backupEnvironment
Definition: GeneralUtilityTest.php:51
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\locationHeaderUrlDataProvider
‪locationHeaderUrlDataProvider()
Definition: GeneralUtilityTest.php:3975
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\implodeArrayForUrlDataProvider
‪implodeArrayForUrlDataProvider()
Definition: GeneralUtilityTest.php:779
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\tempnamReturnsPathWithoutBackslashes
‪tempnamReturnsPathWithoutBackslashes()
Definition: GeneralUtilityTest.php:1705
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\fixPermissionsSetsPermissionsToFile
‪fixPermissionsSetsPermissionsToFile()
Definition: GeneralUtilityTest.php:2043
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\implodeAttributesDataProvider
‪implodeAttributesDataProvider()
Definition: GeneralUtilityTest.php:1755
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\invalidFilePathForTypo3tempDirDataProvider
‪invalidFilePathForTypo3tempDirDataProvider()
Definition: GeneralUtilityTest.php:2330
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\addInstanceCalledTwoTimesMakesMakeInstanceReturnBothInstancesInAddingOrder
‪addInstanceCalledTwoTimesMakesMakeInstanceReturnBothInstancesInAddingOrder()
Definition: GeneralUtilityTest.php:3306
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\canRetrieveGlobalInputsThroughGet
‪canRetrieveGlobalInputsThroughGet($key, $get, $expected)
Definition: GeneralUtilityTest.php:188
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\getFilesInDirFindsHiddenFile
‪getFilesInDirFindsHiddenFile()
Definition: GeneralUtilityTest.php:2736
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\splitCalcCorrectlySplitsExpression
‪splitCalcCorrectlySplitsExpression(array $expected, string $expression)
Definition: GeneralUtilityTest.php:630
‪TYPO3\CMS\Core\Utility\GeneralUtility\isOnCurrentHost
‪static bool isOnCurrentHost($url)
Definition: GeneralUtility.php:505
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\dirnameWithDataProvider
‪dirnameWithDataProvider(string $input, string $expectedValue)
Definition: GeneralUtilityTest.php:2928
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\cmpIPv4ReturnsFalseForNotMatchingAddress
‪cmpIPv4ReturnsFalseForNotMatchingAddress($ip, $list)
Definition: GeneralUtilityTest.php:257
‪TYPO3\CMS\Core\Tests\Unit\Utility\AccessibleProxies\ExtensionManagementUtilityAccessibleProxy
Definition: ExtensionManagementUtilityAccessibleProxy.php:29
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\$backupPackageManager
‪PackageManager $backupPackageManager
Definition: GeneralUtilityTest.php:53
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\fixPermissionsSetsPermissionsToDirectoryWithTrailingSlash
‪fixPermissionsSetsPermissionsToDirectoryWithTrailingSlash()
Definition: GeneralUtilityTest.php:2103
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\xml2arrayProcessHandlesWhitespaces
‪xml2arrayProcessHandlesWhitespaces(string $input)
Definition: GeneralUtilityTest.php:3717
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\makeInstanceCalledTwoTimesForNonSingletonClassReturnsDifferentInstances
‪makeInstanceCalledTwoTimesForNonSingletonClassReturnsDifferentInstances()
Definition: GeneralUtilityTest.php:3100
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:51
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\getIndpEnvTypo3SitePathReturnsStringEndingWithSlash
‪getIndpEnvTypo3SitePathReturnsStringEndingWithSlash()
Definition: GeneralUtilityTest.php:1196
‪TYPO3\CMS\Core\Utility\StringUtility
Definition: StringUtility.php:24
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\formatSizeTranslatesBytesToHigherOrderRepresentation
‪formatSizeTranslatesBytesToHigherOrderRepresentation($size, $labels, $base, $expected)
Definition: GeneralUtilityTest.php:553
‪TYPO3\CMS\Core\Core\SystemEnvironmentBuilder\REQUESTTYPE_FE
‪const REQUESTTYPE_FE
Definition: SystemEnvironmentBuilder.php:43
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\getBytesFromSizeMeasurementDataProvider
‪array getBytesFromSizeMeasurementDataProvider()
Definition: GeneralUtilityTest.php:1164
‪TYPO3\CMS\Core\Utility\GeneralUtility\mkdir
‪static bool mkdir($newFolder)
Definition: GeneralUtility.php:1717
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\getFilesInDirFindsRegularFile
‪getFilesInDirFindsRegularFile()
Definition: GeneralUtilityTest.php:2726
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\rmdirRemovesLinkToDirectory
‪rmdirRemovesLinkToDirectory()
Definition: GeneralUtilityTest.php:2654
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\addInstanceWithSingletonInstanceThrowsException
‪addInstanceWithSingletonInstanceThrowsException()
Definition: GeneralUtilityTest.php:3272
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\makeInstanceReturnsClassInstance
‪makeInstanceReturnsClassInstance()
Definition: GeneralUtilityTest.php:3061
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\setSingletonInstanceForEmptyClassNameThrowsException
‪setSingletonInstanceForEmptyClassNameThrowsException()
Definition: GeneralUtilityTest.php:3138
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\cmpIPv6ReturnsTrueForMatchingAddress
‪cmpIPv6ReturnsTrueForMatchingAddress($ip, $list)
Definition: GeneralUtilityTest.php:290
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\rmdirRemovesDeadLinkToFile
‪rmdirRemovesDeadLinkToFile()
Definition: GeneralUtilityTest.php:2682
‪TYPO3\CMS\Core\Core\Environment\getContext
‪static getContext()
Definition: Environment.php:128
‪TYPO3\CMS\Core\Utility\GeneralUtility\underscoredToUpperCamelCase
‪static string underscoredToUpperCamelCase($string)
Definition: GeneralUtility.php:729
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\unlink_tempfileReturnsNullIfFileIsNowWithinTypo3temp
‪unlink_tempfileReturnsNullIfFileIsNowWithinTypo3temp()
Definition: GeneralUtilityTest.php:1681
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\splitFileRefReturnsFileTypeNotForFolders
‪splitFileRefReturnsFileTypeNotForFolders()
Definition: GeneralUtilityTest.php:2869
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\xml2ArrayProcessHandlesAttributeTypesDataProvider
‪array[] xml2ArrayProcessHandlesAttributeTypesDataProvider()
Definition: GeneralUtilityTest.php:3893
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\revExplodeRespectsLimitThreeWhenExploding
‪revExplodeRespectsLimitThreeWhenExploding()
Definition: GeneralUtilityTest.php:920
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\intExplodeReturnsExplodedArray
‪intExplodeReturnsExplodedArray(string $input, bool $removeEmpty, array $expected)
Definition: GeneralUtilityTest.php:768
‪TYPO3\CMS\Core\Utility\StringUtility\getUniqueId
‪static getUniqueId(string $prefix='')
Definition: StringUtility.php:29
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\quoteJsValueDataProvider
‪quoteJsValueDataProvider()
Definition: GeneralUtilityTest.php:1906
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\implodeAttributesEscapesProperly
‪implodeAttributesEscapesProperly(array $input, bool $xhtmlSafe, bool $keepEmptyValues, string $expected)
Definition: GeneralUtilityTest.php:1787
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\expandListExpandsForTwoThousandElementsExpandsOnlyToThousandElementsMaximum
‪expandListExpandsForTwoThousandElementsExpandsOnlyToThousandElementsMaximum()
Definition: GeneralUtilityTest.php:540
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\rmdirReturnFalseIfNoFileWasRemoved
‪rmdirReturnFalseIfNoFileWasRemoved()
Definition: GeneralUtilityTest.php:2594
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\expandListExpandsIntegerRanges
‪expandListExpandsIntegerRanges(string $list, string $expectation)
Definition: GeneralUtilityTest.php:514
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\addInstanceForEmptyClassNameThrowsException
‪addInstanceForEmptyClassNameThrowsException()
Definition: GeneralUtilityTest.php:3245
‪TYPO3\CMS\Core\Utility\GeneralUtility\writeFileToTypo3tempDir
‪static string null writeFileToTypo3tempDir($filepath, $content)
Definition: GeneralUtility.php:1640
‪TYPO3\CMS\Core\Core\Environment\isWindows
‪static isWindows()
Definition: Environment.php:285
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\dirnameDataProvider
‪array array[] dirnameDataProvider()
Definition: GeneralUtilityTest.php:2909
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\gpMergedWillMergeArraysFromGetAndPost
‪gpMergedWillMergeArraysFromGetAndPost($get, $post, $expected)
Definition: GeneralUtilityTest.php:142