‪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 final 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 _GET
102 
106  public static function ‪getAndPostDataProvider(): array
107  {
108  return [
109  'canRetrieveGlobalInputsThroughPosted input data doesn\'t exist' => ['cake', [], null],
110  'No key will return entire input data' => [null, ['cake' => 'l\\ie'], ['cake' => 'l\\ie']],
111  'Can retrieve specific input' => ['cake', ['cake' => 'l\\ie', 'foo'], 'l\\ie'],
112  'Can retrieve nested input data' => ['cake', ['cake' => ['is a' => 'l\\ie']], ['is a' => 'l\\ie']],
113  ];
114  }
115 
120  public function ‪canRetrieveGlobalInputsThroughGet($key, $get, $expected): void
121  {
122  $_GET = $get;
123  self::assertSame($expected, ‪GeneralUtility::_GET($key));
124  }
125 
127  // Tests concerning cmpIPv4
129 
134  public static function ‪cmpIPv4DataProviderMatching(): array
135  {
136  return [
137  'host with full IP address' => ['127.0.0.1', '127.0.0.1'],
138  'host with two wildcards at the end' => ['127.0.0.1', '127.0.*.*'],
139  'host with wildcard at third octet' => ['127.0.0.1', '127.0.*.1'],
140  'host with wildcard at second octet' => ['127.0.0.1', '127.*.0.1'],
141  '/8 subnet' => ['127.0.0.1', '127.1.1.1/8'],
142  '/32 subnet (match only name)' => ['127.0.0.1', '127.0.0.1/32'],
143  '/30 subnet' => ['10.10.3.1', '10.10.3.3/30'],
144  'host with wildcard in list with IPv4/IPv6 addresses' => ['192.168.1.1', '127.0.0.1, 1234:5678::/126, 192.168.*'],
145  'host in list with IPv4/IPv6 addresses' => ['192.168.1.1', '::1, 1234:5678::/126, 192.168.1.1'],
146  ];
147  }
148 
153  public function ‪cmpIPv4ReturnsTrueForMatchingAddress($ip, $list): void
154  {
155  self::assertTrue(‪GeneralUtility::cmpIPv4($ip, $list));
156  }
157 
163  public static function ‪cmpIPv4DataProviderNotMatching(): array
164  {
165  return [
166  'single host' => ['127.0.0.1', '127.0.0.2'],
167  'single host with wildcard' => ['127.0.0.1', '127.*.1.1'],
168  'single host with /32 subnet mask' => ['127.0.0.1', '127.0.0.2/32'],
169  '/31 subnet' => ['127.0.0.1', '127.0.0.2/31'],
170  'list with IPv4/IPv6 addresses' => ['127.0.0.1', '10.0.2.3, 192.168.1.1, ::1'],
171  'list with only IPv6 addresses' => ['10.20.30.40', '::1, 1234:5678::/127'],
172  ];
173  }
174 
179  public function ‪cmpIPv4ReturnsFalseForNotMatchingAddress($ip, $list): void
180  {
181  self::assertFalse(‪GeneralUtility::cmpIPv4($ip, $list));
182  }
183 
185  // Tests concerning cmpIPv6
187 
192  public static function ‪cmpIPv6DataProviderMatching(): array
193  {
194  return [
195  'empty address' => ['::', '::'],
196  'empty with netmask in list' => ['::', '::/0'],
197  'empty with netmask 0 and host-bits set in list' => ['::', '::123/0'],
198  'localhost' => ['::1', '::1'],
199  'localhost with leading zero blocks' => ['::1', '0:0::1'],
200  'host with submask /128' => ['::1', '0:0::1/128'],
201  '/16 subnet' => ['1234::1', '1234:5678::/16'],
202  '/126 subnet' => ['1234:5678::3', '1234:5678::/126'],
203  '/126 subnet with host-bits in list set' => ['1234:5678::3', '1234:5678::2/126'],
204  'list with IPv4/IPv6 addresses' => ['1234:5678::3', '::1, 127.0.0.1, 1234:5678::/126, 192.168.1.1'],
205  ];
206  }
207 
212  public function ‪cmpIPv6ReturnsTrueForMatchingAddress($ip, $list): void
213  {
214  self::assertTrue(‪GeneralUtility::cmpIPv6($ip, $list));
215  }
216 
222  public static function ‪cmpIPv6DataProviderNotMatching(): array
223  {
224  return [
225  'empty against localhost' => ['::', '::1'],
226  'empty against localhost with /128 netmask' => ['::', '::1/128'],
227  'localhost against different host' => ['::1', '::2'],
228  'localhost against host with prior bits set' => ['::1', '::1:1'],
229  'host against different /17 subnet' => ['1234::1', '1234:f678::/17'],
230  'host against different /127 subnet' => ['1234:5678::3', '1234:5678::/127'],
231  'host against IPv4 address list' => ['1234:5678::3', '127.0.0.1, 192.168.1.1'],
232  'host against mixed list with IPv6 host in different subnet' => ['1234:5678::3', '::1, 1234:5678::/127'],
233  ];
234  }
235 
240  public function ‪cmpIPv6ReturnsFalseForNotMatchingAddress($ip, $list): void
241  {
242  self::assertFalse(‪GeneralUtility::cmpIPv6($ip, $list));
243  }
244 
246  // Tests concerning normalizeIPv6
248 
253  public static function ‪normalizeCompressIPv6DataProviderCorrect(): array
254  {
255  return [
256  'empty' => ['::', '0000:0000:0000:0000:0000:0000:0000:0000'],
257  'localhost' => ['::1', '0000:0000:0000:0000:0000:0000:0000:0001'],
258  'expansion in middle 1' => ['1::2', '0001:0000:0000:0000:0000:0000:0000:0002'],
259  'expansion in middle 2' => ['1:2::3', '0001:0002:0000:0000:0000:0000:0000:0003'],
260  'expansion in middle 3' => ['1::2:3', '0001:0000:0000:0000:0000:0000:0002:0003'],
261  'expansion in middle 4' => ['1:2::3:4:5', '0001:0002:0000:0000:0000:0003:0004:0005'],
262  ];
263  }
264 
269  public function ‪normalizeIPv6CorrectlyNormalizesAddresses($compressed, $normalized): void
270  {
271  self::assertEquals($normalized, ‪GeneralUtility::normalizeIPv6($compressed));
272  }
273 
275  // Tests concerning validIP
277 
282  public static function ‪validIpDataProvider(): array
283  {
284  return [
285  '0.0.0.0' => ['0.0.0.0'],
286  'private IPv4 class C' => ['192.168.0.1'],
287  'private IPv4 class A' => ['10.0.13.1'],
288  'private IPv6' => ['fe80::daa2:5eff:fe8b:7dfb'],
289  ];
290  }
291 
296  public function ‪validIpReturnsTrueForValidIp($ip): void
297  {
298  self::assertTrue(‪GeneralUtility::validIP($ip));
299  }
300 
306  public static function ‪invalidIpDataProvider(): array
307  {
308  return [
309  'null' => [null],
310  'zero' => [0],
311  'string' => ['test'],
312  'string empty' => [''],
313  'string NULL' => ['NULL'],
314  'out of bounds IPv4' => ['300.300.300.300'],
315  'dotted decimal notation with only two dots' => ['127.0.1'],
316  ];
317  }
318 
323  public function ‪validIpReturnsFalseForInvalidIp($ip): void
324  {
325  self::assertFalse(‪GeneralUtility::validIP($ip));
326  }
327 
329  // Tests concerning cmpFQDN
331 
336  public static function ‪cmpFqdnValidDataProvider(): array
337  {
338  return [
339  'localhost should usually resolve, IPv4' => ['127.0.0.1', '*'],
340  'localhost should usually resolve, IPv6' => ['::1', '*'],
341  // other testcases with resolving not possible since it would
342  // require a working IPv4/IPv6-connectivity
343  'aaa.bbb.ccc.ddd.eee, full' => ['aaa.bbb.ccc.ddd.eee', 'aaa.bbb.ccc.ddd.eee'],
344  'aaa.bbb.ccc.ddd.eee, wildcard first' => ['aaa.bbb.ccc.ddd.eee', '*.ccc.ddd.eee'],
345  'aaa.bbb.ccc.ddd.eee, wildcard last' => ['aaa.bbb.ccc.ddd.eee', 'aaa.bbb.ccc.*'],
346  'aaa.bbb.ccc.ddd.eee, wildcard middle' => ['aaa.bbb.ccc.ddd.eee', 'aaa.*.eee'],
347  'list-matches, 1' => ['aaa.bbb.ccc.ddd.eee', 'xxx, yyy, zzz, aaa.*.eee'],
348  'list-matches, 2' => ['aaa.bbb.ccc.ddd.eee', '127:0:0:1,,aaa.*.eee,::1'],
349  ];
350  }
351 
356  public function ‪cmpFqdnReturnsTrue($baseHost, $list): void
357  {
358  self::assertTrue(‪GeneralUtility::cmpFQDN($baseHost, $list));
359  }
360 
366  public static function ‪cmpFqdnInvalidDataProvider(): array
367  {
368  return [
369  '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'],
370  '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'],
371  ];
372  }
373 
378  public function ‪cmpFqdnReturnsFalse($baseHost, $list): void
379  {
380  self::assertFalse(‪GeneralUtility::cmpFQDN($baseHost, $list));
381  }
382 
384  // Tests concerning inList
386 
390  public function ‪inListForItemContainedReturnsTrue(string $haystack): void
391  {
392  self::assertTrue(‪GeneralUtility::inList($haystack, 'findme'));
393  }
394 
398  public static function ‪inListForItemContainedReturnsTrueDataProvider(): array
399  {
400  return [
401  'Element as second element of four items' => ['one,findme,three,four'],
402  'Element at beginning of list' => ['findme,one,two'],
403  'Element at end of list' => ['one,two,findme'],
404  'One item list' => ['findme'],
405  ];
406  }
407 
412  public function ‪inListForItemNotContainedReturnsFalse(string $haystack): void
413  {
414  self::assertFalse(‪GeneralUtility::inList($haystack, 'findme'));
415  }
416 
421  {
422  return [
423  'Four item list' => ['one,two,three,four'],
424  'One item list' => ['one'],
425  'Empty list' => [''],
426  ];
427  }
428 
430  // Tests concerning expandList
432 
436  public function ‪expandListExpandsIntegerRanges(string $list, string $expectation): void
437  {
438  self::assertSame($expectation, ‪GeneralUtility::expandList($list));
439  }
440 
444  public static function ‪expandListExpandsIntegerRangesDataProvider(): array
445  {
446  return [
447  'Expand for the same number' => ['1,2-2,7', '1,2,7'],
448  'Small range expand with parameters reversed ignores reversed items' => ['1,5-3,7', '1,7'],
449  'Small range expand' => ['1,3-5,7', '1,3,4,5,7'],
450  'Expand at beginning' => ['3-5,1,7', '3,4,5,1,7'],
451  'Expand at end' => ['1,7,3-5', '1,7,3,4,5'],
452  'Multiple small range expands' => ['1,3-5,7-10,12', '1,3,4,5,7,8,9,10,12'],
453  'One item list' => ['1-5', '1,2,3,4,5'],
454  'Nothing to expand' => ['1,2,3,4', '1,2,3,4'],
455  'Empty list' => ['', ''],
456  ];
457  }
458 
463  {
464  $list = ‪GeneralUtility::expandList('1-2000');
465  self::assertCount(1000, explode(',', $list));
466  }
467 
469  // Tests concerning formatSize
471 
475  public function ‪formatSizeTranslatesBytesToHigherOrderRepresentation($size, $labels, $base, $expected): void
476  {
477  self::assertEquals($expected, GeneralUtility::formatSize($size, $labels, $base));
478  }
479 
483  public static function ‪formatSizeDataProvider(): array
484  {
485  return [
486  'IEC Bytes stay bytes (min)' => [1, '', 0, '1 '],
487  'IEC Bytes stay bytes (max)' => [921, '', 0, '921 '],
488  'IEC Kilobytes are used (min)' => [922, '', 0, '0.90 Ki'],
489  'IEC Kilobytes are used (max)' => [943718, '', 0, '922 Ki'],
490  'IEC Megabytes are used (min)' => [943719, '', 0, '0.90 Mi'],
491  'IEC Megabytes are used (max)' => [966367641, '', 0, '922 Mi'],
492  'IEC Gigabytes are used (min)' => [966367642, '', 0, '0.90 Gi'],
493  'IEC Gigabytes are used (max)' => [989560464998, '', 0, '922 Gi'],
494  'IEC Decimal is omitted for large kilobytes' => [31080, '', 0, '30 Ki'],
495  'IEC Decimal is omitted for large megabytes' => [31458000, '', 0, '30 Mi'],
496  'IEC Decimal is omitted for large gigabytes' => [32212254720, '', 0, '30 Gi'],
497  'SI Bytes stay bytes (min)' => [1, 'si', 0, '1 '],
498  'SI Bytes stay bytes (max)' => [899, 'si', 0, '899 '],
499  'SI Kilobytes are used (min)' => [901, 'si', 0, '0.90 k'],
500  'SI Kilobytes are used (max)' => [900000, 'si', 0, '900 k'],
501  'SI Megabytes are used (min)' => [900001, 'si', 0, '0.90 M'],
502  'SI Megabytes are used (max)' => [900000000, 'si', 0, '900 M'],
503  'SI Gigabytes are used (min)' => [900000001, 'si', 0, '0.90 G'],
504  'SI Gigabytes are used (max)' => [900000000000, 'si', 0, '900 G'],
505  'SI Decimal is omitted for large kilobytes' => [30000, 'si', 0, '30 k'],
506  'SI Decimal is omitted for large megabytes' => [30000000, 'si', 0, '30 M'],
507  'SI Decimal is omitted for large gigabytes' => [30000000000, 'si', 0, '30 G'],
508  'Label for bytes can be exchanged (binary unit)' => [1, ' Foo|||', 0, '1 Foo'],
509  'Label for kilobytes can be exchanged (binary unit)' => [1024, '| Foo||', 0, '1.00 Foo'],
510  'Label for megabytes can be exchanged (binary unit)' => [1048576, '|| Foo|', 0, '1.00 Foo'],
511  'Label for gigabytes can be exchanged (binary unit)' => [1073741824, '||| Foo', 0, '1.00 Foo'],
512  'Label for bytes can be exchanged (decimal unit)' => [1, ' Foo|||', 1000, '1 Foo'],
513  'Label for kilobytes can be exchanged (decimal unit)' => [1000, '| Foo||', 1000, '1.00 Foo'],
514  'Label for megabytes can be exchanged (decimal unit)' => [1000000, '|| Foo|', 1000, '1.00 Foo'],
515  'Label for gigabytes can be exchanged (decimal unit)' => [1000000000, '||| Foo', 1000, '1.00 Foo'],
516  'IEC Base is ignored' => [1024, 'iec', 1000, '1.00 Ki'],
517  'SI Base is ignored' => [1000, 'si', 1024, '1.00 k'],
518  'Use binary base for unexpected base' => [2048, '| Bar||', 512, '2.00 Bar'],
519  ];
520  }
521 
523  // Tests concerning splitCalc
525 
530  public static function ‪splitCalcDataProvider(): array
531  {
532  return [
533  'empty string returns empty array' => [
534  [],
535  '',
536  ],
537  'number without operator returns array with plus and number' => [
538  [['+', '42']],
539  '42',
540  ],
541  'two numbers with asterisk return first number with plus and second number with asterisk' => [
542  [['+', '42'], ['*', '31']],
543  '42 * 31',
544  ],
545  ];
546  }
547 
552  public function ‪splitCalcCorrectlySplitsExpression(array $expected, string $expression): void
553  {
554  self::assertSame($expected, GeneralUtility::splitCalc($expression, '+-*/'));
555  }
556 
558  // Tests concerning htmlspecialchars_decode
560 
564  {
565  $string = '<typo3 version="6.0">&nbsp;</typo3>';
566  $encoded = htmlspecialchars($string);
567  $decoded = htmlspecialchars_decode($encoded);
568  self::assertEquals($string, $decoded);
569  }
570 
572  // Tests concerning validEmail
574 
579  public static function ‪validEmailValidDataProvider(): array
580  {
581  return [
582  'short mail address' => ['a@b.c'],
583  'simple mail address' => ['test@example.com'],
584  'uppercase characters' => ['QWERTYUIOPASDFGHJKLZXCVBNM@QWERTYUIOPASDFGHJKLZXCVBNM.NET'],
585  'equal sign in local part' => ['test=mail@example.com'],
586  'dash in local part' => ['test-mail@example.com'],
587  'plus in local part' => ['test+mail@example.com'],
588  'question mark in local part' => ['test?mail@example.com'],
589  'slash in local part' => ['foo/bar@example.com'],
590  'hash in local part' => ['foo#bar@example.com'],
591  'dot in local part' => ['firstname.lastname@employee.2something.com'],
592  'dash as local part' => ['-@foo.com'],
593  'umlauts in domain part' => ['foo@äöüfoo.com'],
594  'number as top level domain' => ['foo@bar.123'],
595  'top level domain only' => ['test@localhost'],
596  'umlauts in local part' => ['äöüfoo@bar.com'],
597  'quoted @ char' => ['"Abc@def"@example.com'],
598  ];
599  }
600 
605  public function ‪validEmailReturnsTrueForValidMailAddress($address): void
606  {
607  self::assertTrue(GeneralUtility::validEmail($address));
608  }
609 
615  public static function ‪validEmailInvalidDataProvider(): array
616  {
617  return [
618  'empty string' => [''],
619  'empty array' => [[]],
620  'integer' => [42],
621  'float' => [42.23],
622  'array' => [['foo']],
623  'object' => [new \stdClass()],
624  '@ sign only' => ['@'],
625  'string longer than 320 characters' => [str_repeat('0123456789', 33)],
626  'duplicate @' => ['test@@example.com'],
627  'duplicate @ combined with further special characters in local part' => ['test!.!@#$%^&*@example.com'],
628  'opening parenthesis in local part' => ['foo(bar@example.com'],
629  'closing parenthesis in local part' => ['foo)bar@example.com'],
630  'opening square bracket in local part' => ['foo[bar@example.com'],
631  'closing square bracket as local part' => [']@example.com'],
632  'dash as second level domain' => ['foo@-.com'],
633  'domain part starting with dash' => ['foo@-foo.com'],
634  'domain part ending with dash' => ['foo@foo-.com'],
635  'dot at beginning of domain part' => ['test@.com'],
636  'local part ends with dot' => ['e.x.a.m.p.l.e.@example.com'],
637  'trailing whitespace' => ['test@example.com '],
638  'trailing carriage return' => ['test@example.com' . CR],
639  'trailing linefeed' => ['test@example.com' . LF],
640  'trailing carriage return linefeed' => ['test@example.com' . CRLF],
641  'trailing tab' => ['test@example.com' . "\t"],
642  'prohibited input characters' => ['“mailto:test@example.com”'],
643  'escaped @ char' => ['abc\@def@example.com'], // known bug, see https://github.com/egulias/EmailValidator/issues/181
644  ];
645  }
646 
651  public function ‪validEmailReturnsFalseForInvalidMailAddress($address): void
652  {
653  self::assertFalse(GeneralUtility::validEmail($address));
654  }
655 
657  // Tests concerning intExplode
659 
660  public static function ‪intExplodeDataProvider(): array
661  {
662  return [
663  'convertStringToInteger' => [
664  '1,foo,2',
665  false,
666  [1, 0, 2],
667  ],
668  'zerosAreKept' => [
669  '0,1, 0, 2,0',
670  false,
671  [0, 1, 0, 2, 0],
672  ],
673  'emptyValuesAreKept' => [
674  '0,1,, 0, 2,,0',
675  false,
676  [0, 1, 0, 0, 2, 0, 0],
677  ],
678  'emptyValuesAreRemoved' => [
679  '0,1,, 0, 2,,0',
680  true,
681  [0=>0, 1=>1, 3=>0, 4=>2, 6=>0], // note does not renumber keys!
682  ],
683  ];
684  }
685 
690  public function ‪intExplodeReturnsExplodedArray(string $input, bool $removeEmpty, array $expected): void
691  {
692  self::assertSame($expected, ‪GeneralUtility::intExplode(',', $input, $removeEmpty));
693  }
694 
696  // Tests concerning implodeArrayForUrl / explodeUrl2Array
698 
701  public static function ‪implodeArrayForUrlDataProvider(): array
702  {
703  $valueArray = ['one' => '√', 'two' => 2];
704  return [
705  'Empty input' => ['foo', [], ''],
706  'String parameters' => ['foo', $valueArray, '&foo[one]=%E2%88%9A&foo[two]=2'],
707  'Nested array parameters' => ['foo', [$valueArray], '&foo[0][one]=%E2%88%9A&foo[0][two]=2'],
708  'Keep blank parameters' => ['foo', ['one' => '√', ''], '&foo[one]=%E2%88%9A&foo[0]='],
709  ];
710  }
711 
716  public function ‪implodeArrayForUrlBuildsValidParameterString($name, $input, $expected): void
717  {
718  self::assertSame($expected, ‪GeneralUtility::implodeArrayForUrl($name, $input));
719  }
720 
725  {
726  $input = ['one' => '√', ''];
727  $expected = '&foo[one]=%E2%88%9A';
728  self::assertSame($expected, ‪GeneralUtility::implodeArrayForUrl('foo', $input, '', true));
729  }
730 
735  {
736  $input = ['one' => '√', ''];
737  $expected = '&foo%5Bone%5D=%E2%88%9A&foo%5B0%5D=';
738  self::assertSame($expected, ‪GeneralUtility::implodeArrayForUrl('foo', $input, '', false, true));
739  }
740 
742  {
743  return [
744  'Empty string' => ['', []],
745  'Simple parameter string' => ['&one=%E2%88%9A&two=2', ['one' => '√', 'two' => 2]],
746  'Nested parameter string' => ['&foo[one]=%E2%88%9A&two=2', ['foo[one]' => '√', 'two' => 2]],
747  'Parameter without value' => ['&one=&two=2', ['one' => '', 'two' => 2]],
748  'Nested parameter without value' => ['&foo[one]=&two=2', ['foo[one]' => '', 'two' => 2]],
749  'Parameter without equals sign' => ['&one&two=2', ['one' => '', 'two' => 2]],
750  'Nested parameter without equals sign' => ['&foo[one]&two=2', ['foo[one]' => '', 'two' => 2]],
751  ];
752  }
753 
758  public function ‪explodeUrl2ArrayTransformsParameterStringToFlatArray(string $input, array $expected): void
759  {
760  self::assertEquals($expected, GeneralUtility::explodeUrl2Array($input));
761  }
762 
763  public static function ‪revExplodeDataProvider(): array
764  {
765  return [
766  'limit 0 should return unexploded string' => [
767  ':',
768  'my:words:here',
769  0,
770  ['my:words:here'],
771  ],
772  'limit 1 should return unexploded string' => [
773  ':',
774  'my:words:here',
775  1,
776  ['my:words:here'],
777  ],
778  'limit 2 should return two pieces' => [
779  ':',
780  'my:words:here',
781  2,
782  ['my:words', 'here'],
783  ],
784  'limit 3 should return unexploded string' => [
785  ':',
786  'my:words:here',
787  3,
788  ['my', 'words', 'here'],
789  ],
790  'limit 0 should return unexploded string if no delimiter is contained' => [
791  ':',
792  'mywordshere',
793  0,
794  ['mywordshere'],
795  ],
796  'limit 1 should return unexploded string if no delimiter is contained' => [
797  ':',
798  'mywordshere',
799  1,
800  ['mywordshere'],
801  ],
802  'limit 2 should return unexploded string if no delimiter is contained' => [
803  ':',
804  'mywordshere',
805  2,
806  ['mywordshere'],
807  ],
808  'limit 3 should return unexploded string if no delimiter is contained' => [
809  ':',
810  'mywordshere',
811  3,
812  ['mywordshere'],
813  ],
814  'multi character delimiter is handled properly with limit 2' => [
815  '[]',
816  'a[b][c][d]',
817  2,
818  ['a[b][c', 'd]'],
819  ],
820  'multi character delimiter is handled properly with limit 3' => [
821  '[]',
822  'a[b][c][d]',
823  3,
824  ['a[b', 'c', 'd]'],
825  ],
826  ];
827  }
828 
833  public function ‪revExplodeCorrectlyExplodesStringForGivenPartsCount($delimiter, $testString, $count, $expectedArray): void
834  {
835  $actualArray = ‪GeneralUtility::revExplode($delimiter, $testString, $count);
836  self::assertEquals($expectedArray, $actualArray);
837  }
838 
843  {
844  $testString = 'even:more:of:my:words:here';
845  $expectedArray = ['even:more:of:my', 'words', 'here'];
846  $actualArray = ‪GeneralUtility::revExplode(':', $testString, 3);
847  self::assertEquals($expectedArray, $actualArray);
848  }
849 
851  // Tests concerning trimExplode
853 
857  public function ‪trimExplodeReturnsCorrectResult(string $delimiter, string $testString, bool $removeEmpty, int $limit, array $expectedResult): void
858  {
859  self::assertSame($expectedResult, ‪GeneralUtility::trimExplode($delimiter, $testString, $removeEmpty, $limit));
860  }
861 
862  public static function ‪trimExplodeReturnsCorrectResultDataProvider(): array
863  {
864  return [
865  'spaces at element start and end' => [
866  ',',
867  ' a , b , c ,d ,, e,f,',
868  false,
869  0,
870  ['a', 'b', 'c', 'd', '', 'e', 'f', ''],
871  ],
872  'removes newline' => [
873  ',',
874  ' a , b , ' . LF . ' ,d ,, e,f,',
875  true,
876  0,
877  ['a', 'b', 'd', 'e', 'f'],
878  ],
879  'removes empty elements' => [
880  ',',
881  'a , b , c , ,d ,, ,e,f,',
882  true,
883  0,
884  ['a', 'b', 'c', 'd', 'e', 'f'],
885  ],
886  'keeps remaining results with empty items after reaching limit with positive parameter' => [
887  ',',
888  ' a , b , c , , d,, ,e ',
889  false,
890  3,
891  ['a', 'b', 'c , , d,, ,e'],
892  ],
893  'keeps remaining results without empty items after reaching limit with positive parameter' => [
894  ',',
895  ' a , b , c , , d,, ,e ',
896  true,
897  3,
898  ['a', 'b', 'c , d,e'],
899  ],
900  'keeps remaining results with empty items after reaching limit with negative parameter' => [
901  ',',
902  ' a , b , c , d, ,e, f , , ',
903  false,
904  -3,
905  ['a', 'b', 'c', 'd', '', 'e'],
906  ],
907  'keeps remaining results without empty items after reaching limit with negative parameter' => [
908  ',',
909  ' a , b , c , d, ,e, f , , ',
910  true,
911  -3,
912  ['a', 'b', 'c'],
913  ],
914  'returns exact results without reaching limit with positive parameter' => [
915  ',',
916  ' a , b , , c , , , ',
917  true,
918  4,
919  ['a', 'b', 'c'],
920  ],
921  'keeps zero as string' => [
922  ',',
923  'a , b , c , ,d ,, ,e,f, 0 ,',
924  true,
925  0,
926  ['a', 'b', 'c', 'd', 'e', 'f', '0'],
927  ],
928  'keeps whitespace inside elements' => [
929  ',',
930  'a , b , c , ,d ,, ,e,f, g h ,',
931  true,
932  0,
933  ['a', 'b', 'c', 'd', 'e', 'f', 'g h'],
934  ],
935  'can use internal regex delimiter as explode delimiter' => [
936  '/',
937  'a / b / c / /d // /e/f/ g h /',
938  true,
939  0,
940  ['a', 'b', 'c', 'd', 'e', 'f', 'g h'],
941  ],
942  'can use whitespaces as delimiter' => [
943  ' ',
944  '* * * * *',
945  true,
946  0,
947  ['*', '*', '*', '*', '*'],
948  ],
949  'can use words as delimiter' => [
950  'All',
951  'HelloAllTogether',
952  true,
953  0,
954  ['Hello', 'Together'],
955  ],
956  'can use word with appended and prepended spaces as delimiter' => [
957  ' all ',
958  'Hello all together',
959  true,
960  0,
961  ['Hello', 'together'],
962  ],
963  'can use word with appended and prepended spaces as delimiter and do not remove empty' => [
964  ' all ',
965  'Hello all together all there all all are all none',
966  false,
967  0,
968  ['Hello', 'together', 'there', '', 'are', 'none'],
969  ],
970  'can use word with appended and prepended spaces as delimiter, do not remove empty and limit' => [
971  ' all ',
972  'Hello all together all there all all are all none',
973  false,
974  5,
975  ['Hello', 'together', 'there', '', 'are all none'],
976  ],
977  'can use word with appended and prepended spaces as delimiter, do not remove empty, limit and multiple delimiter in last' => [
978  ' all ',
979  'Hello all together all there all all are all none',
980  false,
981  4,
982  ['Hello', 'together', 'there', 'all are all none'],
983  ],
984  'can use word with appended and prepended spaces as delimiter, remove empty and limit' => [
985  ' all ',
986  'Hello all together all there all all are all none',
987  true,
988  4,
989  ['Hello', 'together', 'there', 'are all none'],
990  ],
991  'can use word with appended and prepended spaces as delimiter, remove empty and limit and multiple delimiter in last' => [
992  ' all ',
993  'Hello all together all there all all are all none',
994  true,
995  5,
996  ['Hello', 'together', 'there', 'are' , 'none'],
997  ],
998  'can use words as delimiter and do not remove empty' => [
999  'all there',
1000  'Helloall theretogether all there all there are all there none',
1001  false,
1002  0,
1003  ['Hello', 'together', '', 'are', 'none'],
1004  ],
1005  'can use words as delimiter, do not remove empty and limit' => [
1006  'all there',
1007  'Helloall theretogether all there all there are all there none',
1008  false,
1009  4,
1010  ['Hello', 'together', '', 'are all there none'],
1011  ],
1012  'can use words as delimiter, do not remove empty, limit and multiple delimiter in last' => [
1013  'all there',
1014  'Helloall theretogether all there all there are all there none',
1015  false,
1016  3,
1017  ['Hello', 'together', 'all there are all there none'],
1018  ],
1019  'can use words as delimiter, remove empty' => [
1020  'all there',
1021  'Helloall theretogether all there all there are all there none',
1022  true,
1023  0,
1024  ['Hello', 'together', 'are', 'none'],
1025  ],
1026  'can use words as delimiter, remove empty and limit' => [
1027  'all there',
1028  'Helloall theretogether all there all there are all there none',
1029  true,
1030  3,
1031  ['Hello', 'together', 'are all there none'],
1032  ],
1033  'can use words as delimiter, remove empty and limit and multiple delimiter in last' => [
1034  'all there',
1035  'Helloall theretogether all there all there are all there none',
1036  true,
1037  4,
1038  ['Hello', 'together', 'are' , 'none'],
1039  ],
1040  'can use new line as delimiter' => [
1041  LF,
1042  "Hello\nall\ntogether",
1043  true,
1044  0,
1045  ['Hello', 'all', 'together'],
1046  ],
1047  'works with whitespace separator' => [
1048  "\t",
1049  " a b \t c \t \t d \t e \t u j \t s",
1050  false,
1051  0,
1052  ['a b', 'c', '', 'd', 'e', 'u j', 's'],
1053  ],
1054  'works with whitespace separator and limit' => [
1055  "\t",
1056  " a b \t c \t \t d \t e \t u j \t s",
1057  false,
1058  4,
1059  ['a b', 'c', '', "d \t e \t u j \t s"],
1060  ],
1061  'works with whitespace separator and remove empty' => [
1062  "\t",
1063  " a b \t c \t \t d \t e \t u j \t s",
1064  true,
1065  0,
1066  ['a b', 'c', 'd', 'e', 'u j', 's'],
1067  ],
1068  'works with whitespace separator remove empty and limit' => [
1069  "\t",
1070  " a b \t c \t \t d \t e \t u j \t s",
1071  true,
1072  3,
1073  ['a b', 'c', "d \t e \t u j \t s"],
1074  ],
1075  ];
1076  }
1077 
1079  // Tests concerning getBytesFromSizeMeasurement
1081 
1086  public static function ‪getBytesFromSizeMeasurementDataProvider(): array
1087  {
1088  return [
1089  '100 kilo Bytes' => ['102400', '100k'],
1090  '100 mega Bytes' => ['104857600', '100m'],
1091  '100 giga Bytes' => ['107374182400', '100g'],
1092  ];
1093  }
1094 
1099  public function ‪getBytesFromSizeMeasurementCalculatesCorrectByteValue($expected, $byteString): void
1100  {
1101  self::assertEquals($expected, GeneralUtility::getBytesFromSizeMeasurement($byteString));
1102  }
1103 
1105  // Tests concerning getIndpEnv
1107 
1111  {
1112  self::assertTrue(strlen(GeneralUtility::getIndpEnv('TYPO3_SITE_PATH')) >= 1);
1113  }
1114 
1119  {
1120  $result = GeneralUtility::getIndpEnv('TYPO3_SITE_PATH');
1121  self::assertEquals('/', $result[strlen($result) - 1]);
1122  }
1123 
1124  public static function ‪hostnameAndPortDataProvider(): array
1125  {
1126  return [
1127  'localhost ipv4 without port' => ['127.0.0.1', '127.0.0.1', ''],
1128  'localhost ipv4 with port' => ['127.0.0.1:81', '127.0.0.1', '81'],
1129  'localhost ipv6 without port' => ['[::1]', '[::1]', ''],
1130  'localhost ipv6 with port' => ['[::1]:81', '[::1]', '81'],
1131  'ipv6 without port' => ['[2001:DB8::1]', '[2001:DB8::1]', ''],
1132  'ipv6 with port' => ['[2001:DB8::1]:81', '[2001:DB8::1]', '81'],
1133  'hostname without port' => ['lolli.did.this', 'lolli.did.this', ''],
1134  'hostname with port' => ['lolli.did.this:42', 'lolli.did.this', '42'],
1135  ];
1136  }
1137 
1142  public function ‪getIndpEnvTypo3HostOnlyParsesHostnamesAndIpAddresses($httpHost, $expectedIp): void
1143  {
1144  $_SERVER['HTTP_HOST'] = $httpHost;
1145  self::assertEquals($expectedIp, GeneralUtility::getIndpEnv('TYPO3_HOST_ONLY'));
1146  }
1147 
1152  public function ‪getIndpEnvTypo3PortParsesHostnamesAndIpAddresses($httpHost, $dummy, $expectedPort): void
1153  {
1154  $_SERVER['HTTP_HOST'] = $httpHost;
1155  self::assertEquals($expectedPort, GeneralUtility::getIndpEnv('TYPO3_PORT'));
1156  }
1157 
1159  // Tests concerning underscoredToUpperCamelCase
1161 
1166  public static function ‪underscoredToUpperCamelCaseDataProvider(): array
1167  {
1168  return [
1169  'single word' => ['Blogexample', 'blogexample'],
1170  'multiple words' => ['BlogExample', 'blog_example'],
1171  ];
1172  }
1173 
1178  public function ‪underscoredToUpperCamelCase($expected, $inputString): void
1179  {
1180  self::assertEquals($expected, ‪GeneralUtility::underscoredToUpperCamelCase($inputString));
1181  }
1182 
1184  // Tests concerning underscoredToLowerCamelCase
1186 
1191  public static function ‪underscoredToLowerCamelCaseDataProvider(): array
1192  {
1193  return [
1194  'single word' => ['minimalvalue', 'minimalvalue'],
1195  'multiple words' => ['minimalValue', 'minimal_value'],
1196  ];
1197  }
1198 
1203  public function ‪underscoredToLowerCamelCase($expected, $inputString): void
1204  {
1205  self::assertEquals($expected, ‪GeneralUtility::underscoredToLowerCamelCase($inputString));
1206  }
1207 
1209  // Tests concerning camelCaseToLowerCaseUnderscored
1211 
1216  public static function ‪camelCaseToLowerCaseUnderscoredDataProvider(): array
1217  {
1218  return [
1219  'single word' => ['blogexample', 'blogexample'],
1220  'single word starting upper case' => ['blogexample', 'Blogexample'],
1221  'two words starting lower case' => ['minimal_value', 'minimalValue'],
1222  'two words starting upper case' => ['blog_example', 'BlogExample'],
1223  ];
1224  }
1225 
1230  public function ‪camelCaseToLowerCaseUnderscored($expected, $inputString): void
1231  {
1232  self::assertEquals($expected, ‪GeneralUtility::camelCaseToLowerCaseUnderscored($inputString));
1233  }
1234 
1236  // Tests concerning isValidUrl
1238 
1243  public static function ‪validUrlValidResourceDataProvider(): array
1244  {
1245  return [
1246  'http' => ['http://www.example.org/'],
1247  'http without trailing slash' => ['http://qwe'],
1248  'http directory with trailing slash' => ['http://www.example/img/dir/'],
1249  'http directory without trailing slash' => ['http://www.example/img/dir'],
1250  'http index.html' => ['http://example.com/index.html'],
1251  'http index.php' => ['http://www.example.com/index.php'],
1252  'http test.png' => ['http://www.example/img/test.png'],
1253  'http username password querystring and anchor' => ['https://user:pw@www.example.org:80/path?arg=value#fragment'],
1254  'file' => ['file:///tmp/test.c'],
1255  'file directory' => ['file://foo/bar'],
1256  'ftp directory' => ['ftp://ftp.example.com/tmp/'],
1257  'mailto' => ['mailto:foo@bar.com'],
1258  'news' => ['news:news.php.net'],
1259  'telnet' => ['telnet://192.0.2.16:80/'],
1260  'ldap' => ['ldap://[2001:db8::7]/c=GB?objectClass?one'],
1261  'http punycode domain name' => ['http://www.xn--bb-eka.at'],
1262  'http punicode subdomain' => ['http://xn--h-zfa.oebb.at'],
1263  'http domain-name umlauts' => ['http://www.öbb.at'],
1264  'http subdomain umlauts' => ['http://äh.oebb.at'],
1265  ];
1266  }
1267 
1273  {
1274  self::assertTrue(‪GeneralUtility::isValidUrl(‪$url));
1275  }
1276 
1282  public static function ‪isValidUrlInvalidResourceDataProvider(): array
1283  {
1284  return [
1285  'http missing colon' => ['http//www.example/wrong/url/'],
1286  'http missing slash' => ['http:/www.example'],
1287  'hostname only' => ['www.example.org/'],
1288  'file missing protocol specification' => ['/tmp/test.c'],
1289  'slash only' => ['/'],
1290  'string http://' => ['http://'],
1291  'string http:/' => ['http:/'],
1292  'string http:' => ['http:'],
1293  'string http' => ['http'],
1294  'empty string' => [''],
1295  'string -1' => ['-1'],
1296  'string array()' => ['array()'],
1297  'random string' => ['qwe'],
1298  'http directory umlauts' => ['http://www.oebb.at/äöü/'],
1299  'prohibited input characters' => ['https://{$unresolved_constant}'],
1300  ];
1301  }
1302 
1308  {
1309  self::assertFalse(‪GeneralUtility::isValidUrl(‪$url));
1310  }
1311 
1313  // Tests concerning isOnCurrentHost
1315 
1319  {
1320  $testUrl = GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL');
1321  self::assertTrue(‪GeneralUtility::isOnCurrentHost($testUrl));
1322  }
1323 
1329  public function ‪checkisOnCurrentHostInvalidHosts(): array
1330  {
1331  return [
1332  'empty string' => [''],
1333  'arbitrary string' => ['arbitrary string'],
1334  'localhost IP' => ['127.0.0.1'],
1335  'relative path' => ['./relpath/file.txt'],
1336  'absolute path' => ['/abspath/file.txt?arg=value'],
1337  'different host' => [GeneralUtility::getIndpEnv('TYPO3_REQUEST_HOST') . '.example.org'],
1338  ];
1339  }
1340 
1342  // Tests concerning sanitizeLocalUrl
1344 
1349  public static function ‪sanitizeLocalUrlValidPathsDataProvider(): array
1350  {
1351  return [
1352  'alt_intro.php' => ['alt_intro.php'],
1353  'alt_intro.php?foo=1&bar=2' => ['alt_intro.php?foo=1&bar=2'],
1354  '../index.php' => ['../index.php'],
1355  '../typo3/alt_intro.php' => ['../typo3/alt_intro.php'],
1356  '../~userDirectory/index.php' => ['../~userDirectory/index.php'],
1357  '../typo3/index.php?var1=test-case&var2=~user' => ['../typo3/index.php?var1=test-case&var2=~user'],
1358  ‪Environment::getPublicPath() . '/typo3/alt_intro.php' => [‪Environment::getPublicPath() . '/typo3/alt_intro.php'],
1359  ];
1360  }
1361 
1366  public function ‪sanitizeLocalUrlAcceptsNotEncodedValidPaths(string $path): void
1367  {
1370  true,
1371  false,
1376  // needs to be a subpath in order to validate ".." references
1377  ‪Environment::getPublicPath() . '/typo3/index.php',
1378  ‪Environment::isWindows() ? 'WINDOWS' : 'UNIX'
1379  );
1380  self::assertEquals($path, GeneralUtility::sanitizeLocalUrl($path));
1381  }
1382 
1387  public function ‪sanitizeLocalUrlAcceptsEncodedValidPaths(string $path): void
1388  {
1391  true,
1392  false,
1397  // needs to be a subpath in order to validate ".." references
1398  ‪Environment::getPublicPath() . '/typo3/index.php',
1399  ‪Environment::isWindows() ? 'WINDOWS' : 'UNIX'
1400  );
1401  self::assertEquals(rawurlencode($path), GeneralUtility::sanitizeLocalUrl(rawurlencode($path)));
1402  }
1403 
1409  public static function ‪sanitizeLocalUrlValidUrlsDataProvider(): array
1410  {
1411  return [
1412  '/cms/typo3/alt_intro.php' => [
1413  '/cms/typo3/alt_intro.php',
1414  'localhost',
1415  '/cms/',
1416  ],
1417  '/cms/index.php' => [
1418  '/cms/index.php',
1419  'localhost',
1420  '/cms/',
1421  ],
1422  'http://localhost/typo3/alt_intro.php' => [
1423  'http://localhost/typo3/alt_intro.php',
1424  'localhost',
1425  '',
1426  ],
1427  'http://localhost/cms/typo3/alt_intro.php' => [
1428  'http://localhost/cms/typo3/alt_intro.php',
1429  'localhost',
1430  '/cms/',
1431  ],
1432  ];
1433  }
1434 
1439  public function ‪sanitizeLocalUrlAcceptsNotEncodedValidUrls(string ‪$url, string $host, string $subDirectory): void
1440  {
1443  true,
1444  false,
1449  // needs to be a subpath in order to validate ".." references
1450  ‪Environment::getPublicPath() . '/typo3/index.php',
1451  ‪Environment::isWindows() ? 'WINDOWS' : 'UNIX'
1452  );
1453  $_SERVER['HTTP_HOST'] = $host;
1454  $_SERVER['SCRIPT_NAME'] = $subDirectory . 'typo3/index.php';
1455  self::assertEquals(‪$url, GeneralUtility::sanitizeLocalUrl(‪$url));
1456  }
1457 
1462  public function ‪sanitizeLocalUrlAcceptsEncodedValidUrls(string ‪$url, string $host, string $subDirectory): void
1463  {
1466  true,
1467  false,
1472  // needs to be a subpath in order to validate ".." references
1473  ‪Environment::getPublicPath() . '/typo3/index.php',
1474  ‪Environment::isWindows() ? 'WINDOWS' : 'UNIX'
1475  );
1476  $_SERVER['HTTP_HOST'] = $host;
1477  $_SERVER['SCRIPT_NAME'] = $subDirectory . 'typo3/index.php';
1478  self::assertEquals(rawurlencode(‪$url), GeneralUtility::sanitizeLocalUrl(rawurlencode(‪$url)));
1479  }
1480 
1486  public static function ‪sanitizeLocalUrlInvalidDataProvider(): array
1487  {
1488  return [
1489  'empty string' => [''],
1490  'http domain' => ['http://www.google.de/'],
1491  'https domain' => ['https://www.google.de/'],
1492  'domain without schema' => ['//www.google.de/'],
1493  'XSS attempt' => ['" onmouseover="alert(123)"'],
1494  'invalid URL, UNC path' => ['\\\\foo\\bar\\'],
1495  'invalid URL, HTML break out attempt' => ['" >blabuubb'],
1496  'base64 encoded string' => ['data:%20text/html;base64,PHNjcmlwdD5hbGVydCgnWFNTJyk8L3NjcmlwdD4='],
1497  ];
1498  }
1499 
1505  {
1508  true,
1509  false,
1514  ‪Environment::getPublicPath() . '/typo3/index.php',
1515  ‪Environment::isWindows() ? 'WINDOWS' : 'UNIX'
1516  );
1517  $_SERVER['HTTP_HOST'] = 'localhost';
1518  $_SERVER['SCRIPT_NAME'] = 'typo3/index.php';
1519  self::assertEquals('', GeneralUtility::sanitizeLocalUrl(‪$url));
1520  }
1521 
1527  {
1530  true,
1531  false,
1536  ‪Environment::getPublicPath() . '/index.php',
1537  ‪Environment::isWindows() ? 'WINDOWS' : 'UNIX'
1538  );
1539  $_SERVER['HTTP_HOST'] = 'localhost';
1540  $_SERVER['SCRIPT_NAME'] = 'index.php';
1541  self::assertEquals('', GeneralUtility::sanitizeLocalUrl(‪$url));
1542  }
1543 
1549  {
1550  self::assertEquals('', GeneralUtility::sanitizeLocalUrl(rawurlencode(‪$url)));
1551  }
1552 
1554  // Tests concerning unlink_tempfile
1556 
1561  {
1562  $fixtureFile = __DIR__ . '/Fixtures/clear.gif';
1563  $testFilename = ‪Environment::getVarPath() . '/tests/' . ‪StringUtility::getUniqueId('test_') . '.gif';
1564  @copy($fixtureFile, $testFilename);
1565  GeneralUtility::unlink_tempfile($testFilename);
1566  $fileExists = file_exists($testFilename);
1567  self::assertFalse($fileExists);
1568  }
1569 
1573  public function ‪unlink_tempfileRemovesHiddenFile(): void
1574  {
1575  $fixtureFile = __DIR__ . '/Fixtures/clear.gif';
1576  $testFilename = ‪Environment::getVarPath() . '/tests/' . ‪StringUtility::getUniqueId('.test_') . '.gif';
1577  @copy($fixtureFile, $testFilename);
1578  GeneralUtility::unlink_tempfile($testFilename);
1579  $fileExists = file_exists($testFilename);
1580  self::assertFalse($fileExists);
1581  }
1582 
1587  {
1588  $fixtureFile = __DIR__ . '/Fixtures/clear.gif';
1589  $testFilename = $this->‪getTestDirectory() . '/' . ‪StringUtility::getUniqueId('test_') . '.gif';
1590  @copy($fixtureFile, $testFilename);
1591  $returnValue = GeneralUtility::unlink_tempfile($testFilename);
1592  self::assertTrue($returnValue);
1593  }
1594 
1599  {
1600  $returnValue = GeneralUtility::unlink_tempfile(‪Environment::getVarPath() . '/tests/' . ‪StringUtility::getUniqueId('i_do_not_exist'));
1601  self::assertNull($returnValue);
1602  }
1603 
1608  {
1609  $returnValue = GeneralUtility::unlink_tempfile('/tmp/typo3-unit-test-unlink_tempfile');
1610  self::assertNull($returnValue);
1611  }
1612 
1614  // Tests concerning tempnam
1616 
1621  {
1622  $filePath = GeneralUtility::tempnam('foo');
1623  $this->testFilesToDelete[] = $filePath;
1624  $fileName = basename($filePath);
1625  self::assertStringStartsWith('foo', $fileName);
1626  }
1627 
1632  {
1633  $filePath = GeneralUtility::tempnam('foo');
1634  $this->testFilesToDelete[] = $filePath;
1635  self::assertStringNotContainsString('\\', $filePath);
1636  }
1637 
1642  {
1643  $filePath = GeneralUtility::tempnam('foo');
1644  $this->testFilesToDelete[] = $filePath;
1645  self::assertStringStartsWith(‪Environment::getVarPath() . '/transient/', $filePath);
1646  }
1647 
1649  // Tests concerning removeDotsFromTS
1651 
1655  {
1656  $typoScript = [
1657  'propertyA.' => [
1658  'keyA.' => [
1659  'valueA' => 1,
1660  ],
1661  'keyB' => 2,
1662  ],
1663  'propertyB' => 3,
1664  ];
1665  $expectedResult = [
1666  'propertyA' => [
1667  'keyA' => [
1668  'valueA' => 1,
1669  ],
1670  'keyB' => 2,
1671  ],
1672  'propertyB' => 3,
1673  ];
1674  self::assertEquals($expectedResult, GeneralUtility::removeDotsFromTS($typoScript));
1675  }
1676 
1678  // Tests concerning implodeAttributes
1680 
1681  public static function ‪implodeAttributesDataProvider(): \Iterator
1682  {
1683  yield 'Generic input without xhtml' => [
1684  ['hREf' => 'https://example.com', 'title' => 'above'],
1685  false,
1686  true,
1687  'hREf="https://example.com" title="above"',
1688  ];
1689  yield 'Generic input' => [
1690  ['hREf' => 'https://example.com', 'title' => 'above'],
1691  true,
1692  true,
1693  'href="https://example.com" title="above"',
1694  ];
1695  yield 'Generic input keeping empty values' => [
1696  ['hREf' => 'https://example.com', 'title' => ''],
1697  true,
1698  true, // keep empty values
1699  'href="https://example.com" title=""',
1700  ];
1701  yield 'Generic input removing empty values' => [
1702  ['hREf' => 'https://example.com', 'title' => '', 'nomodule' => null],
1703  true,
1704  false, // do not keep empty values
1705  'href="https://example.com"',
1706  ];
1707  }
1708 
1713  public function ‪implodeAttributesEscapesProperly(array $input, bool $xhtmlSafe, bool $keepEmptyValues, string $expected): void
1714  {
1715  self::assertSame($expected, GeneralUtility::implodeAttributes($input, $xhtmlSafe, $keepEmptyValues));
1716  }
1717 
1722  {
1723  $typoScript = [
1724  'propertyA.' => [
1725  'keyA' => 'getsOverridden',
1726  'keyA.' => [
1727  'valueA' => 1,
1728  ],
1729  'keyB' => 2,
1730  ],
1731  'propertyB' => 3,
1732  ];
1733  $expectedResult = [
1734  'propertyA' => [
1735  'keyA' => [
1736  'valueA' => 1,
1737  ],
1738  'keyB' => 2,
1739  ],
1740  'propertyB' => 3,
1741  ];
1742  self::assertEquals($expectedResult, GeneralUtility::removeDotsFromTS($typoScript));
1743  }
1744 
1749  {
1750  $typoScript = [
1751  'propertyA.' => [
1752  'keyA.' => [
1753  'valueA' => 1,
1754  ],
1755  'keyA' => 'willOverride',
1756  'keyB' => 2,
1757  ],
1758  'propertyB' => 3,
1759  ];
1760  $expectedResult = [
1761  'propertyA' => [
1762  'keyA' => 'willOverride',
1763  'keyB' => 2,
1764  ],
1765  'propertyB' => 3,
1766  ];
1767  self::assertEquals($expectedResult, GeneralUtility::removeDotsFromTS($typoScript));
1768  }
1769 
1771  // Tests concerning get_dirs
1773 
1777  {
1779  self::assertIsArray($directories);
1780  }
1781 
1786  {
1787  $path = 'foo';
1788  $result = ‪GeneralUtility::get_dirs($path);
1789  $expectedResult = 'error';
1790  self::assertEquals($expectedResult, $result);
1791  }
1792 
1794  // Tests concerning hmac
1796 
1799  public function ‪hmacReturnsHashOfProperLength(): void
1800  {
1801  $hmac = ‪GeneralUtility::hmac('message');
1802  self::assertTrue(!empty($hmac) && is_string($hmac));
1803  self::assertEquals(strlen($hmac), 40);
1804  }
1805 
1810  {
1811  $msg0 = 'message';
1812  $msg1 = 'message';
1813  self::assertEquals(‪GeneralUtility::hmac($msg0), ‪GeneralUtility::hmac($msg1));
1814  }
1815 
1820  {
1821  $msg0 = 'message0';
1822  $msg1 = 'message1';
1823  self::assertNotEquals(‪GeneralUtility::hmac($msg0), ‪GeneralUtility::hmac($msg1));
1824  }
1825 
1827  // Tests concerning quoteJSvalue
1829 
1832  public static function ‪quoteJsValueDataProvider(): array
1833  {
1834  return [
1835  'Immune characters are returned as is' => [
1836  '._,',
1837  '._,',
1838  ],
1839  'Alphanumerical characters are returned as is' => [
1840  'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789',
1841  'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789',
1842  ],
1843  'Angle brackets and ampersand are encoded' => [
1844  '<>&',
1845  '\\u003C\\u003E\\u0026',
1846  ],
1847  'Quotes and backslashes are encoded' => [
1848  '"\'\\',
1849  '\\u0022\\u0027\\u005C',
1850  ],
1851  'Forward slashes are escaped' => [
1852  '</script>',
1853  '\\u003C\\/script\\u003E',
1854  ],
1855  'Empty string stays empty' => [
1856  '',
1857  '',
1858  ],
1859  'Exclamation mark and space are properly encoded' => [
1860  'Hello World!',
1861  'Hello\\u0020World\\u0021',
1862  ],
1863  'Whitespaces are properly encoded' => [
1864  "\t" . LF . CR . ' ',
1865  '\\u0009\\u000A\\u000D\\u0020',
1866  ],
1867  'Null byte is properly encoded' => [
1868  "\0",
1869  '\\u0000',
1870  ],
1871  'Umlauts are properly encoded' => [
1872  'ÜüÖöÄä',
1873  '\\u00dc\\u00fc\\u00d6\\u00f6\\u00c4\\u00e4',
1874  ],
1875  ];
1876  }
1877 
1882  public function ‪quoteJsValueTest(string $input, string $expected): void
1883  {
1884  self::assertSame('\'' . $expected . '\'', GeneralUtility::quoteJSvalue($input));
1885  }
1886 
1887  public static function ‪jsonEncodeForHtmlAttributeTestDataProvider(): array
1888  {
1889  return [
1890  [
1891  ['html' => '<tag attr="\\Vendor\\Package">value</tag>'],
1892  true,
1893  // cave: `\\\\` (four) actually required for PHP only, will be `\\` (two) in HTML
1894  '{&quot;html&quot;:&quot;\u003Ctag attr=\u0022\\\\Vendor\\\\Package\u0022\u003Evalue\u003C\/tag\u003E&quot;}',
1895  ],
1896  [
1897  ['html' => '<tag attr="\\Vendor\\Package">value</tag>'],
1898  false,
1899  // cave: `\\\\` (four) actually required for PHP only, will be `\\` (two) in HTML
1900  '{"html":"\u003Ctag attr=\u0022\\\\Vendor\\\\Package\u0022\u003Evalue\u003C\/tag\u003E"}',
1901  ],
1902  [
1903  ['spaces' => '|' . chr(9) . '|' . chr(10) . '|' . chr(13) . '|'],
1904  false,
1905  '{"spaces":"|\t|\n|\r|"}',
1906  ],
1907  ];
1908  }
1909 
1914  public function ‪jsonEncodeForHtmlAttributeTest($value, bool $useHtmlEntities, string $expectation): void
1915  {
1916  self::assertSame($expectation, GeneralUtility::jsonEncodeForHtmlAttribute($value, $useHtmlEntities));
1917  }
1918 
1919  public static function ‪jsonEncodeForJavaScriptTestDataProvider(): array
1920  {
1921  return [
1922  [
1923  ['html' => '<tag attr="\\Vendor\\Package">value</tag>'],
1924  // cave: `\\\\` (four) actually required for PHP only, will be `\\` (two) in JavaScript
1925  '{"html":"\u003Ctag attr=\u0022\\\\u005CVendor\\\\u005CPackage\u0022\u003Evalue\u003C\/tag\u003E"}',
1926  ],
1927  [
1928  ['spaces' => '|' . chr(9) . '|' . chr(10) . '|' . chr(13) . '|'],
1929  '{"spaces":"|\u0009|\u000A|\u000D|"}',
1930  ],
1931  ];
1932  }
1933 
1938  public function ‪jsonEncodeForJavaScriptTest($value, string $expectation): void
1939  {
1940  self::assertSame($expectation, GeneralUtility::jsonEncodeForJavaScript($value));
1941  }
1942 
1944  // Tests concerning fixPermissions
1946 
1950  public function ‪fixPermissionsSetsGroup(): void
1951  {
1952  if (‪Environment::isWindows()) {
1953  self::markTestSkipped(self::NO_FIX_PERMISSIONS_ON_WINDOWS);
1954  }
1955  // Create and prepare test file
1956  $filename = $this->‪getTestDirectory() . '/' . ‪StringUtility::getUniqueId('test_');
1958  $currentGroupId = posix_getegid();
1959  // Set target group and run method
1960  ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['createGroup'] = $currentGroupId;
1962  clearstatcache();
1963  self::assertEquals($currentGroupId, filegroup($filename));
1964  }
1965 
1970  {
1971  if (‪Environment::isWindows()) {
1972  self::markTestSkipped(self::NO_FIX_PERMISSIONS_ON_WINDOWS);
1973  }
1974  // Create and prepare test file
1975  $filename = $this->‪getTestDirectory() . '/' . ‪StringUtility::getUniqueId('test_');
1977  chmod($filename, 482);
1978  // Set target permissions and run method
1979  ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['fileCreateMask'] = '0660';
1980  $fixPermissionsResult = ‪GeneralUtilityFilesystemFixture::fixPermissions($filename);
1981  clearstatcache();
1982  self::assertTrue($fixPermissionsResult);
1983  self::assertEquals('0660', substr(decoct(fileperms($filename)), 2));
1984  }
1985 
1990  {
1991  if (‪Environment::isWindows()) {
1992  self::markTestSkipped(self::NO_FIX_PERMISSIONS_ON_WINDOWS);
1993  }
1994  // Create and prepare test file
1995  $filename = $this->‪getTestDirectory() . '/' . ‪StringUtility::getUniqueId('test_');
1997  chmod($filename, 482);
1998  // Set target permissions and run method
1999  ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['fileCreateMask'] = '0660';
2000  $fixPermissionsResult = ‪GeneralUtilityFilesystemFixture::fixPermissions($filename);
2001  clearstatcache();
2002  self::assertTrue($fixPermissionsResult);
2003  self::assertEquals('0660', substr(decoct(fileperms($filename)), 2));
2004  }
2005 
2010  {
2011  if (‪Environment::isWindows()) {
2012  self::markTestSkipped(self::NO_FIX_PERMISSIONS_ON_WINDOWS);
2013  }
2014  // Create and prepare test directory
2015  $directory = $this->‪getTestDirectory() . '/' . ‪StringUtility::getUniqueId('test_');
2017  chmod($directory, 1551);
2018  // Set target permissions and run method
2019  ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['folderCreateMask'] = '0770';
2020  $fixPermissionsResult = ‪GeneralUtilityFilesystemFixture::fixPermissions($directory);
2021  clearstatcache();
2022  self::assertTrue($fixPermissionsResult);
2023  self::assertEquals('0770', substr(decoct(fileperms($directory)), 1));
2024  }
2025 
2030  {
2031  if (‪Environment::isWindows()) {
2032  self::markTestSkipped(self::NO_FIX_PERMISSIONS_ON_WINDOWS);
2033  }
2034  // Create and prepare test directory
2035  $directory = $this->‪getTestDirectory() . '/' . ‪StringUtility::getUniqueId('test_');
2037  chmod($directory, 1551);
2038  // Set target permissions and run method
2039  ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['folderCreateMask'] = '0770';
2040  $fixPermissionsResult = ‪GeneralUtilityFilesystemFixture::fixPermissions($directory . '/');
2041  // Get actual permissions and clean up
2042  clearstatcache();
2043  self::assertTrue($fixPermissionsResult);
2044  self::assertEquals('0770', substr(decoct(fileperms($directory)), 1));
2045  }
2046 
2051  {
2052  if (‪Environment::isWindows()) {
2053  self::markTestSkipped(self::NO_FIX_PERMISSIONS_ON_WINDOWS);
2054  }
2055  // Create and prepare test directory
2056  $directory = $this->‪getTestDirectory() . '/' . ‪StringUtility::getUniqueId('test_');
2058  chmod($directory, 1551);
2059  // Set target permissions and run method
2060  ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['folderCreateMask'] = '0770';
2061  $fixPermissionsResult = ‪GeneralUtilityFilesystemFixture::fixPermissions($directory);
2062  // Get actual permissions and clean up
2063  clearstatcache();
2064  self::assertTrue($fixPermissionsResult);
2065  self::assertEquals('0770', substr(decoct(fileperms($directory)), 1));
2066  }
2067 
2072  {
2073  if (‪Environment::isWindows()) {
2074  self::markTestSkipped(self::NO_FIX_PERMISSIONS_ON_WINDOWS);
2075  }
2076  // Create and prepare test directory and file structure
2079  chmod(‪$baseDirectory, 1751);
2081  chmod(‪$baseDirectory . '/file', 482);
2083  chmod(‪$baseDirectory . '/foo', 1751);
2085  chmod(‪$baseDirectory . '/foo/file', 482);
2087  chmod(‪$baseDirectory . '/.bar', 1751);
2088  // Use this if writeFileToTypo3tempDir is fixed to create hidden files in subdirectories
2089  // \TYPO3\CMS\Core\Utility\GeneralUtility::writeFileToTypo3tempDir($baseDirectory . '/.bar/.file', '42');
2090  // \TYPO3\CMS\Core\Utility\GeneralUtility::writeFileToTypo3tempDir($baseDirectory . '/.bar/..file2', '42');
2091  touch(‪$baseDirectory . '/.bar/.file', 42);
2092  chmod(‪$baseDirectory . '/.bar/.file', 482);
2093  touch(‪$baseDirectory . '/.bar/..file2', 42);
2094  chmod(‪$baseDirectory . '/.bar/..file2', 482);
2095  // Set target permissions and run method
2096  ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['fileCreateMask'] = '0660';
2097  ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['folderCreateMask'] = '0770';
2099  // Get actual permissions
2100  clearstatcache();
2101  $resultBaseDirectoryPermissions = substr(decoct(fileperms(‪$baseDirectory)), 1);
2102  $resultBaseFilePermissions = substr(decoct(fileperms(‪$baseDirectory . '/file')), 2);
2103  $resultFooDirectoryPermissions = substr(decoct(fileperms(‪$baseDirectory . '/foo')), 1);
2104  $resultFooFilePermissions = substr(decoct(fileperms(‪$baseDirectory . '/foo/file')), 2);
2105  $resultBarDirectoryPermissions = substr(decoct(fileperms(‪$baseDirectory . '/.bar')), 1);
2106  $resultBarFilePermissions = substr(decoct(fileperms(‪$baseDirectory . '/.bar/.file')), 2);
2107  $resultBarFile2Permissions = substr(decoct(fileperms(‪$baseDirectory . '/.bar/..file2')), 2);
2108  // Test if everything was ok
2109  self::assertTrue($fixPermissionsResult);
2110  self::assertEquals('0770', $resultBaseDirectoryPermissions);
2111  self::assertEquals('0660', $resultBaseFilePermissions);
2112  self::assertEquals('0770', $resultFooDirectoryPermissions);
2113  self::assertEquals('0660', $resultFooFilePermissions);
2114  self::assertEquals('0770', $resultBarDirectoryPermissions);
2115  self::assertEquals('0660', $resultBarFilePermissions);
2116  self::assertEquals('0660', $resultBarFile2Permissions);
2117  }
2118 
2123  {
2124  if (‪Environment::isWindows()) {
2125  self::markTestSkipped(self::NO_FIX_PERMISSIONS_ON_WINDOWS);
2126  }
2127  // Create and prepare test file
2128  $filename = ‪Environment::getVarPath() . '/tests/../../../typo3temp/var/tests/' . ‪StringUtility::getUniqueId('test_');
2129  // Set target permissions and run method
2130  ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['fileCreateMask'] = '0660';
2131  $fixPermissionsResult = ‪GeneralUtility::fixPermissions($filename);
2132  self::assertFalse($fixPermissionsResult);
2133  }
2134 
2139  {
2140  if (‪Environment::isWindows()) {
2141  self::markTestSkipped(self::NO_FIX_PERMISSIONS_ON_WINDOWS);
2142  }
2143  $filename = 'typo3temp/var/tests/' . ‪StringUtility::getUniqueId('test_');
2145  $this->testFilesToDelete[] = ‪Environment::getPublicPath() . '/' . $filename;
2146  chmod(‪Environment::getPublicPath() . '/' . $filename, 482);
2147  // Set target permissions and run method
2148  ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['fileCreateMask'] = '0660';
2149  $fixPermissionsResult = ‪GeneralUtility::fixPermissions($filename);
2150  clearstatcache();
2151  self::assertTrue($fixPermissionsResult);
2152  self::assertEquals('0660', substr(decoct(fileperms(‪Environment::getPublicPath() . '/' . $filename)), 2));
2153  }
2154 
2159  {
2160  if (‪Environment::isWindows()) {
2161  self::markTestSkipped(self::NO_FIX_PERMISSIONS_ON_WINDOWS);
2162  }
2163  $filename = $this->‪getTestDirectory() . '/' . ‪StringUtility::getUniqueId('test_');
2165  chmod($filename, 482);
2166  unset(‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['fileCreateMask']);
2167  $fixPermissionsResult = ‪GeneralUtilityFilesystemFixture::fixPermissions($filename);
2168  clearstatcache();
2169  self::assertTrue($fixPermissionsResult);
2170  self::assertEquals('0644', substr(decoct(fileperms($filename)), 2));
2171  }
2172 
2177  {
2178  if (‪Environment::isWindows()) {
2179  self::markTestSkipped(self::NO_FIX_PERMISSIONS_ON_WINDOWS);
2180  }
2181  $directory = $this->‪getTestDirectory() . '/' . ‪StringUtility::getUniqueId('test_');
2183  chmod($directory, 1551);
2184  unset(‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['folderCreateMask']);
2185  $fixPermissionsResult = ‪GeneralUtilityFilesystemFixture::fixPermissions($directory);
2186  clearstatcache();
2187  self::assertTrue($fixPermissionsResult);
2188  self::assertEquals('0755', substr(decoct(fileperms($directory)), 1));
2189  }
2190 
2192  // Tests concerning mkdir
2194 
2197  public function ‪mkdirCreatesDirectory(): void
2198  {
2199  $directory = $this->‪getTestDirectory() . '/' . ‪StringUtility::getUniqueId('test_');
2200  $mkdirResult = ‪GeneralUtilityFilesystemFixture::mkdir($directory);
2201  clearstatcache();
2202  self::assertTrue($mkdirResult);
2203  self::assertDirectoryExists($directory);
2204  }
2205 
2209  public function ‪mkdirCreatesHiddenDirectory(): void
2210  {
2211  $directory = $this->‪getTestDirectory() . '/' . ‪StringUtility::getUniqueId('.test_');
2212  $mkdirResult = ‪GeneralUtilityFilesystemFixture::mkdir($directory);
2213  clearstatcache();
2214  self::assertTrue($mkdirResult);
2215  self::assertDirectoryExists($directory);
2216  }
2217 
2222  {
2223  $directory = $this->‪getTestDirectory() . '/' . ‪StringUtility::getUniqueId('test_') . '/';
2224  $mkdirResult = ‪GeneralUtilityFilesystemFixture::mkdir($directory);
2225  clearstatcache();
2226  self::assertTrue($mkdirResult);
2227  self::assertDirectoryExists($directory);
2228  }
2229 
2234  {
2235  if (‪Environment::isWindows()) {
2236  self::markTestSkipped(self::NO_FIX_PERMISSIONS_ON_WINDOWS);
2237  }
2238  $directory = $this->‪getTestDirectory() . '/' . ‪StringUtility::getUniqueId('test_');
2239  $oldUmask = umask(19);
2240  ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['folderCreateMask'] = '0772';
2242  clearstatcache();
2243  $resultDirectoryPermissions = substr(decoct(fileperms($directory)), 1);
2244  umask($oldUmask);
2245  self::assertEquals('0772', $resultDirectoryPermissions);
2246  }
2247 
2249  // Tests concerning writeFileToTypo3tempDir()
2251 
2256  public static function ‪invalidFilePathForTypo3tempDirDataProvider(): array
2257  {
2258  return [
2259  [
2260  ‪Environment::getPublicPath() . '/../path/this-path-has-more-than-60-characters-in-one-base-path-you-can-even-count-more',
2261  'Input filepath "' . ‪Environment::getPublicPath() . '/../path/this-path-has-more-than-60-characters-in-one-base-path-you-can-even-count-more" was generally invalid!',
2262  '',
2263  ],
2264  [
2265  ‪Environment::getPublicPath() . '/dummy/path/this-path-has-more-than-60-characters-in-one-base-path-you-can-even-count-more',
2266  '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!',
2267  '',
2268  ],
2269  [
2270  ‪Environment::getPublicPath() . '/dummy/path/this-path-has-more-than-60-characters-in-one-base-path-you-can-even-count-more',
2271  '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!',
2272  '',
2273  ],
2274  [
2275  '/dummy/path/awesome',
2276  '"/dummy/path/" was not within directory Environment::getPublicPath() + "/typo3temp/"',
2277  '',
2278  ],
2279  [
2281  '"' . ‪Environment::getLegacyConfigPath() . '/" was not within directory Environment::getPublicPath() + "/typo3temp/"',
2282  '',
2283  ],
2284  [
2285  ‪Environment::getPublicPath() . '/typo3temp/táylor/swíft',
2286  'Subdir, "táylor/", was NOT on the form "[[:alnum:]_]/+"',
2287  '',
2288  ],
2289  'Path instead of file given' => [
2290  ‪Environment::getPublicPath() . '/typo3temp/dummy/path/',
2291  'Calculated file location didn\'t match input "' . ‪Environment::getPublicPath() . '/typo3temp/dummy/path/".',
2292  ‪Environment::getPublicPath() . '/typo3temp/dummy/',
2293  ],
2294  ];
2295  }
2296 
2303  public function ‪writeFileToTypo3tempDirFailsWithInvalidPath(string $invalidFilePath, string $expectedResult, string $pathToCleanUp): void
2304  {
2305  if ($pathToCleanUp !== '') {
2306  $this->testFilesToDelete[] = $pathToCleanUp;
2307  }
2308  $result = ‪GeneralUtility::writeFileToTypo3tempDir($invalidFilePath, 'dummy content to be written');
2309  self::assertSame($result, $expectedResult);
2310  }
2311 
2316  public static function ‪validFilePathForTypo3tempDirDataProvider(): array
2317  {
2318  return [
2319  'Default text file' => [
2320  ‪Environment::getVarPath() . '/tests/paranoid/android.txt',
2321  ‪Environment::getVarPath() . '/tests/',
2322  ],
2323  'Html file extension' => [
2324  ‪Environment::getVarPath() . '/tests/karma.html',
2325  ‪Environment::getVarPath() . '/tests/',
2326  ],
2327  'No file extension' => [
2328  ‪Environment::getVarPath() . '/tests/no-surprises',
2329  ‪Environment::getVarPath() . '/tests/',
2330  ],
2331  'Deep directory' => [
2332  ‪Environment::getVarPath() . '/tests/climbing/up/the/walls',
2333  ‪Environment::getVarPath() . '/tests/',
2334  ],
2335  'File in typo3temp/var directory' => [
2336  ‪Environment::getPublicPath() . '/typo3temp/var/path/foo.txt',
2337  ‪Environment::getPublicPath() . '/typo3temp/var/path',
2338  ],
2339  ];
2340  }
2341 
2348  public function ‪writeFileToTypo3tempDirWorksWithValidPath(string $filePath, string $pathToCleanUp): void
2349  {
2350  if ($pathToCleanUp !== '') {
2351  $this->testFilesToDelete[] = $pathToCleanUp;
2352  }
2353 
2354  $dummyContent = 'Please could you stop the noise, I\'m trying to get some rest from all the unborn chicken voices in my head.';
2355 
2356  $result = ‪GeneralUtility::writeFileToTypo3tempDir($filePath, $dummyContent);
2357 
2358  self::assertNull($result);
2359  self::assertFileExists($filePath);
2360  self::assertStringEqualsFile($filePath, $dummyContent);
2361  }
2362 
2364  // Tests concerning mkdir_deep
2366 
2369  public function ‪mkdirDeepCreatesDirectory(): void
2370  {
2371  $directory = $this->‪getTestDirectory() . '/' . ‪StringUtility::getUniqueId('test_');
2372  ‪GeneralUtility::mkdir_deep($directory);
2373  self::assertDirectoryExists($directory);
2374  }
2375 
2380  {
2381  $directory = $this->‪getTestDirectory() . '/typo3temp/var/tests/' . ‪StringUtility::getUniqueId('test_');
2382  $subDirectory = $directory . '/foo';
2383  ‪GeneralUtility::mkdir_deep($subDirectory);
2384  self::assertDirectoryExists($subDirectory);
2385  }
2386 
2391  {
2392  return [
2393  'no double slash if concatenated with Environment::getPublicPath()' => ['fileadmin/testDir1'],
2394  'double slash if concatenated with Environment::getPublicPath()' => ['/fileadmin/testDir2'],
2395  ];
2396  }
2397 
2402  public function ‪mkdirDeepCreatesDirectoryWithDoubleSlashes($directoryToCreate): void
2403  {
2404  $testRoot = ‪Environment::getVarPath() . '/public/';
2405  $this->testFilesToDelete[] = $testRoot;
2406  $directory = $testRoot . $directoryToCreate;
2407  ‪GeneralUtility::mkdir_deep($directory);
2408  self::assertDirectoryExists($directory);
2409  }
2410 
2415  {
2416  if (‪Environment::isWindows()) {
2417  self::markTestSkipped(self::NO_FIX_PERMISSIONS_ON_WINDOWS);
2418  }
2419  $directory = ‪StringUtility::getUniqueId('mkdirdeeptest_');
2420  $oldUmask = umask(19);
2421  ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['folderCreateMask'] = '0777';
2422  ‪GeneralUtility::mkdir_deep(‪Environment::getVarPath() . '/tests/' . $directory);
2423  $this->testFilesToDelete[] = ‪Environment::getVarPath() . '/tests/' . $directory;
2424  clearstatcache();
2425  umask($oldUmask);
2426  self::assertEquals('777', substr(decoct(fileperms(‪Environment::getVarPath() . '/tests/' . $directory)), -3, 3));
2427  }
2428 
2433  {
2434  if (‪Environment::isWindows()) {
2435  self::markTestSkipped(self::NO_FIX_PERMISSIONS_ON_WINDOWS);
2436  }
2437  $directory = ‪StringUtility::getUniqueId('mkdirdeeptest_');
2438  $subDirectory = $directory . '/bar';
2439  ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['folderCreateMask'] = '0777';
2440  $oldUmask = umask(19);
2441  ‪GeneralUtility::mkdir_deep(‪Environment::getVarPath() . '/tests/' . $subDirectory);
2442  $this->testFilesToDelete[] = ‪Environment::getVarPath() . '/tests/' . $directory;
2443  clearstatcache();
2444  umask($oldUmask);
2445  self::assertEquals('777', substr(decoct(fileperms(‪Environment::getVarPath() . '/tests/' . $directory)), -3, 3));
2446  }
2447 
2452  {
2453  if (‪Environment::isWindows()) {
2454  self::markTestSkipped(self::NO_FIX_PERMISSIONS_ON_WINDOWS);
2455  }
2457  $existingDirectory = ‪StringUtility::getUniqueId('test_existing_') . '/';
2458  $newSubDirectory = ‪StringUtility::getUniqueId('test_new_');
2459  @mkdir(‪$baseDirectory . $existingDirectory);
2460  $this->testFilesToDelete[] = ‪$baseDirectory . $existingDirectory;
2461  chmod(‪$baseDirectory . $existingDirectory, 482);
2462  ‪GeneralUtility::mkdir_deep(‪$baseDirectory . $existingDirectory . $newSubDirectory);
2463  self::assertEquals(742, (int)substr(decoct(fileperms(‪$baseDirectory . $existingDirectory)), 2));
2464  }
2465 
2470  {
2471  $this->expectException(\RuntimeException::class);
2472  $this->expectExceptionCode(1170251401);
2473 
2474  ‪GeneralUtility::mkdir_deep('http://localhost');
2475  }
2476 
2481  {
2482  $this->expectException(\InvalidArgumentException::class);
2483  $this->expectExceptionCode(1303662955);
2484 
2485  // @phpstan-ignore-next-line We're explicitly checking the behavior for a contract violation.
2487  }
2488 
2490  // Tests concerning rmdir
2492 
2496  public function ‪rmdirRemovesFile(): void
2497  {
2498  $testRoot = ‪Environment::getVarPath() . '/tests/';
2499  $this->testFilesToDelete[] = $testRoot;
2500  ‪GeneralUtility::mkdir_deep($testRoot);
2501  $file = $testRoot . ‪StringUtility::getUniqueId('file_');
2502  touch($file);
2503  ‪GeneralUtility::rmdir($file);
2504  self::assertFileDoesNotExist($file);
2505  }
2506 
2510  public function ‪rmdirReturnTrueIfFileWasRemoved(): void
2511  {
2512  $file = $this->‪getTestDirectory() . '/' . ‪StringUtility::getUniqueId('file_');
2513  touch($file);
2514  self::assertTrue(‪GeneralUtility::rmdir($file));
2515  }
2516 
2521  {
2522  $file = ‪Environment::getVarPath() . '/tests/' . ‪StringUtility::getUniqueId('file_');
2523  self::assertFalse(‪GeneralUtility::rmdir($file));
2524  }
2525 
2529  public function ‪rmdirRemovesDirectory(): void
2530  {
2531  $directory = $this->‪getTestDirectory() . '/' . ‪StringUtility::getUniqueId('directory_');
2532  mkdir($directory);
2533  ‪GeneralUtility::rmdir($directory);
2534  self::assertFileDoesNotExist($directory);
2535  }
2536 
2541  {
2542  $directory = $this->‪getTestDirectory() . '/' . ‪StringUtility::getUniqueId('directory_') . '/';
2543  ‪GeneralUtility::mkdir_deep($directory);
2544  ‪GeneralUtility::rmdir($directory);
2545  self::assertFileDoesNotExist($directory);
2546  }
2547 
2552  {
2553  $directory = $this->‪getTestDirectory() . '/' . ‪StringUtility::getUniqueId('directory_') . '/';
2554  ‪GeneralUtility::mkdir_deep($directory);
2555  $file = ‪StringUtility::getUniqueId('file_');
2556  touch($directory . $file);
2557  $return = ‪GeneralUtility::rmdir($directory);
2558  self::assertFileExists($directory);
2559  self::assertFileExists($directory . $file);
2560  self::assertFalse($return);
2561  }
2562 
2567  {
2568  $directory = $this->‪getTestDirectory() . '/' . ‪StringUtility::getUniqueId('directory_') . '/';
2569  mkdir($directory);
2570  mkdir($directory . 'sub/');
2571  touch($directory . 'sub/file');
2572  $return = ‪GeneralUtility::rmdir($directory, true);
2573  self::assertFileDoesNotExist($directory);
2574  self::assertTrue($return);
2575  }
2576 
2580  public function ‪rmdirRemovesLinkToDirectory(): void
2581  {
2582  $existingDirectory = $this->‪getTestDirectory() . '/' . ‪StringUtility::getUniqueId('notExists_') . '/';
2583  mkdir($existingDirectory);
2584  $symlinkName = ‪Environment::getVarPath() . '/tests/' . ‪StringUtility::getUniqueId('link_');
2585  symlink($existingDirectory, $symlinkName);
2586  ‪GeneralUtility::rmdir($symlinkName, true);
2587  self::assertFalse(is_link($symlinkName));
2588  }
2589 
2593  public function ‪rmdirRemovesDeadLinkToDirectory(): void
2594  {
2595  $notExistingDirectory = $this->‪getTestDirectory() . '/' . ‪StringUtility::getUniqueId('notExists_') . '/';
2596  $symlinkName = $this->‪getTestDirectory() . '/' . ‪StringUtility::getUniqueId('link_');
2597  ‪GeneralUtility::mkdir_deep($notExistingDirectory);
2598  symlink($notExistingDirectory, $symlinkName);
2599  rmdir($notExistingDirectory);
2600 
2601  ‪GeneralUtility::rmdir($symlinkName, true);
2602  self::assertFalse(is_link($symlinkName));
2603  }
2604 
2608  public function ‪rmdirRemovesDeadLinkToFile(): void
2609  {
2610  $testDirectory = $this->‪getTestDirectory() . '/';
2611  $notExistingFile = $testDirectory . ‪StringUtility::getUniqueId('notExists_');
2612  $symlinkName = $testDirectory . ‪StringUtility::getUniqueId('link_');
2613  touch($notExistingFile);
2614  symlink($notExistingFile, $symlinkName);
2615  unlink($notExistingFile);
2616  ‪GeneralUtility::rmdir($symlinkName, true);
2617  self::assertFalse(is_link($symlinkName));
2618  }
2619 
2621  // Tests concerning getFilesInDir
2623 
2629  protected function ‪getFilesInDirCreateTestDirectory(): string
2630  {
2631  $path = ‪Environment::getVarPath() . '/FilesInDirTests';
2632  $this->testFilesToDelete[] = $path;
2633  mkdir($path);
2634  mkdir($path . '/subDirectory');
2635  file_put_contents($path . '/subDirectory/test.php', 'butter');
2636  file_put_contents($path . '/subDirectory/other.php', 'milk');
2637  file_put_contents($path . '/subDirectory/stuff.csv', 'honey');
2638  file_put_contents($path . '/excludeMe.txt', 'cocoa nibs');
2639  file_put_contents($path . '/double.setup.typoscript', 'cool TS');
2640  file_put_contents($path . '/testB.txt', 'olive oil');
2641  file_put_contents($path . '/testA.txt', 'eggs');
2642  file_put_contents($path . '/testC.txt', 'carrots');
2643  file_put_contents($path . '/test.js', 'oranges');
2644  file_put_contents($path . '/test.css', 'apples');
2645  file_put_contents($path . '/.secret.txt', 'sammon');
2646  return $path;
2647  }
2648 
2652  public function ‪getFilesInDirFindsRegularFile(): void
2653  {
2654  $path = $this->‪getFilesInDirCreateTestDirectory();
2655  $files = GeneralUtility::getFilesInDir($path);
2656  self::assertContains('testA.txt', $files);
2657  }
2658 
2662  public function ‪getFilesInDirFindsHiddenFile(): void
2663  {
2664  $path = $this->‪getFilesInDirCreateTestDirectory();
2665  $files = GeneralUtility::getFilesInDir($path);
2666  self::assertContains('.secret.txt', $files);
2667  }
2668 
2672  public static function ‪fileExtensionDataProvider(): array
2673  {
2674  return [
2675  'no space' => [
2676  'setup.typoscript,txt,js,css',
2677  ],
2678  'spaces' => [
2679  'setup.typoscript, txt, js, css',
2680  ],
2681  'mixed' => [
2682  'setup.typoscript , txt,js, css',
2683  ],
2684  'wild' => [
2685  'setup.typoscript, txt, js , css',
2686  ],
2687  ];
2688  }
2689 
2694  public function ‪getFilesInDirByExtensionFindsFiles($fileExtensions): void
2695  {
2696  $path = $this->‪getFilesInDirCreateTestDirectory();
2697  $files = GeneralUtility::getFilesInDir($path, $fileExtensions);
2698  self::assertContains('double.setup.typoscript', $files);
2699  self::assertContains('testA.txt', $files);
2700  self::assertContains('test.js', $files);
2701  self::assertContains('test.css', $files);
2702  }
2703 
2708  {
2709  $path = $this->‪getFilesInDirCreateTestDirectory();
2710  $files = GeneralUtility::getFilesInDir($path, 'txt,js');
2711  self::assertContains('testA.txt', $files);
2712  self::assertContains('test.js', $files);
2713  self::assertNotContains('test.css', $files);
2714  }
2715 
2720  {
2721  $path = $this->‪getFilesInDirCreateTestDirectory();
2722  $files = GeneralUtility::getFilesInDir($path, '', false, '', 'excludeMe.*');
2723  self::assertContains('test.js', $files);
2724  self::assertNotContains('excludeMe.txt', $files);
2725  }
2726 
2730  public function ‪getFilesInDirCanPrependPath(): void
2731  {
2732  $path = $this->‪getFilesInDirCreateTestDirectory();
2733  self::assertContains(
2734  $path . '/testA.txt',
2735  GeneralUtility::getFilesInDir($path, '', true)
2736  );
2737  }
2738 
2743  {
2744  $path = $this->‪getFilesInDirCreateTestDirectory();
2745  self::assertSame(
2746  ['.secret.txt', 'double.setup.typoscript', 'excludeMe.txt', 'test.css', 'test.js', 'testA.txt', 'testB.txt', 'testC.txt'],
2747  array_values(GeneralUtility::getFilesInDir($path))
2748  );
2749  }
2750 
2755  {
2756  $path = $this->‪getFilesInDirCreateTestDirectory();
2757  self::assertArrayHasKey(
2758  md5($path . '/testA.txt'),
2759  GeneralUtility::getFilesInDir($path)
2760  );
2761  }
2762 
2767  {
2768  $path = $this->‪getFilesInDirCreateTestDirectory();
2769  self::assertNotContains(
2770  'subDirectory',
2771  GeneralUtility::getFilesInDir($path)
2772  );
2773  }
2774 
2781  public function ‪getFilesInDirDoesNotFindDotfiles(): void
2782  {
2783  $path = $this->‪getFilesInDirCreateTestDirectory();
2784  $files = GeneralUtility::getFilesInDir($path);
2785  self::assertNotContains('..', $files);
2786  self::assertNotContains('.', $files);
2787  }
2788 
2790  // Tests concerning split_fileref
2792 
2796  {
2797  $directoryName = ‪StringUtility::getUniqueId('test_') . '.com';
2798  $directoryPath = ‪Environment::getVarPath() . '/tests/';
2799  @mkdir($directoryPath, octdec(‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['folderCreateMask']));
2800  $directory = $directoryPath . $directoryName;
2801  mkdir($directory, octdec(‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['folderCreateMask']));
2802  $fileInfo = GeneralUtility::split_fileref($directory);
2803  $directoryCreated = is_dir($directory);
2804  rmdir($directory);
2805  self::assertTrue($directoryCreated);
2806  self::assertIsArray($fileInfo);
2807  self::assertEquals($directoryPath, $fileInfo['path']);
2808  self::assertEquals($directoryName, $fileInfo['file']);
2809  self::assertEquals($directoryName, $fileInfo['filebody']);
2810  self::assertEquals('', $fileInfo['fileext']);
2811  self::assertArrayNotHasKey('realFileext', $fileInfo);
2812  }
2813 
2818  {
2819  $testFile = 'fileadmin/media/someFile.png';
2820  $fileInfo = GeneralUtility::split_fileref($testFile);
2821  self::assertIsArray($fileInfo);
2822  self::assertEquals('fileadmin/media/', $fileInfo['path']);
2823  self::assertEquals('someFile.png', $fileInfo['file']);
2824  self::assertEquals('someFile', $fileInfo['filebody']);
2825  self::assertEquals('png', $fileInfo['fileext']);
2826  }
2827 
2829  // Tests concerning dirname
2831 
2835  public static function ‪dirnameDataProvider(): array
2836  {
2837  return [
2838  'absolute path with multiple part and file' => ['/dir1/dir2/script.php', '/dir1/dir2'],
2839  'absolute path with one part' => ['/dir1/', '/dir1'],
2840  'absolute path to file without extension' => ['/dir1/something', '/dir1'],
2841  'relative path with one part and file' => ['dir1/script.php', 'dir1'],
2842  'relative one-character path with one part and file' => ['d/script.php', 'd'],
2843  'absolute zero-part path with file' => ['/script.php', ''],
2844  'empty string' => ['', ''],
2845  ];
2846  }
2847 
2854  public function ‪dirnameWithDataProvider(string $input, string $expectedValue): void
2855  {
2856  self::assertEquals($expectedValue, GeneralUtility::dirname($input));
2857  }
2858 
2860  // Tests concerning resolveBackPath
2862 
2866  public static function ‪resolveBackPathDataProvider(): array
2867  {
2868  return [
2869  'empty path' => ['', ''],
2870  'this directory' => ['./', './'],
2871  'relative directory without ..' => ['dir1/dir2/dir3/', 'dir1/dir2/dir3/'],
2872  'relative path without ..' => ['dir1/dir2/script.php', 'dir1/dir2/script.php'],
2873  'absolute directory without ..' => ['/dir1/dir2/dir3/', '/dir1/dir2/dir3/'],
2874  'absolute path without ..' => ['/dir1/dir2/script.php', '/dir1/dir2/script.php'],
2875  'only one directory upwards without trailing slash' => ['..', '..'],
2876  'only one directory upwards with trailing slash' => ['../', '../'],
2877  'one level with trailing ..' => ['dir1/..', ''],
2878  'one level with trailing ../' => ['dir1/../', ''],
2879  'two levels with trailing ..' => ['dir1/dir2/..', 'dir1'],
2880  'two levels with trailing ../' => ['dir1/dir2/../', 'dir1/'],
2881  'leading ../ without trailing /' => ['../dir1', '../dir1'],
2882  'leading ../ with trailing /' => ['../dir1/', '../dir1/'],
2883  'leading ../ and inside path' => ['../dir1/dir2/../dir3/', '../dir1/dir3/'],
2884  'one times ../ in relative directory' => ['dir1/../dir2/', 'dir2/'],
2885  'one times ../ in absolute directory' => ['/dir1/../dir2/', '/dir2/'],
2886  'one times ../ in relative path' => ['dir1/../dir2/script.php', 'dir2/script.php'],
2887  'one times ../ in absolute path' => ['/dir1/../dir2/script.php', '/dir2/script.php'],
2888  'consecutive ../' => ['dir1/dir2/dir3/../../../dir4', 'dir4'],
2889  'distributed ../ with trailing /' => ['dir1/../dir2/dir3/../', 'dir2/'],
2890  'distributed ../ without trailing /' => ['dir1/../dir2/dir3/..', 'dir2'],
2891  'multiple distributed and consecutive ../ together' => ['dir1/dir2/dir3/dir4/../../dir5/dir6/dir7/../dir8/', 'dir1/dir2/dir5/dir6/dir8/'],
2892  'dirname with leading ..' => ['dir1/..dir2/dir3/', 'dir1/..dir2/dir3/'],
2893  'dirname with trailing ..' => ['dir1/dir2../dir3/', 'dir1/dir2../dir3/'],
2894  'more times upwards than downwards in directory' => ['dir1/../../', '../'],
2895  'more times upwards than downwards in path' => ['dir1/../../script.php', '../script.php'],
2896  ];
2897  }
2898 
2905  public function ‪resolveBackPathWithDataProvider(string $input, string $expectedValue): void
2906  {
2907  self::assertEquals($expectedValue, GeneralUtility::resolveBackPath($input));
2908  }
2909 
2911  // Tests concerning makeInstance, setSingletonInstance, addInstance, purgeInstances
2913 
2917  {
2918  $this->expectException(\InvalidArgumentException::class);
2919  $this->expectExceptionCode(1288965219);
2920 
2921  // @phpstan-ignore-next-line We're explicitly checking the behavior for a contract violation.
2922  GeneralUtility::makeInstance('');
2923  }
2924 
2929  {
2930  $this->expectException(\InvalidArgumentException::class);
2931  $this->expectExceptionCode(1420281366);
2932 
2933  GeneralUtility::makeInstance('\\TYPO3\\CMS\\Backend\\Controller\\BackendController');
2934  }
2935 
2939  public function ‪makeInstanceReturnsClassInstance(): void
2940  {
2941  self::assertInstanceOf(\stdClass::class, GeneralUtility::makeInstance(\stdClass::class));
2942  }
2943 
2948  {
2949  $instance = GeneralUtility::makeInstance(TwoParametersConstructorFixture::class, 'one parameter', 'another parameter');
2950  self::assertEquals('one parameter', $instance->constructorParameter1, 'The first constructor parameter has not been set.');
2951  self::assertEquals('another parameter', $instance->constructorParameter2, 'The second constructor parameter has not been set.');
2952  }
2953 
2958  {
2959  GeneralUtility::flushInternalRuntimeCaches();
2960  ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects'][OriginalClassFixture::class] = ['className' => ReplacementClassFixture::class];
2961  self::assertInstanceOf(ReplacementClassFixture::class, GeneralUtility::makeInstance(OriginalClassFixture::class));
2962  }
2963 
2968  {
2969  GeneralUtility::flushInternalRuntimeCaches();
2970  ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects'][OriginalClassFixture::class] = ['className' => ReplacementClassFixture::class];
2971  ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects'][ReplacementClassFixture::class] = ['className' => OtherReplacementClassFixture::class];
2972  self::assertInstanceOf(OtherReplacementClassFixture::class, GeneralUtility::makeInstance(OriginalClassFixture::class));
2973  }
2974 
2979  {
2980  $className = \stdClass::class;
2981  self::assertNotSame(GeneralUtility::makeInstance($className), GeneralUtility::makeInstance($className));
2982  }
2983 
2988  {
2989  $className = get_class($this->createMock(SingletonInterface::class));
2990  self::assertSame(GeneralUtility::makeInstance($className), GeneralUtility::makeInstance($className));
2991  }
2992 
2997  {
2998  $className = get_class($this->createMock(SingletonInterface::class));
2999  $instance = GeneralUtility::makeInstance($className);
3000  GeneralUtility::purgeInstances();
3001  self::assertNotSame($instance, GeneralUtility::makeInstance($className));
3002  }
3003 
3007  public function ‪makeInstanceInjectsLogger(): void
3008  {
3009  $instance = GeneralUtility::makeInstance(GeneralUtilityMakeInstanceInjectLoggerFixture::class);
3010  self::assertInstanceOf(LoggerInterface::class, $instance->getLogger());
3011  }
3012 
3017  {
3018  $this->expectException(\InvalidArgumentException::class);
3019  $this->expectExceptionCode(1288967479);
3020 
3021  $instance = $this->createMock(SingletonInterface::class);
3022  // @phpstan-ignore-next-line We are explicitly testing with a contract violation here.
3023  GeneralUtility::setSingletonInstance('', $instance);
3024  }
3025 
3030  {
3031  $this->expectException(\InvalidArgumentException::class);
3032  $this->expectExceptionCode(1288967686);
3033 
3034  $instance = $this->getMockBuilder(SingletonInterface::class)
3035  ->addMethods(['foo'])
3036  ->getMock();
3037  $singletonClassName = get_class($this->createMock(SingletonInterface::class));
3038  GeneralUtility::setSingletonInstance($singletonClassName, $instance);
3039  }
3040 
3045  {
3046  $instance = $this->createMock(SingletonInterface::class);
3047  $singletonClassName = get_class($instance);
3048  GeneralUtility::setSingletonInstance($singletonClassName, $instance);
3049  self::assertSame($instance, GeneralUtility::makeInstance($singletonClassName));
3050  }
3051 
3056  {
3057  $instance1 = $this->createMock(SingletonInterface::class);
3058  $singletonClassName = get_class($instance1);
3059  $instance2 = new $singletonClassName();
3060  GeneralUtility::setSingletonInstance($singletonClassName, $instance1);
3061  GeneralUtility::setSingletonInstance($singletonClassName, $instance2);
3062  self::assertSame($instance2, GeneralUtility::makeInstance($singletonClassName));
3063  }
3064 
3069  {
3070  $instance = $this->createMock(SingletonInterface::class);
3071  $instanceClassName = get_class($instance);
3072  GeneralUtility::setSingletonInstance($instanceClassName, $instance);
3073  $registeredSingletonInstances = GeneralUtility::getSingletonInstances();
3074  self::assertArrayHasKey($instanceClassName, $registeredSingletonInstances);
3075  self::assertSame($registeredSingletonInstances[$instanceClassName], $instance);
3076  }
3077 
3082  {
3083  ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects'][SingletonClassFixture::class]['className'] = ExtendedSingletonClassFixture::class;
3084  $anotherInstance = new ‪ExtendedSingletonClassFixture();
3085  GeneralUtility::makeInstance(SingletonClassFixture::class);
3086  GeneralUtility::setSingletonInstance(SingletonClassFixture::class, $anotherInstance);
3087  $result = GeneralUtility::makeInstance(SingletonClassFixture::class);
3088  self::assertSame($anotherInstance, $result);
3089  self::assertEquals(ExtendedSingletonClassFixture::class, get_class($anotherInstance));
3090  }
3091 
3096  {
3097  $instance = $this->createMock(SingletonInterface::class);
3098  $instanceClassName = get_class($instance);
3099  GeneralUtility::setSingletonInstance($instanceClassName, $instance);
3100  GeneralUtility::resetSingletonInstances([]);
3101  $registeredSingletonInstances = GeneralUtility::getSingletonInstances();
3102  self::assertArrayNotHasKey($instanceClassName, $registeredSingletonInstances);
3103  }
3104 
3109  {
3110  $instance = $this->createMock(SingletonInterface::class);
3111  $instanceClassName = get_class($instance);
3112  GeneralUtility::resetSingletonInstances(
3113  [$instanceClassName => $instance]
3114  );
3115  $registeredSingletonInstances = GeneralUtility::getSingletonInstances();
3116  self::assertArrayHasKey($instanceClassName, $registeredSingletonInstances);
3117  self::assertSame($registeredSingletonInstances[$instanceClassName], $instance);
3118  }
3119 
3124  {
3125  $this->expectException(\InvalidArgumentException::class);
3126  $this->expectExceptionCode(1288967479);
3127 
3128  // @phpstan-ignore-next-line We are explicitly testing with a contract violation here.
3129  GeneralUtility::addInstance('', new \stdClass());
3130  }
3131 
3136  {
3137  $this->expectException(\InvalidArgumentException::class);
3138  $this->expectExceptionCode(1288967686);
3139 
3140  $instance = $this->getMockBuilder(\stdClass::class)
3141  ->addMethods(['bar'])
3142  ->getMock();
3143  $singletonClassName = get_class($this->createMock(\stdClass::class));
3144  GeneralUtility::addInstance($singletonClassName, $instance);
3145  }
3146 
3151  {
3152  $this->expectException(\InvalidArgumentException::class);
3153  $this->expectExceptionCode(1288969325);
3154 
3155  $instance = $this->createMock(SingletonInterface::class);
3156  GeneralUtility::addInstance(get_class($instance), $instance);
3157  }
3158 
3163  {
3164  $instance = $this->createMock(\stdClass::class);
3165  $className = get_class($instance);
3166  GeneralUtility::addInstance($className, $instance);
3167  self::assertSame($instance, GeneralUtility::makeInstance($className));
3168  }
3169 
3174  {
3175  $instance = $this->createMock(\stdClass::class);
3176  $className = get_class($instance);
3177  GeneralUtility::addInstance($className, $instance);
3178  self::assertNotSame(GeneralUtility::makeInstance($className), GeneralUtility::makeInstance($className));
3179  }
3180 
3185  {
3186  $instance1 = $this->createMock(\stdClass::class);
3187  $className = get_class($instance1);
3188  GeneralUtility::addInstance($className, $instance1);
3189  $instance2 = new $className();
3190  GeneralUtility::addInstance($className, $instance2);
3191  self::assertSame($instance1, GeneralUtility::makeInstance($className), 'The first returned instance does not match the first added instance.');
3192  self::assertSame($instance2, GeneralUtility::makeInstance($className), 'The second returned instance does not match the second added instance.');
3193  }
3194 
3198  public function ‪purgeInstancesDropsAddedInstance(): void
3199  {
3200  $instance = $this->createMock(\stdClass::class);
3201  $className = get_class($instance);
3202  GeneralUtility::addInstance($className, $instance);
3203  GeneralUtility::purgeInstances();
3204  self::assertNotSame($instance, GeneralUtility::makeInstance($className));
3205  }
3206 
3207  public static function ‪getFileAbsFileNameDataProvider(): array
3208  {
3209  return [
3210  'relative path is prefixed with public path' => [
3211  'fileadmin/foo.txt',
3212  ‪Environment::getPublicPath() . '/fileadmin/foo.txt',
3213  ],
3214  'relative path, referencing current directory is prefixed with public path' => [
3215  './fileadmin/foo.txt',
3216  ‪Environment::getPublicPath() . '/./fileadmin/foo.txt',
3217  ],
3218  'relative paths with back paths are not allowed and returned empty' => [
3219  '../fileadmin/foo.txt',
3220  '',
3221  ],
3222  'absolute paths with back paths are not allowed and returned empty' => [
3223  ‪Environment::getPublicPath() . '/../sysext/core/Resources/Public/Icons/Extension.png',
3224  '',
3225  ],
3226  'allowed absolute paths are returned as is' => [
3227  ‪Environment::getPublicPath() . '/fileadmin/foo.txt',
3228  ‪Environment::getPublicPath() . '/fileadmin/foo.txt',
3229  ],
3230  'disallowed absolute paths are returned empty' => [
3231  '/somewhere/fileadmin/foo.txt',
3232  '',
3233  ],
3234  'EXT paths are resolved to absolute paths' => [
3235  'EXT:foo/Resources/Private/Templates/Home.html',
3236  '/path/to/foo/Resources/Private/Templates/Home.html',
3237  ],
3238  ];
3239  }
3240 
3245  public function ‪getFileAbsFileNameReturnsCorrectValues(string $path, string $expected): void
3246  {
3247  // build the dummy package "foo" for use in ExtensionManagementUtility::extPath('foo');
3248  $package = $this->getMockBuilder(Package::class)
3249  ->disableOriginalConstructor()
3250  ->onlyMethods(['getPackagePath'])
3251  ->getMock();
3252  $packageManager = $this->getMockBuilder(PackageManager::class)
3253  ->onlyMethods(['isPackageActive', 'getPackage', 'getActivePackages'])
3254  ->disableOriginalConstructor()
3255  ->getMock();
3256  $package
3257  ->method('getPackagePath')
3258  ->willReturn('/path/to/foo/');
3259  $packageManager
3260  ->method('getActivePackages')
3261  ->willReturn(['foo' => $package]);
3262  $packageManager
3263  ->method('isPackageActive')
3264  ->with(self::equalTo('foo'))
3265  ->willReturn(true);
3266  $packageManager
3267  ->method('getPackage')
3268  ->with('foo')
3269  ->willReturn($package);
3271 
3272  $result = GeneralUtility::getFileAbsFileName($path);
3273  self::assertEquals($expected, $result);
3274  }
3275 
3279  public static function ‪validPathStrInvalidCharactersDataProvider(): array
3280  {
3281  $data = [
3282  'double slash in path' => ['path//path'],
3283  'backslash in path' => ['path\\path'],
3284  'directory up in path' => ['path/../path'],
3285  'directory up at the beginning' => ['../path'],
3286  'NUL character in path' => ['path' . "\0" . 'path'],
3287  'BS character in path' => ['path' . chr(8) . 'path'],
3288  'invalid UTF-8-sequence' => ["\xc0" . 'path/path'],
3289  'Could be overlong NUL in some UTF-8 implementations, invalid in RFC3629' => ["\xc0\x80" . 'path/path'],
3290  ];
3291 
3292  // Mixing with regular utf-8
3293  $utf8Characters = 'Ссылка/';
3294  foreach ($data as $key => $value) {
3295  $data[$key . ' with UTF-8 characters prepended'] = [$utf8Characters . $value[0]];
3296  $data[$key . ' with UTF-8 characters appended'] = [$value[0] . $utf8Characters];
3297  }
3298 
3299  // Encoding with UTF-16
3300  foreach ($data as $key => $value) {
3301  $data[$key . ' encoded with UTF-16'] = [mb_convert_encoding($value[0], 'UTF-16')];
3302  }
3303 
3304  return $data;
3305  }
3306 
3313  public function ‪validPathStrDetectsInvalidCharacters(string $path): void
3314  {
3315  self::assertFalse(GeneralUtility::validPathStr($path));
3316  }
3317 
3321  public static function ‪validPathStrDataProvider(): array
3322  {
3323  $data = [
3324  'normal ascii path' => ['fileadmin/templates/myfile..xml'],
3325  'special character' => ['fileadmin/templates/Ссылка (fce).xml'],
3326  ];
3327 
3328  return $data;
3329  }
3330 
3337  public function ‪validPathStrWorksWithUnicodeFileNames($path): void
3338  {
3339  self::assertTrue(GeneralUtility::validPathStr($path));
3340  }
3341 
3343  // Tests concerning copyDirectory
3345 
3350  {
3351  $sourceDirectory = 'typo3temp/var/tests/' . ‪StringUtility::getUniqueId('test_') . '/';
3352  $absoluteSourceDirectory = ‪Environment::getPublicPath() . '/' . $sourceDirectory;
3353  $this->testFilesToDelete[] = $absoluteSourceDirectory;
3354  ‪GeneralUtility::mkdir($absoluteSourceDirectory);
3355 
3356  $targetDirectory = 'typo3temp/var/tests/' . ‪StringUtility::getUniqueId('test_') . '/';
3357  $absoluteTargetDirectory = ‪Environment::getPublicPath() . '/' . $targetDirectory;
3358  $this->testFilesToDelete[] = $absoluteTargetDirectory;
3359 
3360  ‪GeneralUtility::writeFileToTypo3tempDir($absoluteSourceDirectory . 'file', '42');
3361  ‪GeneralUtility::mkdir($absoluteSourceDirectory . 'foo');
3362  ‪GeneralUtility::writeFileToTypo3tempDir($absoluteSourceDirectory . 'foo/file', '42');
3363 
3364  GeneralUtility::copyDirectory($sourceDirectory, $targetDirectory);
3365 
3366  self::assertFileExists($absoluteTargetDirectory . 'file');
3367  self::assertFileExists($absoluteTargetDirectory . 'foo/file');
3368  }
3369 
3374  {
3375  $sourceDirectory = 'typo3temp/var/tests/' . ‪StringUtility::getUniqueId('test_') . '/';
3376  $absoluteSourceDirectory = ‪Environment::getPublicPath() . '/' . $sourceDirectory;
3377  $this->testFilesToDelete[] = $absoluteSourceDirectory;
3378  ‪GeneralUtility::mkdir($absoluteSourceDirectory);
3379 
3380  $targetDirectory = 'typo3temp/var/tests/' . ‪StringUtility::getUniqueId('test_') . '/';
3381  $absoluteTargetDirectory = ‪Environment::getPublicPath() . '/' . $targetDirectory;
3382  $this->testFilesToDelete[] = $absoluteTargetDirectory;
3383 
3384  ‪GeneralUtility::writeFileToTypo3tempDir($absoluteSourceDirectory . 'file', '42');
3385  ‪GeneralUtility::mkdir($absoluteSourceDirectory . 'foo');
3386  ‪GeneralUtility::writeFileToTypo3tempDir($absoluteSourceDirectory . 'foo/file', '42');
3387 
3388  GeneralUtility::copyDirectory($absoluteSourceDirectory, $absoluteTargetDirectory);
3389 
3390  self::assertFileExists($absoluteTargetDirectory . 'file');
3391  self::assertFileExists($absoluteTargetDirectory . 'foo/file');
3392  }
3393 
3394  public static function ‪callUserFunctionInvalidParameterDataProvider(): array
3395  {
3396  return [
3397  'Method does not exist' => [GeneralUtilityTestClass::class . '->calledUserFunction', 1294585865],
3398  'Class does not exist' => ['t3lib_divTest21345->user_calledUserFunction', 1294585866],
3399  'No method name' => [GeneralUtilityTestClass::class, 1294585867],
3400  'No class name' => ['->user_calledUserFunction', 1294585866],
3401  'No function name' => ['', 1294585867],
3402  ];
3403  }
3404 
3410  public function ‪callUserFunctionWillThrowExceptionForInvalidParameters(string $functionName, int $expectedException): void
3411  {
3412  $this->expectException(\InvalidArgumentException::class);
3413  $this->expectExceptionCode($expectedException);
3414  $inputData = ['foo' => 'bar'];
3415  GeneralUtility::callUserFunction($functionName, $inputData, $this);
3416  }
3417 
3421  public function ‪callUserFunctionCanCallClosure(): void
3422  {
3423  $inputData = ['foo' => 'bar'];
3424  $result = GeneralUtility::callUserFunction(
3425  static fn (): string => 'Worked fine',
3426  $inputData,
3427  $this,
3428  ''
3429  );
3430  self::assertEquals('Worked fine', $result);
3431  }
3432 
3436  public function ‪callUserFunctionCanCallMethod(): void
3437  {
3438  $inputData = ['foo' => 'bar'];
3439  $result = GeneralUtility::callUserFunction(GeneralUtilityTestClass::class . '->user_calledUserFunction', $inputData, $this);
3440  self::assertEquals('Worked fine', $result);
3441  }
3442 
3446  public function ‪callUserFunctionTrimsSpaces(): void
3447  {
3448  $inputData = ['foo' => 'bar'];
3449  $result = GeneralUtility::callUserFunction("\t" . GeneralUtilityTestClass::class . '->user_calledUserFunction ', $inputData, $this);
3450  self::assertEquals('Worked fine', $result);
3451  }
3452 
3456  public function ‪callUserFunctionAcceptsClosures(): void
3457  {
3458  $inputData = ['foo' => 'bar'];
3459  $closure = static function ($parameters, $reference) use ($inputData) {
3460  $reference->assertEquals($inputData, $parameters, 'Passed data does not match expected output');
3461  return 'Worked fine';
3462  };
3463  self::assertEquals('Worked fine', GeneralUtility::callUserFunction($closure, $inputData, $this));
3464  }
3465 
3470  {
3471  $directory = $this->‪getTestDirectory() . '/' . ‪StringUtility::getUniqueId('directory_');
3472  mkdir($directory);
3473  $filesAndDirectories = GeneralUtility::getAllFilesAndFoldersInPath([], $directory, '', true);
3474  $check = true;
3475  foreach ($filesAndDirectories as $md5 => $path) {
3476  if (!preg_match('/^[a-f0-9]{32}$/', $md5)) {
3477  $check = false;
3478  }
3479  }
3480  ‪GeneralUtility::rmdir($directory);
3481  self::assertTrue($check);
3482  }
3483 
3491  {
3492  $input = [
3493  'el' => [],
3494  ];
3495 
3496  ‪$output = GeneralUtility::array2xml($input);
3497 
3498  self::assertEquals('<phparray>
3499  <el type="array"></el>
3500 </phparray>', ‪$output);
3501  }
3502 
3506  public function ‪xml2arrayUsesCache(): void
3507  {
3508  $cacheMock = $this->createMock(FrontendInterface::class);
3509  $cacheMock->method('getIdentifier')->willReturn('runtime');
3510  $cacheMock->expects(self::atLeastOnce())->method('get')->with('generalUtilityXml2Array')->willReturn(false);
3511  $cacheMock->expects(self::atLeastOnce())->method('set')->with('generalUtilityXml2Array', self::anything());
3512  $cacheManager = new ‪CacheManager();
3513  $cacheManager->registerCache($cacheMock);
3514  GeneralUtility::setSingletonInstance(CacheManager::class, $cacheManager);
3515  ‪GeneralUtility::xml2array('<?xml version="1.0" encoding="utf-8" standalone="yes"?>', 'T3:');
3516  }
3517 
3522  {
3523  $headerVariants = [
3524  'utf-8' => '<?xml version="1.0" encoding="utf-8" standalone="yes"?>',
3525  'UTF-8' => '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>',
3526  'no-encoding' => '<?xml version="1.0" standalone="yes"?>',
3527  'iso-8859-1' => '<?xml version="1.0" encoding="iso-8859-1" standalone="yes"?>',
3528  'ISO-8859-1' => '<?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?>',
3529  ];
3530  $data = [];
3531  foreach ($headerVariants as ‪$identifier => $headerVariant) {
3532  $data += [
3533  'inputWithoutWhitespaces-' . ‪$identifier => [
3534  $headerVariant . '<T3FlexForms>
3535  <data>
3536  <field index="settings.persistenceIdentifier">
3537  <value index="vDEF">egon</value>
3538  </field>
3539  </data>
3540  </T3FlexForms>',
3541  ],
3542  'inputWithPrecedingWhitespaces-' . ‪$identifier => [
3543  CR . ' ' . $headerVariant . '<T3FlexForms>
3544  <data>
3545  <field index="settings.persistenceIdentifier">
3546  <value index="vDEF">egon</value>
3547  </field>
3548  </data>
3549  </T3FlexForms>',
3550  ],
3551  'inputWithTrailingWhitespaces-' . ‪$identifier => [
3552  $headerVariant . '<T3FlexForms>
3553  <data>
3554  <field index="settings.persistenceIdentifier">
3555  <value index="vDEF">egon</value>
3556  </field>
3557  </data>
3558  </T3FlexForms>' . CR . ' ',
3559  ],
3560  'inputWithPrecedingAndTrailingWhitespaces-' . ‪$identifier => [
3561  CR . ' ' . $headerVariant . '<T3FlexForms>
3562  <data>
3563  <field index="settings.persistenceIdentifier">
3564  <value index="vDEF">egon</value>
3565  </field>
3566  </data>
3567  </T3FlexForms>' . CR . ' ',
3568  ],
3569  ];
3570  }
3571  return $data;
3572  }
3573 
3578  public function ‪xml2arrayProcessHandlesWhitespaces(string $input): void
3579  {
3580  $expected = [
3581  'data' => [
3582  'settings.persistenceIdentifier' => [
3583  'vDEF' => 'egon',
3584  ],
3585  ],
3586  ];
3587  self::assertSame($expected, ‪GeneralUtility::xml2arrayProcess($input));
3588  }
3589 
3594  {
3595  return [
3596  'inputWithNameSpaceOnRootLevel' => [
3597  '<?xml version="1.0" encoding="utf-8" standalone="yes"?>
3598  <T3:T3FlexForms>
3599  <data>
3600  <field index="settings.persistenceIdentifier">
3601  <value index="vDEF">egon</value>
3602  </field>
3603  </data>
3604  </T3:T3FlexForms>',
3605  ],
3606  'inputWithNameSpaceOnNonRootLevel' => [
3607  '<?xml version="1.0" encoding="utf-8" standalone="yes"?>
3608  <T3FlexForms>
3609  <data>
3610  <T3:field index="settings.persistenceIdentifier">
3611  <value index="vDEF">egon</value>
3612  </T3:field>
3613  </data>
3614  </T3FlexForms>',
3615  ],
3616  'inputWithNameSpaceOnRootAndNonRootLevel' => [
3617  '<?xml version="1.0" encoding="utf-8" standalone="yes"?>
3618  <T3:T3FlexForms>
3619  <data>
3620  <T3:field index="settings.persistenceIdentifier">
3621  <value index="vDEF">egon</value>
3622  </T3:field>
3623  </data>
3624  </T3:T3FlexForms>',
3625  ],
3626  ];
3627  }
3628 
3633  public function ‪xml2arrayProcessHandlesTagNamespaces(string $input): void
3634  {
3635  $expected = [
3636  'data' => [
3637  'settings.persistenceIdentifier' => [
3638  'vDEF' => 'egon',
3639  ],
3640  ],
3641  ];
3642  self::assertSame($expected, ‪GeneralUtility::xml2arrayProcess($input, 'T3:'));
3643  }
3644 
3649  {
3650  return [
3651  'input' => [
3652  '<?xml version="1.0" encoding="utf-8" standalone="yes"?>
3653  <T3FlexForms>
3654  <data>
3655  <field index="settings.persistenceIdentifier">
3656  <value index="vDEF">egon</value>
3657  </field>
3658  </data>
3659  </T3FlexForms>',
3660  'T3FlexForms',
3661  ],
3662  'input-with-root-namespace' => [
3663  '<?xml version="1.0" encoding="utf-8" standalone="yes"?>
3664  <T3:T3FlexForms>
3665  <data>
3666  <field index="settings.persistenceIdentifier">
3667  <value index="vDEF">egon</value>
3668  </field>
3669  </data>
3670  </T3:T3FlexForms>',
3671  'T3:T3FlexForms',
3672  ],
3673  'input-with-namespace' => [
3674  '<?xml version="1.0" encoding="utf-8" standalone="yes"?>
3675  <T3FlexForms>
3676  <data>
3677  <T3:field index="settings.persistenceIdentifier">
3678  <value index="vDEF">egon</value>
3679  </T3:field>
3680  </data>
3681  </T3FlexForms>',
3682  'T3FlexForms',
3683  ],
3684  ];
3685  }
3686 
3691  public function ‪xml2arrayProcessHandlesDocumentTag(string $input, string $docTag): void
3692  {
3693  $expected = [
3694  'data' => [
3695  'settings.persistenceIdentifier' => [
3696  'vDEF' => 'egon',
3697  ],
3698  ],
3699  '_DOCUMENT_TAG' => $docTag,
3700  ];
3701  self::assertSame($expected, ‪GeneralUtility::xml2arrayProcess($input, '', true));
3702  }
3703 
3708  {
3709  return [
3710  '1mb' => [
3711  '<?xml version="1.0" encoding="utf-8" standalone="yes"?>
3712  <T3:T3FlexForms>
3713  <data>
3714  <field index="settings.persistenceIdentifier">
3715  <value index="vDEF">' . str_repeat('1', 1024 * 1024) . '</value>
3716  </field>
3717  </data>
3718  </T3:T3FlexForms>',
3719  str_repeat('1', 1024 * 1024),
3720  ],
3721  '5mb' => [
3722  '<?xml version="1.0" encoding="utf-8" standalone="yes"?>
3723  <T3:T3FlexForms>
3724  <data>
3725  <field index="settings.persistenceIdentifier">
3726  <value index="vDEF">' . str_repeat('1', 5 * 1024 * 1024) . '</value>
3727  </field>
3728  </data>
3729  </T3:T3FlexForms>',
3730  str_repeat('1', 5 * 1024 * 1024),
3731  ],
3732  ];
3733  }
3734 
3739  public function ‪xml2ArrayProcessHandlesBigXmlContent(string $input, string $testValue): void
3740  {
3741  $expected = [
3742  'data' => [
3743  'settings.persistenceIdentifier' => [
3744  'vDEF' => $testValue,
3745  ],
3746  ],
3747  ];
3748  self::assertSame($expected, ‪GeneralUtility::xml2arrayProcess($input));
3749  }
3750 
3755  {
3756  $prefix = '<?xml version="1.0" encoding="utf-8" standalone="yes"?><T3FlexForms><field index="index">';
3757  $suffix = '</field></T3FlexForms>';
3758  return [
3759  'no-type string' => [
3760  $prefix . '<value index="vDEF">foo bar</value>' . $suffix,
3761  'foo bar',
3762  ],
3763  'no-type integer' => [
3764  $prefix . '<value index="vDEF">123</value>' . $suffix,
3765  '123',
3766  ],
3767  'no-type double' => [
3768  $prefix . '<value index="vDEF">1.23</value>' . $suffix,
3769  '1.23',
3770  ],
3771  'integer integer' => [
3772  $prefix . '<value index="vDEF" type="integer">123</value>' . $suffix,
3773  123,
3774  ],
3775  'integer double' => [
3776  $prefix . '<value index="vDEF" type="integer">1.23</value>' . $suffix,
3777  1,
3778  ],
3779  'double integer' => [
3780  $prefix . '<value index="vDEF" type="double">123</value>' . $suffix,
3781  123.0,
3782  ],
3783  'double double' => [
3784  $prefix . '<value index="vDEF" type="double">1.23</value>' . $suffix,
3785  1.23,
3786  ],
3787  'boolean 0' => [
3788  $prefix . '<value index="vDEF" type="boolean">0</value>' . $suffix,
3789  false,
3790  ],
3791  'boolean 1' => [
3792  $prefix . '<value index="vDEF" type="boolean">1</value>' . $suffix,
3793  true,
3794  ],
3795  'boolean true' => [
3796  $prefix . '<value index="vDEF" type="boolean">true</value>' . $suffix,
3797  true,
3798  ],
3799  'boolean false' => [
3800  $prefix . '<value index="vDEF" type="boolean">false</value>' . $suffix,
3801  true, // sic(!)
3802  ],
3803  'NULL' => [
3804  $prefix . '<value index="vDEF" type="NULL"></value>' . $suffix,
3805  null,
3806  ],
3807  'NULL string' => [
3808  $prefix . '<value index="vDEF" type="NULL">foo bar</value>' . $suffix,
3809  null,
3810  ],
3811  'NULL integer' => [
3812  $prefix . '<value index="vDEF" type="NULL">123</value>' . $suffix,
3813  null,
3814  ],
3815  'NULL double' => [
3816  $prefix . '<value index="vDEF" type="NULL">1.23</value>' . $suffix,
3817  null,
3818  ],
3819  'array' => [
3820  $prefix . '<value index="vDEF" type="array"></value>' . $suffix,
3821  [],
3822  ],
3823  ];
3824  }
3825 
3830  public function ‪xml2ArrayProcessHandlesAttributeTypes(string $input, mixed $expected): void
3831  {
3832  $result = ‪GeneralUtility::xml2arrayProcess($input);
3833  self::assertSame($expected, $result['index']['vDEF']);
3834  }
3835 
3836  public static function ‪locationHeaderUrlDataProvider(): array
3837  {
3838  return [
3839  'simple relative path' => [
3840  'foo',
3841  'foo.bar.test',
3842  'http://foo.bar.test/foo',
3843  ],
3844  'path beginning with slash' => [
3845  '/foo',
3846  'foo.bar.test',
3847  'http://foo.bar.test/foo',
3848  ],
3849  'path with full domain and https scheme' => [
3850  'https://example.com/foo',
3851  'foo.bar.test',
3852  'https://example.com/foo',
3853  ],
3854  'path with full domain and http scheme' => [
3855  'http://example.com/foo',
3856  'foo.bar.test',
3857  'http://example.com/foo',
3858  ],
3859  'path with full domain and relative scheme' => [
3860  '//example.com/foo',
3861  'foo.bar.test',
3862  '//example.com/foo',
3863  ],
3864  ];
3865  }
3866 
3872  public function ‪locationHeaderUrl(string $path, string $host, string $expected): void
3873  {
3876  true,
3877  false,
3883  ‪Environment::isWindows() ? 'WINDOWS' : 'UNIX'
3884  );
3885  $_SERVER['HTTP_HOST'] = $host;
3886  $_SERVER['SCRIPT_NAME'] = '/index.php';
3887  $result = GeneralUtility::locationHeaderUrl($path);
3888  self::assertSame($expected, $result);
3889  }
3890 
3895  {
3896  ‪$GLOBALS['TYPO3_CONF_VARS']['BE']['versionNumberInFilename'] = true;
3897 
3898  $uniqueFilename = ‪StringUtility::getUniqueId() . 'backend';
3899  $testFileDirectory = ‪Environment::getVarPath() . '/tests/';
3900  $testFilepath = $testFileDirectory . $uniqueFilename . '.css';
3901  $this->testFilesToDelete[] = $testFilepath;
3902  ‪GeneralUtility::mkdir_deep($testFileDirectory);
3903  touch($testFilepath);
3904 
3905  $versionedFilename = GeneralUtility::createVersionNumberedFilename($testFilepath);
3906 
3907  self::assertMatchesRegularExpression('/^.*\/tests\/' . $uniqueFilename . '\.[0-9]+\.css/', $versionedFilename);
3908  }
3909 
3914  {
3917  true,
3918  false,
3923  ‪Environment::getPublicPath() . '/index.php',
3924  ‪Environment::isWindows() ? 'WINDOWS' : 'UNIX'
3925  );
3926  $request = new ‪ServerRequest('https://www.example.com', 'GET');
3927  ‪$GLOBALS['TYPO3_REQUEST'] = $request->withAttribute('applicationType', ‪SystemEnvironmentBuilder::REQUESTTYPE_FE);
3928  $uniqueFilename = ‪StringUtility::getUniqueId('main_');
3929  $testFileDirectory = ‪Environment::getPublicPath() . '/static/';
3930  $testFilepath = $testFileDirectory . $uniqueFilename . '.css';
3931  ‪GeneralUtility::mkdir_deep($testFileDirectory);
3932  touch($testFilepath);
3933 
3934  ‪$GLOBALS['TYPO3_CONF_VARS']['FE']['versionNumberInFilename'] = 'querystring';
3935  $incomingFileName = '/' . ‪PathUtility::stripPathSitePrefix($testFilepath);
3936  $versionedFilename = GeneralUtility::createVersionNumberedFilename($incomingFileName);
3937  self::assertStringContainsString('.css?', $versionedFilename);
3938  self::assertStringStartsWith('/static/main_', $versionedFilename);
3939 
3940  $incomingFileName = ‪PathUtility::stripPathSitePrefix($testFilepath);
3941  $versionedFilename = GeneralUtility::createVersionNumberedFilename($incomingFileName);
3942  self::assertStringContainsString('.css?', $versionedFilename);
3943  self::assertStringStartsWith('static/main_', $versionedFilename);
3944 
3945  ‪GeneralUtility::rmdir($testFileDirectory, true);
3946  }
3947 }
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\resolveBackPathWithDataProvider
‪resolveBackPathWithDataProvider(string $input, string $expectedValue)
Definition: GeneralUtilityTest.php:2905
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\formatSizeDataProvider
‪static formatSizeDataProvider()
Definition: GeneralUtilityTest.php:483
‪TYPO3\CMS\Core\Utility\GeneralUtility\underscoredToLowerCamelCase
‪static string underscoredToLowerCamelCase($string)
Definition: GeneralUtility.php:755
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\cmpFqdnInvalidDataProvider
‪static array cmpFqdnInvalidDataProvider()
Definition: GeneralUtilityTest.php:366
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\validEmailValidDataProvider
‪static array validEmailValidDataProvider()
Definition: GeneralUtilityTest.php:579
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\jsonEncodeForHtmlAttributeTestDataProvider
‪static jsonEncodeForHtmlAttributeTestDataProvider()
Definition: GeneralUtilityTest.php:1887
‪TYPO3\CMS\Core\Utility\GeneralUtility\trimExplode
‪static list< string > trimExplode($delim, $string, $removeEmptyValues=false, $limit=0)
Definition: GeneralUtility.php:916
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\xml2arrayProcessHandlesDocumentTag
‪xml2arrayProcessHandlesDocumentTag(string $input, string $docTag)
Definition: GeneralUtilityTest.php:3691
‪TYPO3\CMS\Core\Utility\GeneralUtility\xml2array
‪static mixed xml2array($string, $NSprefix='', $reportDocTag=false)
Definition: GeneralUtility.php:1363
‪TYPO3\CMS\Core\Utility\GeneralUtility\validIP
‪static bool validIP($ip)
Definition: GeneralUtility.php:413
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\createVersionNumberedFilenameDoesNotResolveBackpathForAbsolutePath
‪createVersionNumberedFilenameDoesNotResolveBackpathForAbsolutePath()
Definition: GeneralUtilityTest.php:3894
‪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:2967
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\getSingletonInstancesContainsPreviouslySetSingletonInstance
‪getSingletonInstancesContainsPreviouslySetSingletonInstance()
Definition: GeneralUtilityTest.php:3068
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\fileExtensionDataProvider
‪static fileExtensionDataProvider()
Definition: GeneralUtilityTest.php:2672
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\rmdirDoesNotRemoveDirectoryWithFilesAndReturnsFalseIfRecursiveDeletionIsOff
‪rmdirDoesNotRemoveDirectoryWithFilesAndReturnsFalseIfRecursiveDeletionIsOff()
Definition: GeneralUtilityTest.php:2551
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\xml2ArrayProcessHandlesBigXmlContent
‪xml2ArrayProcessHandlesBigXmlContent(string $input, string $testValue)
Definition: GeneralUtilityTest.php:3739
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\underscoredToLowerCamelCase
‪underscoredToLowerCamelCase($expected, $inputString)
Definition: GeneralUtilityTest.php:1203
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\jsonEncodeForJavaScriptTest
‪jsonEncodeForJavaScriptTest($value, string $expectation)
Definition: GeneralUtilityTest.php:1938
‪TYPO3\CMS\Core\Utility\PathUtility
Definition: PathUtility.php:27
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\cmpIPv6DataProviderNotMatching
‪static array cmpIPv6DataProviderNotMatching()
Definition: GeneralUtilityTest.php:222
‪TYPO3\CMS\Core\Tests\Unit\Utility\Fixtures\GeneralUtilityFilesystemFixture\writeFileToTypo3tempDir
‪static writeFileToTypo3tempDir($filepath, $content)
Definition: GeneralUtilityFilesystemFixture.php:51
‪TYPO3\CMS\Core\Tests\Unit\Utility\Fixtures\GeneralUtilityMakeInstanceInjectLoggerFixture
Definition: GeneralUtilityMakeInstanceInjectLoggerFixture.php:28
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\getFilesInDirReturnsArrayWithMd5OfElementAndPathAsArrayKey
‪getFilesInDirReturnsArrayWithMd5OfElementAndPathAsArrayKey()
Definition: GeneralUtilityTest.php:2754
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\implodeArrayForUrlCanSkipEmptyParameters
‪implodeArrayForUrlCanSkipEmptyParameters()
Definition: GeneralUtilityTest.php:724
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\sanitizeLocalUrlAcceptsNotEncodedValidPaths
‪sanitizeLocalUrlAcceptsNotEncodedValidPaths(string $path)
Definition: GeneralUtilityTest.php:1366
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\xml2ArrayProcessHandlesAttributeTypesDataProvider
‪static array[] xml2ArrayProcessHandlesAttributeTypesDataProvider()
Definition: GeneralUtilityTest.php:3754
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\makeInstanceWithBeginningSlashInClassNameThrowsException
‪makeInstanceWithBeginningSlashInClassNameThrowsException()
Definition: GeneralUtilityTest.php:2928
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\copyDirectoryCopiesFilesAndDirectoriesWithRelativePaths
‪copyDirectoryCopiesFilesAndDirectoriesWithRelativePaths()
Definition: GeneralUtilityTest.php:3349
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\validIpReturnsTrueForValidIp
‪validIpReturnsTrueForValidIp($ip)
Definition: GeneralUtilityTest.php:296
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\array2xmlConvertsEmptyArraysToElementWithoutContent
‪array2xmlConvertsEmptyArraysToElementWithoutContent()
Definition: GeneralUtilityTest.php:3490
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\cmpFqdnReturnsTrue
‪cmpFqdnReturnsTrue($baseHost, $list)
Definition: GeneralUtilityTest.php:356
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\validEmailInvalidDataProvider
‪static array validEmailInvalidDataProvider()
Definition: GeneralUtilityTest.php:615
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\invalidIpDataProvider
‪static array invalidIpDataProvider()
Definition: GeneralUtilityTest.php:306
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\hmacReturnsEqualHashesForEqualInput
‪hmacReturnsEqualHashesForEqualInput()
Definition: GeneralUtilityTest.php:1809
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\mkdirCreatesHiddenDirectory
‪mkdirCreatesHiddenDirectory()
Definition: GeneralUtilityTest.php:2209
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\validPathStrInvalidCharactersDataProvider
‪static validPathStrInvalidCharactersDataProvider()
Definition: GeneralUtilityTest.php:3279
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\validFilePathForTypo3tempDirDataProvider
‪static validFilePathForTypo3tempDirDataProvider()
Definition: GeneralUtilityTest.php:2316
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\hmacReturnsNoEqualHashesForNonEqualInput
‪hmacReturnsNoEqualHashesForNonEqualInput()
Definition: GeneralUtilityTest.php:1819
‪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\htmlspecialcharsDecodeReturnsDecodedString
‪htmlspecialcharsDecodeReturnsDecodedString()
Definition: GeneralUtilityTest.php:563
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\rmdirRemovesDirectoriesRecursiveAndReturnsTrue
‪rmdirRemovesDirectoriesRecursiveAndReturnsTrue()
Definition: GeneralUtilityTest.php:2566
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\resolveBackPathDataProvider
‪static array array[] resolveBackPathDataProvider()
Definition: GeneralUtilityTest.php:2866
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\locationHeaderUrl
‪locationHeaderUrl(string $path, string $host, string $expected)
Definition: GeneralUtilityTest.php:3872
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\revExplodeDataProvider
‪static revExplodeDataProvider()
Definition: GeneralUtilityTest.php:763
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\getAllFilesAndFoldersInPathReturnsArrayWithMd5Keys
‪getAllFilesAndFoldersInPathReturnsArrayWithMd5Keys()
Definition: GeneralUtilityTest.php:3469
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\mkdirDeepCreatesDirectoryWithDoubleSlashes
‪mkdirDeepCreatesDirectoryWithDoubleSlashes($directoryToCreate)
Definition: GeneralUtilityTest.php:2402
‪TYPO3\CMS\Core\Tests\Unit\Utility\Fixtures\SingletonClassFixture
Definition: SingletonClassFixture.php:26
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\fixPermissionsSetsGroup
‪fixPermissionsSetsGroup()
Definition: GeneralUtilityTest.php:1950
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\implodeArrayForUrlBuildsValidParameterString
‪implodeArrayForUrlBuildsValidParameterString($name, $input, $expected)
Definition: GeneralUtilityTest.php:716
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\setSingletonInstanceMakesMakeInstanceReturnThatInstance
‪setSingletonInstanceMakesMakeInstanceReturnThatInstance()
Definition: GeneralUtilityTest.php:3044
‪TYPO3\CMS\Core\Core\SystemEnvironmentBuilder
Definition: SystemEnvironmentBuilder.php:41
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\rmdirRemovesFile
‪rmdirRemovesFile()
Definition: GeneralUtilityTest.php:2496
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\makeInstanceInjectsLogger
‪makeInstanceInjectsLogger()
Definition: GeneralUtilityTest.php:3007
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\writeFileToTypo3tempDirFailsWithInvalidPath
‪writeFileToTypo3tempDirFailsWithInvalidPath(string $invalidFilePath, string $expectedResult, string $pathToCleanUp)
Definition: GeneralUtilityTest.php:2303
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\sanitizeLocalUrlValidUrlsDataProvider
‪static array sanitizeLocalUrlValidUrlsDataProvider()
Definition: GeneralUtilityTest.php:1409
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\copyDirectoryCopiesFilesAndDirectoriesWithAbsolutePaths
‪copyDirectoryCopiesFilesAndDirectoriesWithAbsolutePaths()
Definition: GeneralUtilityTest.php:3373
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\callUserFunctionCanCallMethod
‪callUserFunctionCanCallMethod()
Definition: GeneralUtilityTest.php:3436
‪TYPO3\CMS\Core\Core\Environment\getPublicPath
‪static getPublicPath()
Definition: Environment.php:187
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\getDirsReturnsStringErrorOnPathFailure
‪getDirsReturnsStringErrorOnPathFailure()
Definition: GeneralUtilityTest.php:1785
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\createVersionNumberedFilenameKeepsInvalidAbsolutePathInFrontendAndAddsQueryString
‪createVersionNumberedFilenameKeepsInvalidAbsolutePathInFrontendAndAddsQueryString()
Definition: GeneralUtilityTest.php:3913
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\unlink_tempfileRemovesValidFileInTypo3temp
‪unlink_tempfileRemovesValidFileInTypo3temp()
Definition: GeneralUtilityTest.php:1560
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\addInstanceMakesMakeInstanceReturnThatInstance
‪addInstanceMakesMakeInstanceReturnThatInstance()
Definition: GeneralUtilityTest.php:3162
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\callUserFunctionWillThrowExceptionForInvalidParameters
‪callUserFunctionWillThrowExceptionForInvalidParameters(string $functionName, int $expectedException)
Definition: GeneralUtilityTest.php:3410
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\locationHeaderUrlDataProvider
‪static locationHeaderUrlDataProvider()
Definition: GeneralUtilityTest.php:3836
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\xml2arrayProcessHandlesWhitespacesDataProvider
‪static string[][] xml2arrayProcessHandlesWhitespacesDataProvider()
Definition: GeneralUtilityTest.php:3521
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\xml2arrayUsesCache
‪xml2arrayUsesCache()
Definition: GeneralUtilityTest.php:3506
‪$baseDirectory
‪$baseDirectory
Definition: updateIsoDatabase.php:98
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\getFilesInDirByExtensionDoesNotFindFilesWithOtherExtensions
‪getFilesInDirByExtensionDoesNotFindFilesWithOtherExtensions()
Definition: GeneralUtilityTest.php:2707
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\getFilesInDirDoesSortAlphabeticallyByDefault
‪getFilesInDirDoesSortAlphabeticallyByDefault()
Definition: GeneralUtilityTest.php:2742
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\sanitizeLocalUrlDeniesPlainInvalidUrlsInBackendContext
‪sanitizeLocalUrlDeniesPlainInvalidUrlsInBackendContext(string $url)
Definition: GeneralUtilityTest.php:1504
‪TYPO3\CMS\Core\Tests\Unit\Utility\Fixtures\ExtendedSingletonClassFixture
Definition: ExtendedSingletonClassFixture.php:24
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\fixPermissionsSetsPermissionsToHiddenFile
‪fixPermissionsSetsPermissionsToHiddenFile()
Definition: GeneralUtilityTest.php:1989
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\makeInstanceCalledTwoTimesForSingletonClassReturnsSameInstance
‪makeInstanceCalledTwoTimesForSingletonClassReturnsSameInstance()
Definition: GeneralUtilityTest.php:2987
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\explodeUrl2ArrayTransformsParameterStringToFlatArray
‪explodeUrl2ArrayTransformsParameterStringToFlatArray(string $input, array $expected)
Definition: GeneralUtilityTest.php:758
‪TYPO3\CMS\Core\Tests\Unit\Utility
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\quoteJsValueTest
‪quoteJsValueTest(string $input, string $expected)
Definition: GeneralUtilityTest.php:1882
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\rmdirRemovesDirectoryWithTrailingSlash
‪rmdirRemovesDirectoryWithTrailingSlash()
Definition: GeneralUtilityTest.php:2540
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\splitFileRefReturnsFileTypeForFilesWithoutPathSite
‪splitFileRefReturnsFileTypeForFilesWithoutPathSite()
Definition: GeneralUtilityTest.php:2817
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\camelCaseToLowerCaseUnderscored
‪camelCaseToLowerCaseUnderscored($expected, $inputString)
Definition: GeneralUtilityTest.php:1230
‪TYPO3\CMS\Core\Tests\Unit\Utility\Fixtures\GeneralUtilityFilesystemFixture
Definition: GeneralUtilityFilesystemFixture.php:23
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\getIndpEnvTypo3HostOnlyParsesHostnamesAndIpAddresses
‪getIndpEnvTypo3HostOnlyParsesHostnamesAndIpAddresses($httpHost, $expectedIp)
Definition: GeneralUtilityTest.php:1142
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\makeInstanceWithEmptyClassNameThrowsException
‪makeInstanceWithEmptyClassNameThrowsException()
Definition: GeneralUtilityTest.php:2916
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\jsonEncodeForHtmlAttributeTest
‪jsonEncodeForHtmlAttributeTest($value, bool $useHtmlEntities, string $expectation)
Definition: GeneralUtilityTest.php:1914
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\callUserFunctionTrimsSpaces
‪callUserFunctionTrimsSpaces()
Definition: GeneralUtilityTest.php:3446
‪TYPO3\CMS\Core\Core\Environment\getCurrentScript
‪static getCurrentScript()
Definition: Environment.php:220
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\fixPermissionsSetsDefaultPermissionsToFile
‪fixPermissionsSetsDefaultPermissionsToFile()
Definition: GeneralUtilityTest.php:2158
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\isConnected
‪bool isConnected()
Definition: GeneralUtilityTest.php:76
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\mkdirDeepCreatesDirectoryWithAndWithoutDoubleSlashesDataProvider
‪static mkdirDeepCreatesDirectoryWithAndWithoutDoubleSlashesDataProvider()
Definition: GeneralUtilityTest.php:2390
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\sanitizeLocalUrlAcceptsNotEncodedValidUrls
‪sanitizeLocalUrlAcceptsNotEncodedValidUrls(string $url, string $host, string $subDirectory)
Definition: GeneralUtilityTest.php:1439
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\trimExplodeReturnsCorrectResultDataProvider
‪static trimExplodeReturnsCorrectResultDataProvider()
Definition: GeneralUtilityTest.php:862
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\trimExplodeReturnsCorrectResult
‪trimExplodeReturnsCorrectResult(string $delimiter, string $testString, bool $removeEmpty, int $limit, array $expectedResult)
Definition: GeneralUtilityTest.php:857
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\getFileAbsFileNameReturnsCorrectValues
‪getFileAbsFileNameReturnsCorrectValues(string $path, string $expected)
Definition: GeneralUtilityTest.php:3245
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\cmpIPv4DataProviderMatching
‪static array cmpIPv4DataProviderMatching()
Definition: GeneralUtilityTest.php:134
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\callUserFunctionAcceptsClosures
‪callUserFunctionAcceptsClosures()
Definition: GeneralUtilityTest.php:3456
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\makeInstancePassesParametersToConstructor
‪makeInstancePassesParametersToConstructor()
Definition: GeneralUtilityTest.php:2947
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\callUserFunctionCanCallClosure
‪callUserFunctionCanCallClosure()
Definition: GeneralUtilityTest.php:3421
‪TYPO3\CMS\Core\Utility\GeneralUtility\camelCaseToLowerCaseUnderscored
‪static string camelCaseToLowerCaseUnderscored($string)
Definition: GeneralUtility.php:767
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\validUrlValidResourceDataProvider
‪static array validUrlValidResourceDataProvider()
Definition: GeneralUtilityTest.php:1243
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\normalizeCompressIPv6DataProviderCorrect
‪static array normalizeCompressIPv6DataProviderCorrect()
Definition: GeneralUtilityTest.php:253
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\mkdirDeepDoesNotChangePermissionsOfExistingSubDirectories
‪mkdirDeepDoesNotChangePermissionsOfExistingSubDirectories()
Definition: GeneralUtilityTest.php:2451
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\sanitizeLocalUrlInvalidDataProvider
‪static array sanitizeLocalUrlInvalidDataProvider()
Definition: GeneralUtilityTest.php:1486
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\mkdirCreatesDirectory
‪mkdirCreatesDirectory()
Definition: GeneralUtilityTest.php:2197
‪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:349
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\getFileAbsFileNameDataProvider
‪static getFileAbsFileNameDataProvider()
Definition: GeneralUtilityTest.php:3207
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\normalizeIPv6CorrectlyNormalizesAddresses
‪normalizeIPv6CorrectlyNormalizesAddresses($compressed, $normalized)
Definition: GeneralUtilityTest.php:269
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\mkdirDeepThrowsExceptionIfBaseDirectoryIsNotOfTypeString
‪mkdirDeepThrowsExceptionIfBaseDirectoryIsNotOfTypeString()
Definition: GeneralUtilityTest.php:2480
‪TYPO3\CMS\Core\Core\Environment\getLegacyConfigPath
‪static getLegacyConfigPath()
Definition: Environment.php:279
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\camelCaseToLowerCaseUnderscoredDataProvider
‪static array camelCaseToLowerCaseUnderscoredDataProvider()
Definition: GeneralUtilityTest.php:1216
‪TYPO3\CMS\Core\Tests\Unit\Utility\Fixtures\TwoParametersConstructorFixture
Definition: TwoParametersConstructorFixture.php:24
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\rmdirRemovesDirectory
‪rmdirRemovesDirectory()
Definition: GeneralUtilityTest.php:2529
‪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:1124
‪TYPO3\CMS\Core\Utility\GeneralUtility\implodeArrayForUrl
‪static string implodeArrayForUrl($name, array $theArray, $str='', $skipBlank=false, $rawurlencodeParamName=false)
Definition: GeneralUtility.php:954
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\xml2ArrayProcessHandlesAttributeTypes
‪xml2ArrayProcessHandlesAttributeTypes(string $input, mixed $expected)
Definition: GeneralUtilityTest.php:3830
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\inListForItemNotContainedReturnsFalse
‪inListForItemNotContainedReturnsFalse(string $haystack)
Definition: GeneralUtilityTest.php:412
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\addInstanceForClassThatIsNoSubclassOfProvidedClassThrowsException
‪addInstanceForClassThatIsNoSubclassOfProvidedClassThrowsException()
Definition: GeneralUtilityTest.php:3135
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\fixPermissionsDoesNotSetPermissionsToNotAllowedPath
‪fixPermissionsDoesNotSetPermissionsToNotAllowedPath()
Definition: GeneralUtilityTest.php:2122
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\mkdirDeepFixesPermissionsOfCreatedDirectory
‪mkdirDeepFixesPermissionsOfCreatedDirectory()
Definition: GeneralUtilityTest.php:2414
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\validEmailReturnsTrueForValidMailAddress
‪validEmailReturnsTrueForValidMailAddress($address)
Definition: GeneralUtilityTest.php:605
‪TYPO3\CMS\Core\Core\Environment\getConfigPath
‪static getConfigPath()
Definition: Environment.php:212
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\expandListExpandsIntegerRangesDataProvider
‪static expandListExpandsIntegerRangesDataProvider()
Definition: GeneralUtilityTest.php:444
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\getFilesInDirCreateTestDirectory
‪string getFilesInDirCreateTestDirectory()
Definition: GeneralUtilityTest.php:2629
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\sanitizeLocalUrlDeniesPlainInvalidUrlsInFrontendContext
‪sanitizeLocalUrlDeniesPlainInvalidUrlsInFrontendContext(string $url)
Definition: GeneralUtilityTest.php:1526
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\getIndpEnvTypo3PortParsesHostnamesAndIpAddresses
‪getIndpEnvTypo3PortParsesHostnamesAndIpAddresses($httpHost, $dummy, $expectedPort)
Definition: GeneralUtilityTest.php:1152
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\unlink_tempfileRemovesHiddenFile
‪unlink_tempfileRemovesHiddenFile()
Definition: GeneralUtilityTest.php:1573
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\invalidFilePathForTypo3tempDirDataProvider
‪static invalidFilePathForTypo3tempDirDataProvider()
Definition: GeneralUtilityTest.php:2256
‪TYPO3\CMS\Core\Utility\GeneralUtility\get_dirs
‪static string[] string null get_dirs($path)
Definition: GeneralUtility.php:1863
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\getFilesInDirDoesNotFindDirectories
‪getFilesInDirDoesNotFindDirectories()
Definition: GeneralUtilityTest.php:2766
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\makeInstanceCalledTwoTimesForSingletonClassWithPurgeInstancesInbetweenReturnsDifferentInstances
‪makeInstanceCalledTwoTimesForSingletonClassWithPurgeInstancesInbetweenReturnsDifferentInstances()
Definition: GeneralUtilityTest.php:2996
‪TYPO3\CMS\Core\Utility\ExtensionManagementUtility
Definition: ExtensionManagementUtility.php:40
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\fixPermissionsSetsPermissionsToHiddenDirectory
‪fixPermissionsSetsPermissionsToHiddenDirectory()
Definition: GeneralUtilityTest.php:2050
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\setUp
‪setUp()
Definition: GeneralUtilityTest.php:55
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\getFilesInDirDoesNotFindDotfiles
‪getFilesInDirDoesNotFindDotfiles()
Definition: GeneralUtilityTest.php:2781
‪TYPO3\CMS\Core\Utility\GeneralUtility\revExplode
‪static list< string > revExplode($delimiter, $string, $limit=0)
Definition: GeneralUtility.php:882
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\getAndPostDataProvider
‪static getAndPostDataProvider()
Definition: GeneralUtilityTest.php:106
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\intExplodeDataProvider
‪static intExplodeDataProvider()
Definition: GeneralUtilityTest.php:660
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\callUserFunctionInvalidParameterDataProvider
‪static callUserFunctionInvalidParameterDataProvider()
Definition: GeneralUtilityTest.php:3394
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\setSingletonInstanceForClassThatIsNoSubclassOfProvidedClassThrowsException
‪setSingletonInstanceForClassThatIsNoSubclassOfProvidedClassThrowsException()
Definition: GeneralUtilityTest.php:3029
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\implodeArrayForUrlCanUrlEncodeKeyNames
‪implodeArrayForUrlCanUrlEncodeKeyNames()
Definition: GeneralUtilityTest.php:734
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\mkdirDeepFixesPermissionsOnNewParentDirectory
‪mkdirDeepFixesPermissionsOnNewParentDirectory()
Definition: GeneralUtilityTest.php:2432
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\dirnameDataProvider
‪static array array[] dirnameDataProvider()
Definition: GeneralUtilityTest.php:2835
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\$resetSingletonInstances
‪bool $resetSingletonInstances
Definition: GeneralUtilityTest.php:49
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\isValidUrlInvalidResourceDataProvider
‪static array isValidUrlInvalidResourceDataProvider()
Definition: GeneralUtilityTest.php:1282
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\fixPermissionsSetsDefaultPermissionsToDirectory
‪fixPermissionsSetsDefaultPermissionsToDirectory()
Definition: GeneralUtilityTest.php:2176
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\cmpFqdnValidDataProvider
‪static array cmpFqdnValidDataProvider()
Definition: GeneralUtilityTest.php:336
‪TYPO3\CMS\Core\Utility\GeneralUtility\cmpFQDN
‪static bool cmpFQDN($baseHost, $list)
Definition: GeneralUtility.php:451
‪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:1272
‪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:2071
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\underscoredToLowerCamelCaseDataProvider
‪static array underscoredToLowerCamelCaseDataProvider()
Definition: GeneralUtilityTest.php:1191
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\fixPermissionsSetsPermissionsWithRelativeFileReference
‪fixPermissionsSetsPermissionsWithRelativeFileReference()
Definition: GeneralUtilityTest.php:2138
‪TYPO3\CMS\Core\Utility\GeneralUtility\fixPermissions
‪static mixed fixPermissions($path, $recursive=false)
Definition: GeneralUtility.php:1594
‪TYPO3\CMS\Core\Utility\ExtensionManagementUtility\setPackageManager
‪static setPackageManager(PackageManager $packageManager)
Definition: ExtensionManagementUtility.php:61
‪TYPO3\CMS\Core\Utility\GeneralUtility\mkdir_deep
‪static mkdir_deep($directory)
Definition: GeneralUtility.php:1753
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\validIpReturnsFalseForInvalidIp
‪validIpReturnsFalseForInvalidIp($ip)
Definition: GeneralUtilityTest.php:323
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\implodeAttributesDataProvider
‪static implodeAttributesDataProvider()
Definition: GeneralUtilityTest.php:1681
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\getBytesFromSizeMeasurementCalculatesCorrectByteValue
‪getBytesFromSizeMeasurementCalculatesCorrectByteValue($expected, $byteString)
Definition: GeneralUtilityTest.php:1099
‪TYPO3\CMS\Core\Utility\GeneralUtility\expandList
‪static string expandList($list)
Definition: GeneralUtility.php:544
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\sanitizeLocalUrlDeniesEncodedInvalidUrls
‪sanitizeLocalUrlDeniesEncodedInvalidUrls($url)
Definition: GeneralUtilityTest.php:1548
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\writeFileToTypo3tempDirWorksWithValidPath
‪writeFileToTypo3tempDirWorksWithValidPath(string $filePath, string $pathToCleanUp)
Definition: GeneralUtilityTest.php:2348
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\tempnamReturnsPathStartingWithGivenPrefix
‪tempnamReturnsPathStartingWithGivenPrefix()
Definition: GeneralUtilityTest.php:1620
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\rmdirRemovesDeadLinkToDirectory
‪rmdirRemovesDeadLinkToDirectory()
Definition: GeneralUtilityTest.php:2593
‪TYPO3\CMS\Core\Package\Package
Definition: Package.php:28
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\validPathStrDetectsInvalidCharacters
‪validPathStrDetectsInvalidCharacters(string $path)
Definition: GeneralUtilityTest.php:3313
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\getTestDirectory
‪getTestDirectory(string $prefix='root_')
Definition: GeneralUtilityTest.php:91
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\quoteJsValueDataProvider
‪static quoteJsValueDataProvider()
Definition: GeneralUtilityTest.php:1832
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\unlink_tempfileReturnsTrueIfFileWasRemoved
‪unlink_tempfileReturnsTrueIfFileWasRemoved()
Definition: GeneralUtilityTest.php:1586
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\removeDotsFromTypoScriptSucceedsWithDottedArray
‪removeDotsFromTypoScriptSucceedsWithDottedArray()
Definition: GeneralUtilityTest.php:1654
‪TYPO3\CMS\Core\Utility\GeneralUtility\_GET
‪static mixed _GET($var=null)
Definition: GeneralUtility.php:155
‪TYPO3\CMS\Core\Utility\GeneralUtility\hmac
‪static string hmac($input, $additionalSecret='')
Definition: GeneralUtility.php:584
‪TYPO3\CMS\Core\Cache\CacheManager
Definition: CacheManager.php:36
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\xml2ArrayProcessHandlesBigXmlContentDataProvider
‪static array[] xml2ArrayProcessHandlesBigXmlContentDataProvider()
Definition: GeneralUtilityTest.php:3707
‪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:294
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\validIpDataProvider
‪static array validIpDataProvider()
Definition: GeneralUtilityTest.php:282
‪TYPO3\CMS\Core\Http\ServerRequest
Definition: ServerRequest.php:37
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\mkdirCreatesDirectoryWithTrailingSlash
‪mkdirCreatesDirectoryWithTrailingSlash()
Definition: GeneralUtilityTest.php:2221
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\tempnamReturnsAbsolutePathInVarPath
‪tempnamReturnsAbsolutePathInVarPath()
Definition: GeneralUtilityTest.php:1641
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\unlink_tempfileReturnsNullIfFileDoesNotExist
‪unlink_tempfileReturnsNullIfFileDoesNotExist()
Definition: GeneralUtilityTest.php:1598
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\validEmailReturnsFalseForInvalidMailAddress
‪validEmailReturnsFalseForInvalidMailAddress($address)
Definition: GeneralUtilityTest.php:651
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\sanitizeLocalUrlAcceptsEncodedValidUrls
‪sanitizeLocalUrlAcceptsEncodedValidUrls(string $url, string $host, string $subDirectory)
Definition: GeneralUtilityTest.php:1462
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\xml2arrayProcessHandlesDocumentTagDataProvider
‪static array[] xml2arrayProcessHandlesDocumentTagDataProvider()
Definition: GeneralUtilityTest.php:3648
‪TYPO3\CMS\Core\Utility\GeneralUtility\xml2arrayProcess
‪static mixed xml2arrayProcess($string, $NSprefix='', $reportDocTag=false)
Definition: GeneralUtility.php:1386
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\makeInstanceInstanciatesConfiguredImplementation
‪makeInstanceInstanciatesConfiguredImplementation()
Definition: GeneralUtilityTest.php:2957
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\rmdirReturnTrueIfFileWasRemoved
‪rmdirReturnTrueIfFileWasRemoved()
Definition: GeneralUtilityTest.php:2510
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\mkdirSetsPermissionsOfCreatedDirectory
‪mkdirSetsPermissionsOfCreatedDirectory()
Definition: GeneralUtilityTest.php:2233
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\setSingletonInstanceReturnsFinalClassNameWithOverriddenClass
‪setSingletonInstanceReturnsFinalClassNameWithOverriddenClass()
Definition: GeneralUtilityTest.php:3081
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\mkdirDeepCreatesDirectory
‪mkdirDeepCreatesDirectory()
Definition: GeneralUtilityTest.php:2369
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\underscoredToUpperCamelCase
‪underscoredToUpperCamelCase($expected, $inputString)
Definition: GeneralUtilityTest.php:1178
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\getFilesInDirCanPrependPath
‪getFilesInDirCanPrependPath()
Definition: GeneralUtilityTest.php:2730
‪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:1318
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\inListForItemContainedReturnsTrue
‪inListForItemContainedReturnsTrue(string $haystack)
Definition: GeneralUtilityTest.php:390
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\cmpIPv6DataProviderMatching
‪static array cmpIPv6DataProviderMatching()
Definition: GeneralUtilityTest.php:192
‪TYPO3\CMS\Core\Tests\Unit\Utility\Fixtures\OriginalClassFixture
Definition: OriginalClassFixture.php:24
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\mkdirDeepCreatesSubdirectoriesRecursive
‪mkdirDeepCreatesSubdirectoriesRecursive()
Definition: GeneralUtilityTest.php:2379
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\sanitizeLocalUrlValidPathsDataProvider
‪static array sanitizeLocalUrlValidPathsDataProvider()
Definition: GeneralUtilityTest.php:1349
‪$output
‪$output
Definition: annotationChecker.php:119
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\jsonEncodeForJavaScriptTestDataProvider
‪static jsonEncodeForJavaScriptTestDataProvider()
Definition: GeneralUtilityTest.php:1919
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\purgeInstancesDropsAddedInstance
‪purgeInstancesDropsAddedInstance()
Definition: GeneralUtilityTest.php:3198
‪TYPO3\CMS\Core\Utility\GeneralUtility\isValidUrl
‪static bool isValidUrl($url)
Definition: GeneralUtility.php:797
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\xml2arrayProcessHandlesTagNamespaces
‪xml2arrayProcessHandlesTagNamespaces(string $input)
Definition: GeneralUtilityTest.php:3633
‪TYPO3\CMS\Core\Cache\Frontend\FrontendInterface
Definition: FrontendInterface.php:22
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\mkdirDeepThrowsExceptionIfDirectoryCreationFails
‪mkdirDeepThrowsExceptionIfDirectoryCreationFails()
Definition: GeneralUtilityTest.php:2469
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\cmpIPv4DataProviderNotMatching
‪static array cmpIPv4DataProviderNotMatching()
Definition: GeneralUtilityTest.php:163
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\getIndpEnvTypo3SitePathReturnNonEmptyString
‪getIndpEnvTypo3SitePathReturnNonEmptyString()
Definition: GeneralUtilityTest.php:1110
‪TYPO3\CMS\Webhooks\Message\$url
‪identifier readonly UriInterface $url
Definition: LoginErrorOccurredMessage.php:36
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\validPathStrWorksWithUnicodeFileNames
‪validPathStrWorksWithUnicodeFileNames($path)
Definition: GeneralUtilityTest.php:3337
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\validURLReturnsFalseForInvalidResource
‪validURLReturnsFalseForInvalidResource($url)
Definition: GeneralUtilityTest.php:1307
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\cmpFqdnReturnsFalse
‪cmpFqdnReturnsFalse($baseHost, $list)
Definition: GeneralUtilityTest.php:378
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\cmpIPv4ReturnsTrueForMatchingAddress
‪cmpIPv4ReturnsTrueForMatchingAddress($ip, $list)
Definition: GeneralUtilityTest.php:153
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\hmacReturnsHashOfProperLength
‪hmacReturnsHashOfProperLength()
Definition: GeneralUtilityTest.php:1799
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\removeDotsFromTypoScriptOverridesWithScalar
‪removeDotsFromTypoScriptOverridesWithScalar()
Definition: GeneralUtilityTest.php:1748
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\getDirsReturnsArrayOfDirectoriesFromGivenDirectory
‪getDirsReturnsArrayOfDirectoriesFromGivenDirectory()
Definition: GeneralUtilityTest.php:1776
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\explodeUrl2ArrayTransformsParameterStringToFlatArrayDataProvider
‪static explodeUrl2ArrayTransformsParameterStringToFlatArrayDataProvider()
Definition: GeneralUtilityTest.php:741
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\underscoredToUpperCamelCaseDataProvider
‪static array underscoredToUpperCamelCaseDataProvider()
Definition: GeneralUtilityTest.php:1166
‪TYPO3\CMS\Core\SingletonInterface
Definition: SingletonInterface.php:23
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:25
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\validPathStrDataProvider
‪static validPathStrDataProvider()
Definition: GeneralUtilityTest.php:3321
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\fixPermissionsSetsPermissionsToDirectory
‪fixPermissionsSetsPermissionsToDirectory()
Definition: GeneralUtilityTest.php:2009
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\getFilesInDirByExtensionFindsFiles
‪getFilesInDirByExtensionFindsFiles($fileExtensions)
Definition: GeneralUtilityTest.php:2694
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\revExplodeCorrectlyExplodesStringForGivenPartsCount
‪revExplodeCorrectlyExplodesStringForGivenPartsCount($delimiter, $testString, $count, $expectedArray)
Definition: GeneralUtilityTest.php:833
‪TYPO3\CMS\Core\Core\Environment
Definition: Environment.php:41
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\cmpIPv6ReturnsFalseForNotMatchingAddress
‪cmpIPv6ReturnsFalseForNotMatchingAddress($ip, $list)
Definition: GeneralUtilityTest.php:240
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\sanitizeLocalUrlAcceptsEncodedValidPaths
‪sanitizeLocalUrlAcceptsEncodedValidPaths(string $path)
Definition: GeneralUtilityTest.php:1387
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\getFilesInDirExcludesFilesMatchingPattern
‪getFilesInDirExcludesFilesMatchingPattern()
Definition: GeneralUtilityTest.php:2719
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\checkisOnCurrentHostInvalidHosts
‪array checkisOnCurrentHostInvalidHosts()
Definition: GeneralUtilityTest.php:1329
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\setSingletonInstanceCalledTwoTimesMakesMakeInstanceReturnLastSetInstance
‪setSingletonInstanceCalledTwoTimesMakesMakeInstanceReturnLastSetInstance()
Definition: GeneralUtilityTest.php:3055
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\resetSingletonInstancesResetsPreviouslySetInstance
‪resetSingletonInstancesResetsPreviouslySetInstance()
Definition: GeneralUtilityTest.php:3095
‪TYPO3\CMS\Core\Utility\GeneralUtility\intExplode
‪static int[] intExplode($delimiter, $string, $removeEmptyValues=false, $limit=0)
Definition: GeneralUtility.php:842
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\resetSingletonInstancesSetsGivenInstance
‪resetSingletonInstancesSetsGivenInstance()
Definition: GeneralUtilityTest.php:3108
‪TYPO3\CMS\Core\Utility\GeneralUtility\cmpIPv4
‪static bool cmpIPv4($baseIP, $list)
Definition: GeneralUtility.php:245
‪TYPO3\CMS\Core\Utility\GeneralUtility\rmdir
‪static bool rmdir($path, $removeNonEmpty=false)
Definition: GeneralUtility.php:1806
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\splitCalcDataProvider
‪static array splitCalcDataProvider()
Definition: GeneralUtilityTest.php:530
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\makeInstanceCalledTwoTimesAfterAddInstanceReturnTwoDifferentInstances
‪makeInstanceCalledTwoTimesAfterAddInstanceReturnTwoDifferentInstances()
Definition: GeneralUtilityTest.php:3173
‪TYPO3\CMS\Core\Tests\Unit\Utility\Fixtures\OtherReplacementClassFixture
Definition: OtherReplacementClassFixture.php:24
‪TYPO3\CMS\Core\Tests\Unit\Utility\Fixtures\GeneralUtilityTestClass
Definition: GeneralUtilityTestClass.php:21
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\removeDotsFromTypoScriptOverridesSubArray
‪removeDotsFromTypoScriptOverridesSubArray()
Definition: GeneralUtilityTest.php:1721
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\getBytesFromSizeMeasurementDataProvider
‪static array getBytesFromSizeMeasurementDataProvider()
Definition: GeneralUtilityTest.php:1086
‪TYPO3\CMS\Core\Utility\GeneralUtility\inList
‪static bool inList($list, $item)
Definition: GeneralUtility.php:532
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\$backupEnvironment
‪bool $backupEnvironment
Definition: GeneralUtilityTest.php:51
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\tempnamReturnsPathWithoutBackslashes
‪tempnamReturnsPathWithoutBackslashes()
Definition: GeneralUtilityTest.php:1631
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\fixPermissionsSetsPermissionsToFile
‪fixPermissionsSetsPermissionsToFile()
Definition: GeneralUtilityTest.php:1969
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\addInstanceCalledTwoTimesMakesMakeInstanceReturnBothInstancesInAddingOrder
‪addInstanceCalledTwoTimesMakesMakeInstanceReturnBothInstancesInAddingOrder()
Definition: GeneralUtilityTest.php:3184
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\canRetrieveGlobalInputsThroughGet
‪canRetrieveGlobalInputsThroughGet($key, $get, $expected)
Definition: GeneralUtilityTest.php:120
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\getFilesInDirFindsHiddenFile
‪getFilesInDirFindsHiddenFile()
Definition: GeneralUtilityTest.php:2662
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\splitCalcCorrectlySplitsExpression
‪splitCalcCorrectlySplitsExpression(array $expected, string $expression)
Definition: GeneralUtilityTest.php:552
‪TYPO3\CMS\Core\Utility\GeneralUtility\isOnCurrentHost
‪static bool isOnCurrentHost($url)
Definition: GeneralUtility.php:519
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\dirnameWithDataProvider
‪dirnameWithDataProvider(string $input, string $expectedValue)
Definition: GeneralUtilityTest.php:2854
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\cmpIPv4ReturnsFalseForNotMatchingAddress
‪cmpIPv4ReturnsFalseForNotMatchingAddress($ip, $list)
Definition: GeneralUtilityTest.php:179
‪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:2029
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\xml2arrayProcessHandlesWhitespaces
‪xml2arrayProcessHandlesWhitespaces(string $input)
Definition: GeneralUtilityTest.php:3578
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\makeInstanceCalledTwoTimesForNonSingletonClassReturnsDifferentInstances
‪makeInstanceCalledTwoTimesForNonSingletonClassReturnsDifferentInstances()
Definition: GeneralUtilityTest.php:2978
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\xml2arrayProcessHandlesTagNamespacesDataProvider
‪static string[][] xml2arrayProcessHandlesTagNamespacesDataProvider()
Definition: GeneralUtilityTest.php:3593
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:51
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\inListForItemContainedReturnsTrueDataProvider
‪static inListForItemContainedReturnsTrueDataProvider()
Definition: GeneralUtilityTest.php:398
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\getIndpEnvTypo3SitePathReturnsStringEndingWithSlash
‪getIndpEnvTypo3SitePathReturnsStringEndingWithSlash()
Definition: GeneralUtilityTest.php:1118
‪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:475
‪TYPO3\CMS\Core\Core\SystemEnvironmentBuilder\REQUESTTYPE_FE
‪const REQUESTTYPE_FE
Definition: SystemEnvironmentBuilder.php:43
‪TYPO3\CMS\Core\Utility\GeneralUtility\mkdir
‪static bool mkdir($newFolder)
Definition: GeneralUtility.php:1736
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\getFilesInDirFindsRegularFile
‪getFilesInDirFindsRegularFile()
Definition: GeneralUtilityTest.php:2652
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\rmdirRemovesLinkToDirectory
‪rmdirRemovesLinkToDirectory()
Definition: GeneralUtilityTest.php:2580
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\implodeArrayForUrlDataProvider
‪static implodeArrayForUrlDataProvider()
Definition: GeneralUtilityTest.php:701
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\addInstanceWithSingletonInstanceThrowsException
‪addInstanceWithSingletonInstanceThrowsException()
Definition: GeneralUtilityTest.php:3150
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\makeInstanceReturnsClassInstance
‪makeInstanceReturnsClassInstance()
Definition: GeneralUtilityTest.php:2939
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\setSingletonInstanceForEmptyClassNameThrowsException
‪setSingletonInstanceForEmptyClassNameThrowsException()
Definition: GeneralUtilityTest.php:3016
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\cmpIPv6ReturnsTrueForMatchingAddress
‪cmpIPv6ReturnsTrueForMatchingAddress($ip, $list)
Definition: GeneralUtilityTest.php:212
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\rmdirRemovesDeadLinkToFile
‪rmdirRemovesDeadLinkToFile()
Definition: GeneralUtilityTest.php:2608
‪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:743
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\unlink_tempfileReturnsNullIfFileIsNowWithinTypo3temp
‪unlink_tempfileReturnsNullIfFileIsNowWithinTypo3temp()
Definition: GeneralUtilityTest.php:1607
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\splitFileRefReturnsFileTypeNotForFolders
‪splitFileRefReturnsFileTypeNotForFolders()
Definition: GeneralUtilityTest.php:2795
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\revExplodeRespectsLimitThreeWhenExploding
‪revExplodeRespectsLimitThreeWhenExploding()
Definition: GeneralUtilityTest.php:842
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\intExplodeReturnsExplodedArray
‪intExplodeReturnsExplodedArray(string $input, bool $removeEmpty, array $expected)
Definition: GeneralUtilityTest.php:690
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\inListForItemNotContainedReturnsFalseDataProvider
‪static inListForItemNotContainedReturnsFalseDataProvider()
Definition: GeneralUtilityTest.php:420
‪TYPO3\CMS\Webhooks\Message\$identifier
‪identifier readonly string $identifier
Definition: FileAddedMessage.php:37
‪TYPO3\CMS\Core\Utility\StringUtility\getUniqueId
‪static getUniqueId(string $prefix='')
Definition: StringUtility.php:29
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\implodeAttributesEscapesProperly
‪implodeAttributesEscapesProperly(array $input, bool $xhtmlSafe, bool $keepEmptyValues, string $expected)
Definition: GeneralUtilityTest.php:1713
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\expandListExpandsForTwoThousandElementsExpandsOnlyToThousandElementsMaximum
‪expandListExpandsForTwoThousandElementsExpandsOnlyToThousandElementsMaximum()
Definition: GeneralUtilityTest.php:462
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\rmdirReturnFalseIfNoFileWasRemoved
‪rmdirReturnFalseIfNoFileWasRemoved()
Definition: GeneralUtilityTest.php:2520
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\expandListExpandsIntegerRanges
‪expandListExpandsIntegerRanges(string $list, string $expectation)
Definition: GeneralUtilityTest.php:436
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\addInstanceForEmptyClassNameThrowsException
‪addInstanceForEmptyClassNameThrowsException()
Definition: GeneralUtilityTest.php:3123
‪TYPO3\CMS\Core\Utility\GeneralUtility\writeFileToTypo3tempDir
‪static string null writeFileToTypo3tempDir($filepath, $content)
Definition: GeneralUtility.php:1659
‪TYPO3\CMS\Core\Core\Environment\isWindows
‪static isWindows()
Definition: Environment.php:287