‪TYPO3CMS  11.5
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 org\bovigo\vfs\vfsStream;
21 use org\bovigo\vfs\vfsStreamDirectory;
22 use org\bovigo\vfs\vfsStreamWrapper;
23 use Prophecy\Argument;
24 use Prophecy\PhpUnit\ProphecyTrait;
25 use Psr\Log\LoggerInterface;
32 use TYPO3\CMS\Core\Package\PackageManager;
48 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
49 
53 class ‪GeneralUtilityTest extends UnitTestCase
54 {
55  use ProphecyTrait;
56  public const ‪NO_FIX_PERMISSIONS_ON_WINDOWS = 'fixPermissions() not available on Windows (method does nothing)';
57 
61  protected ‪$resetSingletonInstances = true;
62 
66  protected ‪$backupEnvironment = true;
67 
68  protected ?PackageManager ‪$backupPackageManager;
69 
73  protected function ‪setUp(): void
74  {
75  parent::setUp();
77  }
78 
82  protected function ‪tearDown(): void
83  {
84  GeneralUtility::flushInternalRuntimeCaches();
85  if ($this->backupPackageManager) {
87  }
88  parent::tearDown();
89  }
90 
97  public function ‪isConnected(): bool
98  {
99  $isConnected = false;
100  $connected = @fsockopen('typo3.org', 80);
101  if ($connected) {
102  $isConnected = true;
103  fclose($connected);
104  }
105  return $isConnected;
106  }
107 
115  protected function ‪getVirtualTestDir(string $prefix = 'root_'): string
116  {
117  $root = vfsStream::setup();
118  $path = $root->url() . '/typo3temp/var/tests/' . ‪StringUtility::getUniqueId($prefix);
120  return $path;
121  }
122 
124  // Tests concerning _GP
126 
130  public function ‪canRetrieveValueWithGP($key, $get, $post, $expected): void
131  {
132  $_GET = $get;
133  $_POST = $post;
134  self::assertSame($expected, GeneralUtility::_GP($key));
135  }
136 
143  public function ‪gpDataProvider(): array
144  {
145  return [
146  'No key parameter' => [null, [], [], null],
147  'Key not found' => ['cake', [], [], null],
148  'Value only in GET' => ['cake', ['cake' => 'li\\e'], [], 'li\\e'],
149  'Value only in POST' => ['cake', [], ['cake' => 'l\\ie'], 'l\\ie'],
150  'Value from POST preferred over GET' => ['cake', ['cake' => 'is a'], ['cake' => '\\lie'], '\\lie'],
151  'Value can be an array' => [
152  'cake',
153  ['cake' => ['is a' => 'l\\ie']],
154  [],
155  ['is a' => 'l\\ie'],
156  ],
157  'Empty-ish key' => ['0', ['0' => 'zero'], ['0' => 'zero'], null],
158  ];
159  }
160 
162  // Tests concerning _GPmerged
164 
168  public function ‪gpMergedWillMergeArraysFromGetAndPost($get, $post, $expected): void
169  {
170  $_POST = $post;
171  $_GET = $get;
172  self::assertEquals($expected, GeneralUtility::_GPmerged('cake'));
173  }
174 
180  public function ‪gpMergedDataProvider(): array
181  {
182  $fullDataArray = ['cake' => ['a' => 'is a', 'b' => 'lie']];
183  $postPartData = ['cake' => ['b' => 'lie']];
184  $getPartData = ['cake' => ['a' => 'is a']];
185  $getPartDataModified = ['cake' => ['a' => 'is not a']];
186  return [
187  'Key doesn\' exist' => [['foo'], ['bar'], []],
188  'No POST data' => [$fullDataArray, [], $fullDataArray['cake']],
189  'No GET data' => [[], $fullDataArray, $fullDataArray['cake']],
190  'POST and GET are merged' => [$getPartData, $postPartData, $fullDataArray['cake']],
191  'POST is preferred over GET' => [$getPartDataModified, $fullDataArray, $fullDataArray['cake']],
192  ];
193  }
194 
196  // Tests concerning _GET / _POST
198 
204  public function ‪getAndPostDataProvider(): array
205  {
206  return [
207  'Requested input data doesn\'t exist' => ['cake', [], null],
208  'No key will return entire input data' => [null, ['cake' => 'l\\ie'], ['cake' => 'l\\ie']],
209  'Can retrieve specific input' => ['cake', ['cake' => 'l\\ie', 'foo'], 'l\\ie'],
210  'Can retrieve nested input data' => ['cake', ['cake' => ['is a' => 'l\\ie']], ['is a' => 'l\\ie']],
211  ];
212  }
213 
218  public function ‪canRetrieveGlobalInputsThroughGet($key, $get, $expected): void
219  {
220  $_GET = $get;
221  self::assertSame($expected, GeneralUtility::_GET($key));
222  }
223 
228  public function ‪canRetrieveGlobalInputsThroughPost($key, $post, $expected): void
229  {
230  $_POST = $post;
231  self::assertSame($expected, GeneralUtility::_POST($key));
232  }
233 
235  // Tests concerning cmpIPv4
237 
242  public static function ‪cmpIPv4DataProviderMatching(): array
243  {
244  return [
245  'host with full IP address' => ['127.0.0.1', '127.0.0.1'],
246  'host with two wildcards at the end' => ['127.0.0.1', '127.0.*.*'],
247  'host with wildcard at third octet' => ['127.0.0.1', '127.0.*.1'],
248  'host with wildcard at second octet' => ['127.0.0.1', '127.*.0.1'],
249  '/8 subnet' => ['127.0.0.1', '127.1.1.1/8'],
250  '/32 subnet (match only name)' => ['127.0.0.1', '127.0.0.1/32'],
251  '/30 subnet' => ['10.10.3.1', '10.10.3.3/30'],
252  'host with wildcard in list with IPv4/IPv6 addresses' => ['192.168.1.1', '127.0.0.1, 1234:5678::/126, 192.168.*'],
253  'host in list with IPv4/IPv6 addresses' => ['192.168.1.1', '::1, 1234:5678::/126, 192.168.1.1'],
254  ];
255  }
256 
261  public function ‪cmpIPv4ReturnsTrueForMatchingAddress($ip, $list): void
262  {
263  self::assertTrue(GeneralUtility::cmpIPv4($ip, $list));
264  }
265 
271  public static function ‪cmpIPv4DataProviderNotMatching(): array
272  {
273  return [
274  'single host' => ['127.0.0.1', '127.0.0.2'],
275  'single host with wildcard' => ['127.0.0.1', '127.*.1.1'],
276  'single host with /32 subnet mask' => ['127.0.0.1', '127.0.0.2/32'],
277  '/31 subnet' => ['127.0.0.1', '127.0.0.2/31'],
278  'list with IPv4/IPv6 addresses' => ['127.0.0.1', '10.0.2.3, 192.168.1.1, ::1'],
279  'list with only IPv6 addresses' => ['10.20.30.40', '::1, 1234:5678::/127'],
280  ];
281  }
282 
287  public function ‪cmpIPv4ReturnsFalseForNotMatchingAddress($ip, $list): void
288  {
289  self::assertFalse(GeneralUtility::cmpIPv4($ip, $list));
290  }
291 
293  // Tests concerning cmpIPv6
295 
300  public static function ‪cmpIPv6DataProviderMatching(): array
301  {
302  return [
303  'empty address' => ['::', '::'],
304  'empty with netmask in list' => ['::', '::/0'],
305  'empty with netmask 0 and host-bits set in list' => ['::', '::123/0'],
306  'localhost' => ['::1', '::1'],
307  'localhost with leading zero blocks' => ['::1', '0:0::1'],
308  'host with submask /128' => ['::1', '0:0::1/128'],
309  '/16 subnet' => ['1234::1', '1234:5678::/16'],
310  '/126 subnet' => ['1234:5678::3', '1234:5678::/126'],
311  '/126 subnet with host-bits in list set' => ['1234:5678::3', '1234:5678::2/126'],
312  'list with IPv4/IPv6 addresses' => ['1234:5678::3', '::1, 127.0.0.1, 1234:5678::/126, 192.168.1.1'],
313  ];
314  }
315 
320  public function ‪cmpIPv6ReturnsTrueForMatchingAddress($ip, $list): void
321  {
322  self::assertTrue(GeneralUtility::cmpIPv6($ip, $list));
323  }
324 
330  public static function ‪cmpIPv6DataProviderNotMatching(): array
331  {
332  return [
333  'empty against localhost' => ['::', '::1'],
334  'empty against localhost with /128 netmask' => ['::', '::1/128'],
335  'localhost against different host' => ['::1', '::2'],
336  'localhost against host with prior bits set' => ['::1', '::1:1'],
337  'host against different /17 subnet' => ['1234::1', '1234:f678::/17'],
338  'host against different /127 subnet' => ['1234:5678::3', '1234:5678::/127'],
339  'host against IPv4 address list' => ['1234:5678::3', '127.0.0.1, 192.168.1.1'],
340  'host against mixed list with IPv6 host in different subnet' => ['1234:5678::3', '::1, 1234:5678::/127'],
341  ];
342  }
343 
348  public function ‪cmpIPv6ReturnsFalseForNotMatchingAddress($ip, $list): void
349  {
350  self::assertFalse(GeneralUtility::cmpIPv6($ip, $list));
351  }
352 
354  // Tests concerning normalizeIPv6
356 
361  public static function ‪normalizeCompressIPv6DataProviderCorrect(): array
362  {
363  return [
364  'empty' => ['::', '0000:0000:0000:0000:0000:0000:0000:0000'],
365  'localhost' => ['::1', '0000:0000:0000:0000:0000:0000:0000:0001'],
366  'expansion in middle 1' => ['1::2', '0001:0000:0000:0000:0000:0000:0000:0002'],
367  'expansion in middle 2' => ['1:2::3', '0001:0002:0000:0000:0000:0000:0000:0003'],
368  'expansion in middle 3' => ['1::2:3', '0001:0000:0000:0000:0000:0000:0002:0003'],
369  'expansion in middle 4' => ['1:2::3:4:5', '0001:0002:0000:0000:0000:0003:0004:0005'],
370  ];
371  }
372 
377  public function ‪normalizeIPv6CorrectlyNormalizesAddresses($compressed, $normalized): void
378  {
379  self::assertEquals($normalized, GeneralUtility::normalizeIPv6($compressed));
380  }
381 
383  // Tests concerning validIP
385 
390  public static function ‪validIpDataProvider(): array
391  {
392  return [
393  '0.0.0.0' => ['0.0.0.0'],
394  'private IPv4 class C' => ['192.168.0.1'],
395  'private IPv4 class A' => ['10.0.13.1'],
396  'private IPv6' => ['fe80::daa2:5eff:fe8b:7dfb'],
397  ];
398  }
399 
404  public function ‪validIpReturnsTrueForValidIp($ip): void
405  {
406  self::assertTrue(GeneralUtility::validIP($ip));
407  }
408 
414  public static function ‪invalidIpDataProvider(): array
415  {
416  return [
417  'null' => [null],
418  'zero' => [0],
419  'string' => ['test'],
420  'string empty' => [''],
421  'string NULL' => ['NULL'],
422  'out of bounds IPv4' => ['300.300.300.300'],
423  'dotted decimal notation with only two dots' => ['127.0.1'],
424  ];
425  }
426 
431  public function ‪validIpReturnsFalseForInvalidIp($ip): void
432  {
433  self::assertFalse(GeneralUtility::validIP($ip));
434  }
435 
437  // Tests concerning cmpFQDN
439 
444  public static function ‪cmpFqdnValidDataProvider(): array
445  {
446  return [
447  'localhost should usually resolve, IPv4' => ['127.0.0.1', '*'],
448  'localhost should usually resolve, IPv6' => ['::1', '*'],
449  // other testcases with resolving not possible since it would
450  // require a working IPv4/IPv6-connectivity
451  'aaa.bbb.ccc.ddd.eee, full' => ['aaa.bbb.ccc.ddd.eee', 'aaa.bbb.ccc.ddd.eee'],
452  'aaa.bbb.ccc.ddd.eee, wildcard first' => ['aaa.bbb.ccc.ddd.eee', '*.ccc.ddd.eee'],
453  'aaa.bbb.ccc.ddd.eee, wildcard last' => ['aaa.bbb.ccc.ddd.eee', 'aaa.bbb.ccc.*'],
454  'aaa.bbb.ccc.ddd.eee, wildcard middle' => ['aaa.bbb.ccc.ddd.eee', 'aaa.*.eee'],
455  'list-matches, 1' => ['aaa.bbb.ccc.ddd.eee', 'xxx, yyy, zzz, aaa.*.eee'],
456  'list-matches, 2' => ['aaa.bbb.ccc.ddd.eee', '127:0:0:1,,aaa.*.eee,::1'],
457  ];
458  }
459 
464  public function ‪cmpFqdnReturnsTrue($baseHost, $list): void
465  {
466  self::assertTrue(GeneralUtility::cmpFQDN($baseHost, $list));
467  }
468 
474  public static function ‪cmpFqdnInvalidDataProvider(): array
475  {
476  return [
477  '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'],
478  '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'],
479  ];
480  }
481 
486  public function ‪cmpFqdnReturnsFalse($baseHost, $list): void
487  {
488  self::assertFalse(GeneralUtility::cmpFQDN($baseHost, $list));
489  }
490 
492  // Tests concerning inList
494 
499  public function ‪inListForItemContainedReturnsTrue(string $haystack): void
500  {
501  self::assertTrue(GeneralUtility::inList($haystack, 'findme'));
502  }
503 
509  public function ‪inListForItemContainedReturnsTrueDataProvider(): array
510  {
511  return [
512  'Element as second element of four items' => ['one,findme,three,four'],
513  'Element at beginning of list' => ['findme,one,two'],
514  'Element at end of list' => ['one,two,findme'],
515  'One item list' => ['findme'],
516  ];
517  }
518 
524  public function ‪inListForItemNotContainedReturnsFalse(string $haystack): void
525  {
526  self::assertFalse(GeneralUtility::inList($haystack, 'findme'));
527  }
528 
535  {
536  return [
537  'Four item list' => ['one,two,three,four'],
538  'One item list' => ['one'],
539  'Empty list' => [''],
540  ];
541  }
542 
544  // Tests concerning expandList
546 
552  public function ‪expandListExpandsIntegerRanges(string $list, string $expectation): void
553  {
554  self::assertSame($expectation, GeneralUtility::expandList($list));
555  }
556 
562  public function ‪expandListExpandsIntegerRangesDataProvider(): array
563  {
564  return [
565  'Expand for the same number' => ['1,2-2,7', '1,2,7'],
566  'Small range expand with parameters reversed ignores reversed items' => ['1,5-3,7', '1,7'],
567  'Small range expand' => ['1,3-5,7', '1,3,4,5,7'],
568  'Expand at beginning' => ['3-5,1,7', '3,4,5,1,7'],
569  'Expand at end' => ['1,7,3-5', '1,7,3,4,5'],
570  'Multiple small range expands' => ['1,3-5,7-10,12', '1,3,4,5,7,8,9,10,12'],
571  'One item list' => ['1-5', '1,2,3,4,5'],
572  'Nothing to expand' => ['1,2,3,4', '1,2,3,4'],
573  'Empty list' => ['', ''],
574  ];
575  }
576 
581  {
582  $list = GeneralUtility::expandList('1-2000');
583  self::assertCount(1000, explode(',', $list));
584  }
585 
587  // Tests concerning formatSize
589 
593  public function ‪formatSizeTranslatesBytesToHigherOrderRepresentation($size, $labels, $base, $expected): void
594  {
595  self::assertEquals($expected, GeneralUtility::formatSize($size, $labels, $base));
596  }
597 
603  public function ‪formatSizeDataProvider(): array
604  {
605  return [
606  'IEC Bytes stay bytes (min)' => [1, '', 0, '1 '],
607  'IEC Bytes stay bytes (max)' => [921, '', 0, '921 '],
608  'IEC Kilobytes are used (min)' => [922, '', 0, '0.90 Ki'],
609  'IEC Kilobytes are used (max)' => [943718, '', 0, '922 Ki'],
610  'IEC Megabytes are used (min)' => [943719, '', 0, '0.90 Mi'],
611  'IEC Megabytes are used (max)' => [966367641, '', 0, '922 Mi'],
612  'IEC Gigabytes are used (min)' => [966367642, '', 0, '0.90 Gi'],
613  'IEC Gigabytes are used (max)' => [989560464998, '', 0, '922 Gi'],
614  'IEC Decimal is omitted for large kilobytes' => [31080, '', 0, '30 Ki'],
615  'IEC Decimal is omitted for large megabytes' => [31458000, '', 0, '30 Mi'],
616  'IEC Decimal is omitted for large gigabytes' => [32212254720, '', 0, '30 Gi'],
617  'SI Bytes stay bytes (min)' => [1, 'si', 0, '1 '],
618  'SI Bytes stay bytes (max)' => [899, 'si', 0, '899 '],
619  'SI Kilobytes are used (min)' => [901, 'si', 0, '0.90 k'],
620  'SI Kilobytes are used (max)' => [900000, 'si', 0, '900 k'],
621  'SI Megabytes are used (min)' => [900001, 'si', 0, '0.90 M'],
622  'SI Megabytes are used (max)' => [900000000, 'si', 0, '900 M'],
623  'SI Gigabytes are used (min)' => [900000001, 'si', 0, '0.90 G'],
624  'SI Gigabytes are used (max)' => [900000000000, 'si', 0, '900 G'],
625  'SI Decimal is omitted for large kilobytes' => [30000, 'si', 0, '30 k'],
626  'SI Decimal is omitted for large megabytes' => [30000000, 'si', 0, '30 M'],
627  'SI Decimal is omitted for large gigabytes' => [30000000000, 'si', 0, '30 G'],
628  'Label for bytes can be exchanged (binary unit)' => [1, ' Foo|||', 0, '1 Foo'],
629  'Label for kilobytes can be exchanged (binary unit)' => [1024, '| Foo||', 0, '1.00 Foo'],
630  'Label for megabytes can be exchanged (binary unit)' => [1048576, '|| Foo|', 0, '1.00 Foo'],
631  'Label for gigabytes can be exchanged (binary unit)' => [1073741824, '||| Foo', 0, '1.00 Foo'],
632  'Label for bytes can be exchanged (decimal unit)' => [1, ' Foo|||', 1000, '1 Foo'],
633  'Label for kilobytes can be exchanged (decimal unit)' => [1000, '| Foo||', 1000, '1.00 Foo'],
634  'Label for megabytes can be exchanged (decimal unit)' => [1000000, '|| Foo|', 1000, '1.00 Foo'],
635  'Label for gigabytes can be exchanged (decimal unit)' => [1000000000, '||| Foo', 1000, '1.00 Foo'],
636  'IEC Base is ignored' => [1024, 'iec', 1000, '1.00 Ki'],
637  'SI Base is ignored' => [1000, 'si', 1024, '1.00 k'],
638  'Use binary base for unexpected base' => [2048, '| Bar||', 512, '2.00 Bar'],
639  ];
640  }
641 
643  // Tests concerning splitCalc
645 
650  public function ‪splitCalcDataProvider(): array
651  {
652  return [
653  'empty string returns empty array' => [
654  [],
655  '',
656  ],
657  'number without operator returns array with plus and number' => [
658  [['+', '42']],
659  '42',
660  ],
661  'two numbers with asterisk return first number with plus and second number with asterisk' => [
662  [['+', '42'], ['*', '31']],
663  '42 * 31',
664  ],
665  ];
666  }
667 
672  public function ‪splitCalcCorrectlySplitsExpression(array $expected, string $expression): void
673  {
674  self::assertSame($expected, GeneralUtility::splitCalc($expression, '+-*/'));
675  }
676 
678  // Tests concerning htmlspecialchars_decode
680 
683  public function ‪htmlspecialcharsDecodeReturnsDecodedString(): void
684  {
685  $string = '<typo3 version="6.0">&nbsp;</typo3>';
686  $encoded = htmlspecialchars($string);
687  $decoded = htmlspecialchars_decode($encoded);
688  self::assertEquals($string, $decoded);
689  }
690 
692  // Tests concerning validEmail
694 
699  public function ‪validEmailValidDataProvider(): array
700  {
701  return [
702  'short mail address' => ['a@b.c'],
703  'simple mail address' => ['test@example.com'],
704  'uppercase characters' => ['QWERTYUIOPASDFGHJKLZXCVBNM@QWERTYUIOPASDFGHJKLZXCVBNM.NET'],
705  'equal sign in local part' => ['test=mail@example.com'],
706  'dash in local part' => ['test-mail@example.com'],
707  'plus in local part' => ['test+mail@example.com'],
708  'question mark in local part' => ['test?mail@example.com'],
709  'slash in local part' => ['foo/bar@example.com'],
710  'hash in local part' => ['foo#bar@example.com'],
711  'dot in local part' => ['firstname.lastname@employee.2something.com'],
712  'dash as local part' => ['-@foo.com'],
713  'umlauts in domain part' => ['foo@äöüfoo.com'],
714  'number as top level domain' => ['foo@bar.123'],
715  'top level domain only' => ['test@localhost'],
716  'umlauts in local part' => ['äöüfoo@bar.com'],
717  'quoted @ char' => ['"Abc@def"@example.com'],
718  ];
719  }
720 
725  public function ‪validEmailReturnsTrueForValidMailAddress($address): void
726  {
727  self::assertTrue(GeneralUtility::validEmail($address));
728  }
729 
735  public function ‪validEmailInvalidDataProvider(): array
736  {
737  return [
738  'empty string' => [''],
739  'empty array' => [[]],
740  'integer' => [42],
741  'float' => [42.23],
742  'array' => [['foo']],
743  'object' => [new \stdClass()],
744  '@ sign only' => ['@'],
745  'string longer than 320 characters' => [str_repeat('0123456789', 33)],
746  'duplicate @' => ['test@@example.com'],
747  'duplicate @ combined with further special characters in local part' => ['test!.!@#$%^&*@example.com'],
748  'opening parenthesis in local part' => ['foo(bar@example.com'],
749  'closing parenthesis in local part' => ['foo)bar@example.com'],
750  'opening square bracket in local part' => ['foo[bar@example.com'],
751  'closing square bracket as local part' => [']@example.com'],
752  'dash as second level domain' => ['foo@-.com'],
753  'domain part starting with dash' => ['foo@-foo.com'],
754  'domain part ending with dash' => ['foo@foo-.com'],
755  'dot at beginning of domain part' => ['test@.com'],
756  'local part ends with dot' => ['e.x.a.m.p.l.e.@example.com'],
757  'trailing whitespace' => ['test@example.com '],
758  'trailing carriage return' => ['test@example.com' . CR],
759  'trailing linefeed' => ['test@example.com' . LF],
760  'trailing carriage return linefeed' => ['test@example.com' . CRLF],
761  'trailing tab' => ['test@example.com' . "\t"],
762  'prohibited input characters' => ['“mailto:test@example.com”'],
763  'escaped @ char' => ['abc\@def@example.com'], // known bug, see https://github.com/egulias/EmailValidator/issues/181
764  ];
765  }
766 
771  public function ‪validEmailReturnsFalseForInvalidMailAddress($address): void
772  {
773  self::assertFalse(GeneralUtility::validEmail($address));
774  }
775 
777  // Tests concerning intExplode
779 
782  public function ‪intExplodeConvertsStringsToInteger(): void
783  {
784  $testString = '1,foo,2';
785  $expectedArray = [1, 0, 2];
786  $actualArray = ‪GeneralUtility::intExplode(',', $testString);
787  self::assertEquals($expectedArray, $actualArray);
788  }
789 
791  // Tests concerning implodeArrayForUrl / explodeUrl2Array
793 
798  public function ‪implodeArrayForUrlDataProvider(): array
799  {
800  $valueArray = ['one' => '√', 'two' => 2];
801  return [
802  'Empty input' => ['foo', [], ''],
803  'String parameters' => ['foo', $valueArray, '&foo[one]=%E2%88%9A&foo[two]=2'],
804  'Nested array parameters' => ['foo', [$valueArray], '&foo[0][one]=%E2%88%9A&foo[0][two]=2'],
805  'Keep blank parameters' => ['foo', ['one' => '√', ''], '&foo[one]=%E2%88%9A&foo[0]='],
806  ];
807  }
808 
813  public function ‪implodeArrayForUrlBuildsValidParameterString($name, $input, $expected): void
814  {
815  self::assertSame($expected, ‪GeneralUtility::implodeArrayForUrl($name, $input));
816  }
817 
821  public function ‪implodeArrayForUrlCanSkipEmptyParameters(): void
822  {
823  $input = ['one' => '√', ''];
824  $expected = '&foo[one]=%E2%88%9A';
825  self::assertSame($expected, ‪GeneralUtility::implodeArrayForUrl('foo', $input, '', true));
826  }
827 
831  public function ‪implodeArrayForUrlCanUrlEncodeKeyNames(): void
832  {
833  $input = ['one' => '√', ''];
834  $expected = '&foo%5Bone%5D=%E2%88%9A&foo%5B0%5D=';
835  self::assertSame($expected, ‪GeneralUtility::implodeArrayForUrl('foo', $input, '', false, true));
836  }
837 
839  {
840  return [
841  'Empty string' => ['', []],
842  'Simple parameter string' => ['&one=%E2%88%9A&two=2', ['one' => '√', 'two' => 2]],
843  'Nested parameter string' => ['&foo[one]=%E2%88%9A&two=2', ['foo[one]' => '√', 'two' => 2]],
844  'Parameter without value' => ['&one=&two=2', ['one' => '', 'two' => 2]],
845  'Nested parameter without value' => ['&foo[one]=&two=2', ['foo[one]' => '', 'two' => 2]],
846  'Parameter without equals sign' => ['&one&two=2', ['one' => '', 'two' => 2]],
847  'Nested parameter without equals sign' => ['&foo[one]&two=2', ['foo[one]' => '', 'two' => 2]],
848  ];
849  }
850 
855  public function ‪explodeUrl2ArrayTransformsParameterStringToFlatArray(string $input, array $expected): void
856  {
857  self::assertEquals($expected, GeneralUtility::explodeUrl2Array($input));
858  }
859 
861  // Tests concerning revExplode
863 
867  public function ‪revExplodeDataProvider(): array
868  {
869  return [
870  'limit 0 should return unexploded string' => [
871  ':',
872  'my:words:here',
873  0,
874  ['my:words:here'],
875  ],
876  'limit 1 should return unexploded string' => [
877  ':',
878  'my:words:here',
879  1,
880  ['my:words:here'],
881  ],
882  'limit 2 should return two pieces' => [
883  ':',
884  'my:words:here',
885  2,
886  ['my:words', 'here'],
887  ],
888  'limit 3 should return unexploded string' => [
889  ':',
890  'my:words:here',
891  3,
892  ['my', 'words', 'here'],
893  ],
894  'limit 0 should return unexploded string if no delimiter is contained' => [
895  ':',
896  'mywordshere',
897  0,
898  ['mywordshere'],
899  ],
900  'limit 1 should return unexploded string if no delimiter is contained' => [
901  ':',
902  'mywordshere',
903  1,
904  ['mywordshere'],
905  ],
906  'limit 2 should return unexploded string if no delimiter is contained' => [
907  ':',
908  'mywordshere',
909  2,
910  ['mywordshere'],
911  ],
912  'limit 3 should return unexploded string if no delimiter is contained' => [
913  ':',
914  'mywordshere',
915  3,
916  ['mywordshere'],
917  ],
918  'multi character delimiter is handled properly with limit 2' => [
919  '[]',
920  'a[b][c][d]',
921  2,
922  ['a[b][c', 'd]'],
923  ],
924  'multi character delimiter is handled properly with limit 3' => [
925  '[]',
926  'a[b][c][d]',
927  3,
928  ['a[b', 'c', 'd]'],
929  ],
930  ];
931  }
932 
937  public function ‪revExplodeCorrectlyExplodesStringForGivenPartsCount($delimiter, $testString, $count, $expectedArray): void
938  {
939  $actualArray = ‪GeneralUtility::revExplode($delimiter, $testString, $count);
940  self::assertEquals($expectedArray, $actualArray);
941  }
942 
946  public function ‪revExplodeRespectsLimitThreeWhenExploding(): void
947  {
948  $testString = 'even:more:of:my:words:here';
949  $expectedArray = ['even:more:of:my', 'words', 'here'];
950  $actualArray = ‪GeneralUtility::revExplode(':', $testString, 3);
951  self::assertEquals($expectedArray, $actualArray);
952  }
953 
955  // Tests concerning trimExplode
957 
967  public function ‪trimExplodeReturnsCorrectResult(string $delimiter, string $testString, bool $removeEmpty, int $limit, array $expectedResult): void
968  {
969  self::assertSame($expectedResult, ‪GeneralUtility::trimExplode($delimiter, $testString, $removeEmpty, $limit));
970  }
971 
975  public function ‪trimExplodeReturnsCorrectResultDataProvider(): array
976  {
977  return [
978  'spaces at element start and end' => [
979  ',',
980  ' a , b , c ,d ,, e,f,',
981  false,
982  0,
983  ['a', 'b', 'c', 'd', '', 'e', 'f', ''],
984  ],
985  'removes newline' => [
986  ',',
987  ' a , b , ' . LF . ' ,d ,, e,f,',
988  true,
989  0,
990  ['a', 'b', 'd', 'e', 'f'],
991  ],
992  'removes empty elements' => [
993  ',',
994  'a , b , c , ,d ,, ,e,f,',
995  true,
996  0,
997  ['a', 'b', 'c', 'd', 'e', 'f'],
998  ],
999  'keeps remaining results with empty items after reaching limit with positive parameter' => [
1000  ',',
1001  ' a , b , c , , d,, ,e ',
1002  false,
1003  3,
1004  ['a', 'b', 'c , , d,, ,e'],
1005  ],
1006  'keeps remaining results without empty items after reaching limit with positive parameter' => [
1007  ',',
1008  ' a , b , c , , d,, ,e ',
1009  true,
1010  3,
1011  ['a', 'b', 'c , d,e'],
1012  ],
1013  'keeps remaining results with empty items after reaching limit with negative parameter' => [
1014  ',',
1015  ' a , b , c , d, ,e, f , , ',
1016  false,
1017  -3,
1018  ['a', 'b', 'c', 'd', '', 'e'],
1019  ],
1020  'keeps remaining results without empty items after reaching limit with negative parameter' => [
1021  ',',
1022  ' a , b , c , d, ,e, f , , ',
1023  true,
1024  -3,
1025  ['a', 'b', 'c'],
1026  ],
1027  'returns exact results without reaching limit with positive parameter' => [
1028  ',',
1029  ' a , b , , c , , , ',
1030  true,
1031  4,
1032  ['a', 'b', 'c'],
1033  ],
1034  'keeps zero as string' => [
1035  ',',
1036  'a , b , c , ,d ,, ,e,f, 0 ,',
1037  true,
1038  0,
1039  ['a', 'b', 'c', 'd', 'e', 'f', '0'],
1040  ],
1041  'keeps whitespace inside elements' => [
1042  ',',
1043  'a , b , c , ,d ,, ,e,f, g h ,',
1044  true,
1045  0,
1046  ['a', 'b', 'c', 'd', 'e', 'f', 'g h'],
1047  ],
1048  'can use internal regex delimiter as explode delimiter' => [
1049  '/',
1050  'a / b / c / /d // /e/f/ g h /',
1051  true,
1052  0,
1053  ['a', 'b', 'c', 'd', 'e', 'f', 'g h'],
1054  ],
1055  'can use whitespaces as delimiter' => [
1056  ' ',
1057  '* * * * *',
1058  true,
1059  0,
1060  ['*', '*', '*', '*', '*'],
1061  ],
1062  'can use words as delimiter' => [
1063  'All',
1064  'HelloAllTogether',
1065  true,
1066  0,
1067  ['Hello', 'Together'],
1068  ],
1069  'can use word with appended and prepended spaces as delimiter' => [
1070  ' all ',
1071  'Hello all together',
1072  true,
1073  0,
1074  ['Hello', 'together'],
1075  ],
1076  'can use word with appended and prepended spaces as delimiter and do not remove empty' => [
1077  ' all ',
1078  'Hello all together all there all all are all none',
1079  false,
1080  0,
1081  ['Hello', 'together', 'there', '', 'are', 'none'],
1082  ],
1083  'can use word with appended and prepended spaces as delimiter, do not remove empty and limit' => [
1084  ' all ',
1085  'Hello all together all there all all are all none',
1086  false,
1087  5,
1088  ['Hello', 'together', 'there', '', 'are all none'],
1089  ],
1090  'can use word with appended and prepended spaces as delimiter, do not remove empty, limit and multiple delimiter in last' => [
1091  ' all ',
1092  'Hello all together all there all all are all none',
1093  false,
1094  4,
1095  ['Hello', 'together', 'there', 'all are all none'],
1096  ],
1097  'can use word with appended and prepended spaces as delimiter, remove empty and limit' => [
1098  ' all ',
1099  'Hello all together all there all all are all none',
1100  true,
1101  4,
1102  ['Hello', 'together', 'there', 'are all none'],
1103  ],
1104  'can use word with appended and prepended spaces as delimiter, remove empty and limit and multiple delimiter in last' => [
1105  ' all ',
1106  'Hello all together all there all all are all none',
1107  true,
1108  5,
1109  ['Hello', 'together', 'there', 'are' , 'none'],
1110  ],
1111  'can use words as delimiter and do not remove empty' => [
1112  'all there',
1113  'Helloall theretogether all there all there are all there none',
1114  false,
1115  0,
1116  ['Hello', 'together', '', 'are', 'none'],
1117  ],
1118  'can use words as delimiter, do not remove empty and limit' => [
1119  'all there',
1120  'Helloall theretogether all there all there are all there none',
1121  false,
1122  4,
1123  ['Hello', 'together', '', 'are all there none'],
1124  ],
1125  'can use words as delimiter, do not remove empty, limit and multiple delimiter in last' => [
1126  'all there',
1127  'Helloall theretogether all there all there are all there none',
1128  false,
1129  3,
1130  ['Hello', 'together', 'all there are all there none'],
1131  ],
1132  'can use words as delimiter, remove empty' => [
1133  'all there',
1134  'Helloall theretogether all there all there are all there none',
1135  true,
1136  0,
1137  ['Hello', 'together', 'are', 'none'],
1138  ],
1139  'can use words as delimiter, remove empty and limit' => [
1140  'all there',
1141  'Helloall theretogether all there all there are all there none',
1142  true,
1143  3,
1144  ['Hello', 'together', 'are all there none'],
1145  ],
1146  'can use words as delimiter, remove empty and limit and multiple delimiter in last' => [
1147  'all there',
1148  'Helloall theretogether all there all there are all there none',
1149  true,
1150  4,
1151  ['Hello', 'together', 'are' , 'none'],
1152  ],
1153  'can use new line as delimiter' => [
1154  LF,
1155  "Hello\nall\ntogether",
1156  true,
1157  0,
1158  ['Hello', 'all', 'together'],
1159  ],
1160  'works with whitespace separator' => [
1161  "\t",
1162  " a b \t c \t \t d \t e \t u j \t s",
1163  false,
1164  0,
1165  ['a b', 'c', '', 'd', 'e', 'u j', 's'],
1166  ],
1167  'works with whitespace separator and limit' => [
1168  "\t",
1169  " a b \t c \t \t d \t e \t u j \t s",
1170  false,
1171  4,
1172  ['a b', 'c', '', "d \t e \t u j \t s"],
1173  ],
1174  'works with whitespace separator and remove empty' => [
1175  "\t",
1176  " a b \t c \t \t d \t e \t u j \t s",
1177  true,
1178  0,
1179  ['a b', 'c', 'd', 'e', 'u j', 's'],
1180  ],
1181  'works with whitespace separator remove empty and limit' => [
1182  "\t",
1183  " a b \t c \t \t d \t e \t u j \t s",
1184  true,
1185  3,
1186  ['a b', 'c', "d \t e \t u j \t s"],
1187  ],
1188  ];
1189  }
1190 
1192  // Tests concerning getBytesFromSizeMeasurement
1194 
1199  public function ‪getBytesFromSizeMeasurementDataProvider(): array
1200  {
1201  return [
1202  '100 kilo Bytes' => ['102400', '100k'],
1203  '100 mega Bytes' => ['104857600', '100m'],
1204  '100 giga Bytes' => ['107374182400', '100g'],
1205  ];
1206  }
1207 
1212  public function ‪getBytesFromSizeMeasurementCalculatesCorrectByteValue($expected, $byteString): void
1213  {
1214  self::assertEquals($expected, GeneralUtility::getBytesFromSizeMeasurement($byteString));
1215  }
1216 
1218  // Tests concerning getIndpEnv
1223  public function ‪getIndpEnvTypo3SitePathReturnNonEmptyString(): void
1224  {
1225  self::assertTrue(strlen(GeneralUtility::getIndpEnv('TYPO3_SITE_PATH')) >= 1);
1226  }
1227 
1232  {
1233  $result = GeneralUtility::getIndpEnv('TYPO3_SITE_PATH');
1234  self::assertEquals('/', $result[strlen($result) - 1]);
1235  }
1236 
1240  public static function ‪hostnameAndPortDataProvider(): array
1241  {
1242  return [
1243  'localhost ipv4 without port' => ['127.0.0.1', '127.0.0.1', ''],
1244  'localhost ipv4 with port' => ['127.0.0.1:81', '127.0.0.1', '81'],
1245  'localhost ipv6 without port' => ['[::1]', '[::1]', ''],
1246  'localhost ipv6 with port' => ['[::1]:81', '[::1]', '81'],
1247  'ipv6 without port' => ['[2001:DB8::1]', '[2001:DB8::1]', ''],
1248  'ipv6 with port' => ['[2001:DB8::1]:81', '[2001:DB8::1]', '81'],
1249  'hostname without port' => ['lolli.did.this', 'lolli.did.this', ''],
1250  'hostname with port' => ['lolli.did.this:42', 'lolli.did.this', '42'],
1251  ];
1252  }
1253 
1258  public function ‪getIndpEnvTypo3HostOnlyParsesHostnamesAndIpAddresses($httpHost, $expectedIp): void
1259  {
1260  $_SERVER['HTTP_HOST'] = $httpHost;
1261  self::assertEquals($expectedIp, GeneralUtility::getIndpEnv('TYPO3_HOST_ONLY'));
1262  }
1263 
1268  public function ‪getIndpEnvTypo3PortParsesHostnamesAndIpAddresses($httpHost, $dummy, $expectedPort): void
1269  {
1270  $_SERVER['HTTP_HOST'] = $httpHost;
1271  self::assertEquals($expectedPort, GeneralUtility::getIndpEnv('TYPO3_PORT'));
1272  }
1273 
1275  // Tests concerning underscoredToUpperCamelCase
1277 
1282  public function ‪underscoredToUpperCamelCaseDataProvider(): array
1283  {
1284  return [
1285  'single word' => ['Blogexample', 'blogexample'],
1286  'multiple words' => ['BlogExample', 'blog_example'],
1287  ];
1288  }
1289 
1294  public function ‪underscoredToUpperCamelCase($expected, $inputString): void
1295  {
1296  self::assertEquals($expected, ‪GeneralUtility::underscoredToUpperCamelCase($inputString));
1297  }
1298 
1300  // Tests concerning underscoredToLowerCamelCase
1302 
1307  public function ‪underscoredToLowerCamelCaseDataProvider(): array
1308  {
1309  return [
1310  'single word' => ['minimalvalue', 'minimalvalue'],
1311  'multiple words' => ['minimalValue', 'minimal_value'],
1312  ];
1313  }
1314 
1319  public function ‪underscoredToLowerCamelCase($expected, $inputString): void
1320  {
1321  self::assertEquals($expected, ‪GeneralUtility::underscoredToLowerCamelCase($inputString));
1322  }
1323 
1325  // Tests concerning camelCaseToLowerCaseUnderscored
1327 
1332  public function ‪camelCaseToLowerCaseUnderscoredDataProvider(): array
1333  {
1334  return [
1335  'single word' => ['blogexample', 'blogexample'],
1336  'single word starting upper case' => ['blogexample', 'Blogexample'],
1337  'two words starting lower case' => ['minimal_value', 'minimalValue'],
1338  'two words starting upper case' => ['blog_example', 'BlogExample'],
1339  ];
1340  }
1341 
1346  public function ‪camelCaseToLowerCaseUnderscored($expected, $inputString): void
1347  {
1348  self::assertEquals($expected, ‪GeneralUtility::camelCaseToLowerCaseUnderscored($inputString));
1349  }
1350 
1352  // Tests concerning isValidUrl
1354 
1359  public function ‪validUrlValidResourceDataProvider(): array
1360  {
1361  return [
1362  'http' => ['http://www.example.org/'],
1363  'http without trailing slash' => ['http://qwe'],
1364  'http directory with trailing slash' => ['http://www.example/img/dir/'],
1365  'http directory without trailing slash' => ['http://www.example/img/dir'],
1366  'http index.html' => ['http://example.com/index.html'],
1367  'http index.php' => ['http://www.example.com/index.php'],
1368  'http test.png' => ['http://www.example/img/test.png'],
1369  'http username password querystring and anchor' => ['https://user:pw@www.example.org:80/path?arg=value#fragment'],
1370  'file' => ['file:///tmp/test.c'],
1371  'file directory' => ['file://foo/bar'],
1372  'ftp directory' => ['ftp://ftp.example.com/tmp/'],
1373  'mailto' => ['mailto:foo@bar.com'],
1374  'news' => ['news:news.php.net'],
1375  'telnet' => ['telnet://192.0.2.16:80/'],
1376  'ldap' => ['ldap://[2001:db8::7]/c=GB?objectClass?one'],
1377  'http punycode domain name' => ['http://www.xn--bb-eka.at'],
1378  'http punicode subdomain' => ['http://xn--h-zfa.oebb.at'],
1379  'http domain-name umlauts' => ['http://www.öbb.at'],
1380  'http subdomain umlauts' => ['http://äh.oebb.at'],
1381  ];
1382  }
1383 
1388  public function ‪validURLReturnsTrueForValidResource($url): void
1389  {
1390  self::assertTrue(‪GeneralUtility::isValidUrl($url));
1391  }
1392 
1398  public function ‪isValidUrlInvalidResourceDataProvider(): array
1399  {
1400  return [
1401  'http missing colon' => ['http//www.example/wrong/url/'],
1402  'http missing slash' => ['http:/www.example'],
1403  'hostname only' => ['www.example.org/'],
1404  'file missing protocol specification' => ['/tmp/test.c'],
1405  'slash only' => ['/'],
1406  'string http://' => ['http://'],
1407  'string http:/' => ['http:/'],
1408  'string http:' => ['http:'],
1409  'string http' => ['http'],
1410  'empty string' => [''],
1411  'string -1' => ['-1'],
1412  'string array()' => ['array()'],
1413  'random string' => ['qwe'],
1414  'http directory umlauts' => ['http://www.oebb.at/äöü/'],
1415  'prohibited input characters' => ['https://{$unresolved_constant}'],
1416  ];
1417  }
1418 
1423  public function ‪validURLReturnsFalseForInvalidResource($url): void
1424  {
1425  self::assertFalse(‪GeneralUtility::isValidUrl($url));
1426  }
1427 
1429  // Tests concerning isOnCurrentHost
1431 
1435  public function ‪isOnCurrentHostReturnsTrueWithCurrentHost(): void
1436  {
1437  $testUrl = GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL');
1438  self::assertTrue(GeneralUtility::isOnCurrentHost($testUrl));
1439  }
1440 
1446  public static function checkisOnCurrentHostInvalidHostsDataProvider(): array
1447  {
1448  return [
1449  'empty string' => [''],
1450  'arbitrary string' => ['arbitrary string'],
1451  'localhost IP' => ['127.0.0.1'],
1452  'relative path' => ['./relpath/file.txt'],
1453  'absolute path' => ['/abspath/file.txt?arg=value'],
1454  'different host' => [GeneralUtility::getIndpEnv('TYPO3_REQUEST_HOST') . '.example.org'],
1455  ];
1456  }
1457 
1463  public function ‪isOnCurrentHostWithNotCurrentHostReturnsFalse(string $hostCandidate): void
1464  {
1465  self::assertFalse(GeneralUtility::isOnCurrentHost($hostCandidate));
1466  }
1467 
1469  // Tests concerning sanitizeLocalUrl
1471 
1476  public function ‪sanitizeLocalUrlValidPathsDataProvider(): array
1477  {
1478  return [
1479  'alt_intro.php' => ['alt_intro.php'],
1480  'alt_intro.php?foo=1&bar=2' => ['alt_intro.php?foo=1&bar=2'],
1481  '../index.php' => ['../index.php'],
1482  '../typo3/alt_intro.php' => ['../typo3/alt_intro.php'],
1483  '../~userDirectory/index.php' => ['../~userDirectory/index.php'],
1484  '../typo3/index.php?var1=test-case&var2=~user' => ['../typo3/index.php?var1=test-case&var2=~user'],
1485  ‪Environment::getPublicPath() . '/typo3/alt_intro.php' => [‪Environment::getPublicPath() . '/typo3/alt_intro.php'],
1486  ];
1487  }
1488 
1494  public function ‪sanitizeLocalUrlAcceptsNotEncodedValidPaths(string $path): void
1495  {
1498  true,
1499  false,
1504  ‪Environment::getBackendPath() . '/index.php',
1505  ‪Environment::isWindows() ? 'WINDOWS' : 'UNIX'
1506  );
1507  self::assertEquals($path, GeneralUtility::sanitizeLocalUrl($path));
1508  }
1509 
1515  public function ‪sanitizeLocalUrlAcceptsEncodedValidPaths(string $path): void
1516  {
1519  true,
1520  false,
1525  ‪Environment::getBackendPath() . '/index.php',
1526  ‪Environment::isWindows() ? 'WINDOWS' : 'UNIX'
1527  );
1528  self::assertEquals(rawurlencode($path), GeneralUtility::sanitizeLocalUrl(rawurlencode($path)));
1529  }
1530 
1536  public function ‪sanitizeLocalUrlValidUrlsDataProvider(): array
1537  {
1538  return [
1539  '/cms/typo3/alt_intro.php' => [
1540  '/cms/typo3/alt_intro.php',
1541  'localhost',
1542  '/cms/',
1543  ],
1544  '/cms/index.php' => [
1545  '/cms/index.php',
1546  'localhost',
1547  '/cms/',
1548  ],
1549  'http://localhost/typo3/alt_intro.php' => [
1550  'http://localhost/typo3/alt_intro.php',
1551  'localhost',
1552  '',
1553  ],
1554  'http://localhost/cms/typo3/alt_intro.php' => [
1555  'http://localhost/cms/typo3/alt_intro.php',
1556  'localhost',
1557  '/cms/',
1558  ],
1559  ];
1560  }
1561 
1569  public function ‪sanitizeLocalUrlAcceptsNotEncodedValidUrls(string $url, string $host, string $subDirectory): void
1570  {
1573  true,
1574  false,
1579  ‪Environment::getBackendPath() . '/index.php',
1580  ‪Environment::isWindows() ? 'WINDOWS' : 'UNIX'
1581  );
1582  $_SERVER['HTTP_HOST'] = $host;
1583  $_SERVER['SCRIPT_NAME'] = $subDirectory . 'typo3/index.php';
1584  self::assertEquals($url, GeneralUtility::sanitizeLocalUrl($url));
1585  }
1586 
1594  public function ‪sanitizeLocalUrlAcceptsEncodedValidUrls(string $url, string $host, string $subDirectory): void
1595  {
1598  true,
1599  false,
1604  ‪Environment::getBackendPath() . '/index.php',
1605  ‪Environment::isWindows() ? 'WINDOWS' : 'UNIX'
1606  );
1607  $_SERVER['HTTP_HOST'] = $host;
1608  $_SERVER['SCRIPT_NAME'] = $subDirectory . 'typo3/index.php';
1609  self::assertEquals(rawurlencode($url), GeneralUtility::sanitizeLocalUrl(rawurlencode($url)));
1610  }
1611 
1617  public function ‪sanitizeLocalUrlInvalidDataProvider(): array
1618  {
1619  return [
1620  'empty string' => [''],
1621  'http domain' => ['http://www.google.de/'],
1622  'https domain' => ['https://www.google.de/'],
1623  'domain without schema' => ['//www.google.de/'],
1624  'XSS attempt' => ['" onmouseover="alert(123)"'],
1625  'invalid URL, UNC path' => ['\\\\foo\\bar\\'],
1626  'invalid URL, HTML break out attempt' => ['" >blabuubb'],
1627  'base64 encoded string' => ['data:%20text/html;base64,PHNjcmlwdD5hbGVydCgnWFNTJyk8L3NjcmlwdD4='],
1628  ];
1629  }
1630 
1636  public function ‪sanitizeLocalUrlDeniesPlainInvalidUrlsInBackendContext(string $url): void
1637  {
1640  true,
1641  false,
1646  ‪Environment::getBackendPath() . '/index.php',
1647  ‪Environment::isWindows() ? 'WINDOWS' : 'UNIX'
1648  );
1649  $_SERVER['HTTP_HOST'] = 'localhost';
1650  $_SERVER['SCRIPT_NAME'] = 'typo3/index.php';
1651  self::assertEquals('', GeneralUtility::sanitizeLocalUrl($url));
1652  }
1653 
1659  public function ‪sanitizeLocalUrlDeniesPlainInvalidUrlsInFrontendContext(string $url): void
1660  {
1663  true,
1664  false,
1669  ‪Environment::getPublicPath() . '/index.php',
1670  ‪Environment::isWindows() ? 'WINDOWS' : 'UNIX'
1671  );
1672  $_SERVER['HTTP_HOST'] = 'localhost';
1673  $_SERVER['SCRIPT_NAME'] = 'index.php';
1674  self::assertEquals('', GeneralUtility::sanitizeLocalUrl($url));
1675  }
1676 
1681  public function ‪sanitizeLocalUrlDeniesEncodedInvalidUrls($url): void
1682  {
1683  self::assertEquals('', GeneralUtility::sanitizeLocalUrl(rawurlencode($url)));
1684  }
1685 
1687  // Tests concerning unlink_tempfile
1689 
1693  public function ‪unlink_tempfileRemovesValidFileInTypo3temp(): void
1694  {
1695  $fixtureFile = __DIR__ . '/Fixtures/clear.gif';
1696  $testFilename = ‪Environment::getVarPath() . '/tests/' . ‪StringUtility::getUniqueId('test_') . '.gif';
1697  @copy($fixtureFile, $testFilename);
1698  GeneralUtility::unlink_tempfile($testFilename);
1699  $fileExists = file_exists($testFilename);
1700  self::assertFalse($fileExists);
1701  }
1702 
1706  public function ‪unlink_tempfileRemovesHiddenFile(): void
1707  {
1708  $fixtureFile = __DIR__ . '/Fixtures/clear.gif';
1709  $testFilename = ‪Environment::getVarPath() . '/tests/' . ‪StringUtility::getUniqueId('.test_') . '.gif';
1710  @copy($fixtureFile, $testFilename);
1711  GeneralUtility::unlink_tempfile($testFilename);
1712  $fileExists = file_exists($testFilename);
1713  self::assertFalse($fileExists);
1714  }
1715 
1719  public function ‪unlink_tempfileReturnsTrueIfFileWasRemoved(): void
1720  {
1721  $fixtureFile = __DIR__ . '/Fixtures/clear.gif';
1722  $testFilename = ‪Environment::getVarPath() . '/tests/' . ‪StringUtility::getUniqueId('test_') . '.gif';
1723  @copy($fixtureFile, $testFilename);
1724  $returnValue = GeneralUtility::unlink_tempfile($testFilename);
1725  self::assertTrue($returnValue);
1726  }
1727 
1731  public function ‪unlink_tempfileReturnsNullIfFileDoesNotExist(): void
1732  {
1733  $returnValue = GeneralUtility::unlink_tempfile(‪Environment::getVarPath() . '/tests/' . ‪StringUtility::getUniqueId('i_do_not_exist'));
1734  self::assertNull($returnValue);
1735  }
1736 
1741  {
1742  $returnValue = GeneralUtility::unlink_tempfile('/tmp/typo3-unit-test-unlink_tempfile');
1743  self::assertNull($returnValue);
1744  }
1745 
1747  // Tests concerning tempnam
1749 
1753  public function ‪tempnamReturnsPathStartingWithGivenPrefix(): void
1754  {
1755  $filePath = GeneralUtility::tempnam('foo');
1756  $this->testFilesToDelete[] = $filePath;
1757  $fileName = basename($filePath);
1758  self::assertStringStartsWith('foo', $fileName);
1759  }
1760 
1764  public function ‪tempnamReturnsPathWithoutBackslashes(): void
1765  {
1766  $filePath = GeneralUtility::tempnam('foo');
1767  $this->testFilesToDelete[] = $filePath;
1768  self::assertStringNotContainsString('\\', $filePath);
1769  }
1770 
1774  public function ‪tempnamReturnsAbsolutePathInVarPath(): void
1775  {
1776  $filePath = GeneralUtility::tempnam('foo');
1777  $this->testFilesToDelete[] = $filePath;
1778  self::assertStringStartsWith(‪Environment::getVarPath() . '/transient/', $filePath);
1779  }
1780 
1782  // Tests concerning removeDotsFromTS
1788  {
1789  $typoScript = [
1790  'propertyA.' => [
1791  'keyA.' => [
1792  'valueA' => 1,
1793  ],
1794  'keyB' => 2,
1795  ],
1796  'propertyB' => 3,
1797  ];
1798  $expectedResult = [
1799  'propertyA' => [
1800  'keyA' => [
1801  'valueA' => 1,
1802  ],
1803  'keyB' => 2,
1804  ],
1805  'propertyB' => 3,
1806  ];
1807  self::assertEquals($expectedResult, GeneralUtility::removeDotsFromTS($typoScript));
1808  }
1809 
1811  // Tests concerning implodeAttributes
1813 
1814  public function ‪implodeAttributesDataProvider(): \Iterator
1815  {
1816  yield 'Generic input without xhtml' => [
1817  ['hREf' => 'https://example.com', 'title' => 'above'],
1818  false,
1819  true,
1820  'hREf="https://example.com" title="above"',
1821  ];
1822  yield 'Generic input' => [
1823  ['hREf' => 'https://example.com', 'title' => 'above'],
1824  true,
1825  true,
1826  'href="https://example.com" title="above"',
1827  ];
1828  yield 'Generic input keeping empty values' => [
1829  ['hREf' => 'https://example.com', 'title' => ''],
1830  true,
1831  true, // keep empty values
1832  'href="https://example.com" title=""',
1833  ];
1834  yield 'Generic input removing empty values' => [
1835  ['hREf' => 'https://example.com', 'title' => '', 'nomodule' => null],
1836  true,
1837  false, // do not keep empty values
1838  'href="https://example.com"',
1839  ];
1840  }
1841 
1846  public function ‪implodeAttributesEscapesProperly(array $input, bool $xhtmlSafe, bool $keepEmptyValues, string $expected): void
1847  {
1848  self::assertSame($expected, GeneralUtility::implodeAttributes($input, $xhtmlSafe, $keepEmptyValues));
1849  }
1850 
1854  public function ‪removeDotsFromTypoScriptOverridesSubArray(): void
1855  {
1856  $typoScript = [
1857  'propertyA.' => [
1858  'keyA' => 'getsOverridden',
1859  'keyA.' => [
1860  'valueA' => 1,
1861  ],
1862  'keyB' => 2,
1863  ],
1864  'propertyB' => 3,
1865  ];
1866  $expectedResult = [
1867  'propertyA' => [
1868  'keyA' => [
1869  'valueA' => 1,
1870  ],
1871  'keyB' => 2,
1872  ],
1873  'propertyB' => 3,
1874  ];
1875  self::assertEquals($expectedResult, GeneralUtility::removeDotsFromTS($typoScript));
1876  }
1877 
1881  public function ‪removeDotsFromTypoScriptOverridesWithScalar(): void
1882  {
1883  $typoScript = [
1884  'propertyA.' => [
1885  'keyA.' => [
1886  'valueA' => 1,
1887  ],
1888  'keyA' => 'willOverride',
1889  'keyB' => 2,
1890  ],
1891  'propertyB' => 3,
1892  ];
1893  $expectedResult = [
1894  'propertyA' => [
1895  'keyA' => 'willOverride',
1896  'keyB' => 2,
1897  ],
1898  'propertyB' => 3,
1899  ];
1900  self::assertEquals($expectedResult, GeneralUtility::removeDotsFromTS($typoScript));
1901  }
1902 
1904  // Tests concerning get_dirs
1910  {
1912  self::assertIsArray($directories);
1913  }
1914 
1918  public function ‪getDirsReturnsStringErrorOnPathFailure(): void
1919  {
1920  $path = 'foo';
1921  $result = ‪GeneralUtility::get_dirs($path);
1922  $expectedResult = 'error';
1923  self::assertEquals($expectedResult, $result);
1924  }
1925 
1927  // Tests concerning hmac
1932  public function ‪hmacReturnsHashOfProperLength(): void
1933  {
1934  ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'] = '';
1935  $hmac = GeneralUtility::hmac('message');
1936  self::assertTrue(!empty($hmac) && is_string($hmac));
1937  self::assertEquals(strlen($hmac), 40);
1938  }
1939 
1943  public function ‪hmacReturnsEqualHashesForEqualInput(): void
1944  {
1945  ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'] = '';
1946  $msg0 = 'message';
1947  $msg1 = 'message';
1948  self::assertEquals(GeneralUtility::hmac($msg0), GeneralUtility::hmac($msg1));
1949  }
1950 
1954  public function ‪hmacReturnsNoEqualHashesForNonEqualInput(): void
1955  {
1956  ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'] = '';
1957  $msg0 = 'message0';
1958  $msg1 = 'message1';
1959  self::assertNotEquals(GeneralUtility::hmac($msg0), GeneralUtility::hmac($msg1));
1960  }
1961 
1963  // Tests concerning quoteJSvalue
1965 
1970  public function ‪quoteJsValueDataProvider(): array
1971  {
1972  return [
1973  'Immune characters are returned as is' => [
1974  '._,',
1975  '._,',
1976  ],
1977  'Alphanumerical characters are returned as is' => [
1978  'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789',
1979  'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789',
1980  ],
1981  'Angle brackets and ampersand are encoded' => [
1982  '<>&',
1983  '\\u003C\\u003E\\u0026',
1984  ],
1985  'Quotes and backslashes are encoded' => [
1986  '"\'\\',
1987  '\\u0022\\u0027\\u005C',
1988  ],
1989  'Forward slashes are escaped' => [
1990  '</script>',
1991  '\\u003C\\/script\\u003E',
1992  ],
1993  'Empty string stays empty' => [
1994  '',
1995  '',
1996  ],
1997  'Exclamation mark and space are properly encoded' => [
1998  'Hello World!',
1999  'Hello\\u0020World\\u0021',
2000  ],
2001  'Whitespaces are properly encoded' => [
2002  "\t" . LF . CR . ' ',
2003  '\\u0009\\u000A\\u000D\\u0020',
2004  ],
2005  'Null byte is properly encoded' => [
2006  "\0",
2007  '\\u0000',
2008  ],
2009  'Umlauts are properly encoded' => [
2010  'ÜüÖöÄä',
2011  '\\u00dc\\u00fc\\u00d6\\u00f6\\u00c4\\u00e4',
2012  ],
2013  ];
2014  }
2015 
2022  public function ‪quoteJsValueTest(string $input, string $expected): void
2023  {
2024  self::assertSame('\'' . $expected . '\'', GeneralUtility::quoteJSvalue($input));
2025  }
2026 
2027  public static function ‪jsonEncodeForHtmlAttributeTestDataProvider(): array
2028  {
2029  return [
2030  [
2031  ['html' => '<tag attr="\\Vendor\\Package">value</tag>'],
2032  true,
2033  // cave: `\\\\` (four) actually required for PHP only, will be `\\` (two) in HTML
2034  '{&quot;html&quot;:&quot;\u003Ctag attr=\u0022\\\\Vendor\\\\Package\u0022\u003Evalue\u003C\/tag\u003E&quot;}',
2035  ],
2036  [
2037  ['html' => '<tag attr="\\Vendor\\Package">value</tag>'],
2038  false,
2039  // cave: `\\\\` (four) actually required for PHP only, will be `\\` (two) in HTML
2040  '{"html":"\u003Ctag attr=\u0022\\\\Vendor\\\\Package\u0022\u003Evalue\u003C\/tag\u003E"}',
2041  ],
2042  [
2043  ['spaces' => '|' . chr(9) . '|' . chr(10) . '|' . chr(13) . '|'],
2044  false,
2045  '{"spaces":"|\t|\n|\r|"}',
2046  ],
2047  ];
2048  }
2049 
2054  public function ‪jsonEncodeForHtmlAttributeTest($value, bool $useHtmlEntities, string $expectation): void
2055  {
2056  self::assertSame($expectation, GeneralUtility::jsonEncodeForHtmlAttribute($value, $useHtmlEntities));
2057  }
2058 
2059  public static function ‪jsonEncodeForJavaScriptTestDataProvider(): array
2060  {
2061  return [
2062  [
2063  ['html' => '<tag attr="\\Vendor\\Package">value</tag>'],
2064  // cave: `\\\\` (four) actually required for PHP only, will be `\\` (two) in JavaScript
2065  '{"html":"\u003Ctag attr=\u0022\\\\u005CVendor\\\\u005CPackage\u0022\u003Evalue\u003C\/tag\u003E"}',
2066  ],
2067  [
2068  ['spaces' => '|' . chr(9) . '|' . chr(10) . '|' . chr(13) . '|'],
2069  '{"spaces":"|\u0009|\u000A|\u000D|"}',
2070  ],
2071  ];
2072  }
2073 
2078  public function ‪jsonEncodeForJavaScriptTest($value, string $expectation): void
2079  {
2080  self::assertSame($expectation, GeneralUtility::jsonEncodeForJavaScript($value));
2081  }
2082 
2086  public function ‪fixPermissionsSetsPermissionsToFile(): void
2087  {
2088  if (‪Environment::isWindows()) {
2089  self::markTestSkipped(self::NO_FIX_PERMISSIONS_ON_WINDOWS);
2090  }
2091  // Create and prepare test file
2092  $filename = $this->‪getVirtualTestDir() . '/' . ‪StringUtility::getUniqueId('test_');
2094  chmod($filename, 482);
2095  // Set target permissions and run method
2096  ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['fileCreateMask'] = '0660';
2097  $fixPermissionsResult = ‪GeneralUtilityFilesystemFixture::fixPermissions($filename);
2098  clearstatcache();
2099  self::assertTrue($fixPermissionsResult);
2100  self::assertEquals('0660', substr(decoct(fileperms($filename)), 2));
2101  }
2102 
2106  public function ‪fixPermissionsSetsPermissionsToHiddenFile(): void
2107  {
2108  if (‪Environment::isWindows()) {
2109  self::markTestSkipped(self::NO_FIX_PERMISSIONS_ON_WINDOWS);
2110  }
2111  // Create and prepare test file
2112  $filename = $this->‪getVirtualTestDir() . '/' . ‪StringUtility::getUniqueId('test_');
2114  chmod($filename, 482);
2115  // Set target permissions and run method
2116  ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['fileCreateMask'] = '0660';
2117  $fixPermissionsResult = ‪GeneralUtilityFilesystemFixture::fixPermissions($filename);
2118  clearstatcache();
2119  self::assertTrue($fixPermissionsResult);
2120  self::assertEquals('0660', substr(decoct(fileperms($filename)), 2));
2121  }
2122 
2126  public function ‪fixPermissionsSetsPermissionsToDirectory(): void
2127  {
2128  if (‪Environment::isWindows()) {
2129  self::markTestSkipped(self::NO_FIX_PERMISSIONS_ON_WINDOWS);
2130  }
2131  // Create and prepare test directory
2132  $directory = $this->‪getVirtualTestDir() . '/' . ‪StringUtility::getUniqueId('test_');
2134  chmod($directory, 1551);
2135  // Set target permissions and run method
2136  ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['folderCreateMask'] = '0770';
2137  $fixPermissionsResult = ‪GeneralUtilityFilesystemFixture::fixPermissions($directory);
2138  clearstatcache();
2139  self::assertTrue($fixPermissionsResult);
2140  self::assertEquals('0770', substr(decoct(fileperms($directory)), 1));
2141  }
2142 
2147  {
2148  if (‪Environment::isWindows()) {
2149  self::markTestSkipped(self::NO_FIX_PERMISSIONS_ON_WINDOWS);
2150  }
2151  // Create and prepare test directory
2152  $directory = $this->‪getVirtualTestDir() . '/' . ‪StringUtility::getUniqueId('test_');
2154  chmod($directory, 1551);
2155  // Set target permissions and run method
2156  ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['folderCreateMask'] = '0770';
2157  $fixPermissionsResult = ‪GeneralUtilityFilesystemFixture::fixPermissions($directory . '/');
2158  // Get actual permissions and clean up
2159  clearstatcache();
2160  self::assertTrue($fixPermissionsResult);
2161  self::assertEquals('0770', substr(decoct(fileperms($directory)), 1));
2162  }
2163 
2168  {
2169  if (‪Environment::isWindows()) {
2170  self::markTestSkipped(self::NO_FIX_PERMISSIONS_ON_WINDOWS);
2171  }
2172  // Create and prepare test directory
2173  $directory = $this->‪getVirtualTestDir() . '/' . ‪StringUtility::getUniqueId('test_');
2175  chmod($directory, 1551);
2176  // Set target permissions and run method
2177  ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['folderCreateMask'] = '0770';
2178  $fixPermissionsResult = ‪GeneralUtilityFilesystemFixture::fixPermissions($directory);
2179  // Get actual permissions and clean up
2180  clearstatcache();
2181  self::assertTrue($fixPermissionsResult);
2182  self::assertEquals('0770', substr(decoct(fileperms($directory)), 1));
2183  }
2184 
2189  {
2190  if (‪Environment::isWindows()) {
2191  self::markTestSkipped(self::NO_FIX_PERMISSIONS_ON_WINDOWS);
2192  }
2193  // Create and prepare test directory and file structure
2194  $baseDirectory = $this->‪getVirtualTestDir() . '/' . ‪StringUtility::getUniqueId('test_');
2196  chmod($baseDirectory, 1751);
2197  ‪GeneralUtilityFilesystemFixture::writeFileToTypo3tempDir($baseDirectory . '/file', '42');
2198  chmod($baseDirectory . '/file', 482);
2199  ‪GeneralUtilityFilesystemFixture::mkdir($baseDirectory . '/foo');
2200  chmod($baseDirectory . '/foo', 1751);
2201  ‪GeneralUtilityFilesystemFixture::writeFileToTypo3tempDir($baseDirectory . '/foo/file', '42');
2202  chmod($baseDirectory . '/foo/file', 482);
2203  ‪GeneralUtilityFilesystemFixture::mkdir($baseDirectory . '/.bar');
2204  chmod($baseDirectory . '/.bar', 1751);
2205  // Use this if writeFileToTypo3tempDir is fixed to create hidden files in subdirectories
2206  // \TYPO3\CMS\Core\Utility\GeneralUtility::writeFileToTypo3tempDir($baseDirectory . '/.bar/.file', '42');
2207  // \TYPO3\CMS\Core\Utility\GeneralUtility::writeFileToTypo3tempDir($baseDirectory . '/.bar/..file2', '42');
2208  touch($baseDirectory . '/.bar/.file', 42);
2209  chmod($baseDirectory . '/.bar/.file', 482);
2210  touch($baseDirectory . '/.bar/..file2', 42);
2211  chmod($baseDirectory . '/.bar/..file2', 482);
2212  // Set target permissions and run method
2213  ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['fileCreateMask'] = '0660';
2214  ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['folderCreateMask'] = '0770';
2215  $fixPermissionsResult = ‪GeneralUtilityFilesystemFixture::fixPermissions($baseDirectory, true);
2216  // Get actual permissions
2217  clearstatcache();
2218  $resultBaseDirectoryPermissions = substr(decoct(fileperms($baseDirectory)), 1);
2219  $resultBaseFilePermissions = substr(decoct(fileperms($baseDirectory . '/file')), 2);
2220  $resultFooDirectoryPermissions = substr(decoct(fileperms($baseDirectory . '/foo')), 1);
2221  $resultFooFilePermissions = substr(decoct(fileperms($baseDirectory . '/foo/file')), 2);
2222  $resultBarDirectoryPermissions = substr(decoct(fileperms($baseDirectory . '/.bar')), 1);
2223  $resultBarFilePermissions = substr(decoct(fileperms($baseDirectory . '/.bar/.file')), 2);
2224  $resultBarFile2Permissions = substr(decoct(fileperms($baseDirectory . '/.bar/..file2')), 2);
2225  // Test if everything was ok
2226  self::assertTrue($fixPermissionsResult);
2227  self::assertEquals('0770', $resultBaseDirectoryPermissions);
2228  self::assertEquals('0660', $resultBaseFilePermissions);
2229  self::assertEquals('0770', $resultFooDirectoryPermissions);
2230  self::assertEquals('0660', $resultFooFilePermissions);
2231  self::assertEquals('0770', $resultBarDirectoryPermissions);
2232  self::assertEquals('0660', $resultBarFilePermissions);
2233  self::assertEquals('0660', $resultBarFile2Permissions);
2234  }
2235 
2240  {
2241  if (‪Environment::isWindows()) {
2242  self::markTestSkipped(self::NO_FIX_PERMISSIONS_ON_WINDOWS);
2243  }
2244  // Create and prepare test file
2245  $filename = ‪Environment::getVarPath() . '/tests/../../../typo3temp/var/tests/' . ‪StringUtility::getUniqueId('test_');
2246  // Set target permissions and run method
2247  ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['fileCreateMask'] = '0660';
2248  $fixPermissionsResult = ‪GeneralUtility::fixPermissions($filename);
2249  self::assertFalse($fixPermissionsResult);
2250  }
2251 
2256  {
2257  if (‪Environment::isWindows()) {
2258  self::markTestSkipped(self::NO_FIX_PERMISSIONS_ON_WINDOWS);
2259  }
2260  $filename = 'typo3temp/var/tests/' . ‪StringUtility::getUniqueId('test_');
2262  $this->testFilesToDelete[] = ‪Environment::getPublicPath() . '/' . $filename;
2263  chmod(‪Environment::getPublicPath() . '/' . $filename, 482);
2264  // Set target permissions and run method
2265  ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['fileCreateMask'] = '0660';
2266  $fixPermissionsResult = ‪GeneralUtility::fixPermissions($filename);
2267  clearstatcache();
2268  self::assertTrue($fixPermissionsResult);
2269  self::assertEquals('0660', substr(decoct(fileperms(‪Environment::getPublicPath() . '/' . $filename)), 2));
2270  }
2271 
2275  public function ‪fixPermissionsSetsDefaultPermissionsToFile(): void
2276  {
2277  if (‪Environment::isWindows()) {
2278  self::markTestSkipped(self::NO_FIX_PERMISSIONS_ON_WINDOWS);
2279  }
2280  $filename = $this->‪getVirtualTestDir() . '/' . ‪StringUtility::getUniqueId('test_');
2282  chmod($filename, 482);
2283  unset(‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['fileCreateMask']);
2284  $fixPermissionsResult = ‪GeneralUtilityFilesystemFixture::fixPermissions($filename);
2285  clearstatcache();
2286  self::assertTrue($fixPermissionsResult);
2287  self::assertEquals('0644', substr(decoct(fileperms($filename)), 2));
2288  }
2289 
2294  {
2295  if (‪Environment::isWindows()) {
2296  self::markTestSkipped(self::NO_FIX_PERMISSIONS_ON_WINDOWS);
2297  }
2298  $directory = $this->‪getVirtualTestDir() . '/' . ‪StringUtility::getUniqueId('test_');
2300  chmod($directory, 1551);
2301  unset(‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['folderCreateMask']);
2302  $fixPermissionsResult = ‪GeneralUtilityFilesystemFixture::fixPermissions($directory);
2303  clearstatcache();
2304  self::assertTrue($fixPermissionsResult);
2305  self::assertEquals('0755', substr(decoct(fileperms($directory)), 1));
2306  }
2307 
2309  // Tests concerning mkdir
2314  public function ‪mkdirCreatesDirectory(): void
2315  {
2316  $directory = $this->‪getVirtualTestDir() . '/' . ‪StringUtility::getUniqueId('test_');
2317  $mkdirResult = ‪GeneralUtilityFilesystemFixture::mkdir($directory);
2318  clearstatcache();
2319  self::assertTrue($mkdirResult);
2320  self::assertDirectoryExists($directory);
2321  }
2322 
2326  public function ‪mkdirCreatesHiddenDirectory(): void
2327  {
2328  $directory = $this->‪getVirtualTestDir() . '/' . ‪StringUtility::getUniqueId('.test_');
2329  $mkdirResult = ‪GeneralUtilityFilesystemFixture::mkdir($directory);
2330  clearstatcache();
2331  self::assertTrue($mkdirResult);
2332  self::assertDirectoryExists($directory);
2333  }
2334 
2338  public function ‪mkdirCreatesDirectoryWithTrailingSlash(): void
2339  {
2340  $directory = $this->‪getVirtualTestDir() . '/' . ‪StringUtility::getUniqueId('test_') . '/';
2341  $mkdirResult = ‪GeneralUtilityFilesystemFixture::mkdir($directory);
2342  clearstatcache();
2343  self::assertTrue($mkdirResult);
2344  self::assertDirectoryExists($directory);
2345  }
2346 
2350  public function ‪mkdirSetsPermissionsOfCreatedDirectory(): void
2351  {
2352  if (‪Environment::isWindows()) {
2353  self::markTestSkipped(self::NO_FIX_PERMISSIONS_ON_WINDOWS);
2354  }
2355  $directory = $this->‪getVirtualTestDir() . '/' . ‪StringUtility::getUniqueId('test_');
2356  $oldUmask = umask(19);
2357  ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['folderCreateMask'] = '0772';
2359  clearstatcache();
2360  $resultDirectoryPermissions = substr(decoct(fileperms($directory)), 1);
2361  umask($oldUmask);
2362  self::assertEquals('0772', $resultDirectoryPermissions);
2363  }
2364 
2366  // Tests concerning writeFileToTypo3tempDir()
2368 
2372  public function ‪invalidFilePathForTypo3tempDirDataProvider(): array
2373  {
2374  return [
2375  [
2376  ‪Environment::getPublicPath() . '/../path/this-path-has-more-than-60-characters-in-one-base-path-you-can-even-count-more',
2377  'Input filepath "' . ‪Environment::getPublicPath() . '/../path/this-path-has-more-than-60-characters-in-one-base-path-you-can-even-count-more" was generally invalid!',
2378  ],
2379  [
2380  ‪Environment::getPublicPath() . '/dummy/path/this-path-has-more-than-60-characters-in-one-base-path-you-can-even-count-more',
2381  '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!',
2382  ],
2383  [
2384  ‪Environment::getPublicPath() . '/dummy/path/this-path-has-more-than-60-characters-in-one-base-path-you-can-even-count-more',
2385  '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!',
2386  ],
2387  [
2388  '/dummy/path/awesome',
2389  '"/dummy/path/" was not within directory Environment::getPublicPath() + "/typo3temp/"',
2390  ],
2391  [
2393  '"' . ‪Environment::getLegacyConfigPath() . '/" was not within directory Environment::getPublicPath() + "/typo3temp/"',
2394  ],
2395  [
2396  ‪Environment::getPublicPath() . '/typo3temp/táylor/swíft',
2397  'Subdir, "táylor/", was NOT on the form "[[:alnum:]_]/+"',
2398  ],
2399  'Path instead of file given' => [
2400  ‪Environment::getPublicPath() . '/typo3temp/dummy/path/',
2401  'Calculated file location didn\'t match input "' . ‪Environment::getPublicPath() . '/typo3temp/dummy/path/".',
2402  ],
2403  ];
2404  }
2405 
2412  public function ‪writeFileToTypo3tempDirFailsWithInvalidPath(string $invalidFilePath, string $expectedResult): void
2413  {
2414  $result = ‪GeneralUtility::writeFileToTypo3tempDir($invalidFilePath, 'dummy content to be written');
2415  self::assertSame($result, $expectedResult);
2416  }
2417 
2421  public function ‪validFilePathForTypo3tempDirDataProvider(): array
2422  {
2423  return [
2424  'Default text file' => [
2425  ‪Environment::getVarPath() . '/paranoid/android.txt',
2426  ],
2427  'Html file extension' => [
2428  ‪Environment::getVarPath() . '/karma.html',
2429  ],
2430  'No file extension' => [
2431  ‪Environment::getVarPath() . '/no-surprises',
2432  ],
2433  'Deep directory' => [
2434  ‪Environment::getVarPath() . '/climbing/up/the/walls',
2435  ],
2436  'File in typo3temp/var directory' => [
2437  ‪Environment::getPublicPath() . '/typo3temp/var/path/foo.txt',
2438  ],
2439  ];
2440  }
2441 
2447  public function ‪writeFileToTypo3tempDirWorksWithValidPath(string $filePath): void
2448  {
2449  $dummyContent = 'Please could you stop the noise, I\'m trying to get some rest from all the unborn chicken voices in my head.';
2450 
2451  $this->testFilesToDelete[] = $filePath;
2452 
2453  $result = ‪GeneralUtility::writeFileToTypo3tempDir($filePath, $dummyContent);
2454 
2455  self::assertNull($result);
2456  self::assertFileExists($filePath);
2457  self::assertStringEqualsFile($filePath, $dummyContent);
2458  }
2459 
2461  // Tests concerning mkdir_deep
2466  public function ‪mkdirDeepCreatesDirectory(): void
2467  {
2468  $directory = $this->‪getVirtualTestDir() . '/' . ‪StringUtility::getUniqueId('test_');
2469  ‪GeneralUtility::mkdir_deep($directory);
2470  self::assertDirectoryExists($directory);
2471  }
2472 
2476  public function ‪mkdirDeepCreatesSubdirectoriesRecursive(): void
2477  {
2478  $directory = $this->‪getVirtualTestDir() . 'typo3temp/var/tests/' . ‪StringUtility::getUniqueId('test_');
2479  $subDirectory = $directory . '/foo';
2480  ‪GeneralUtility::mkdir_deep($subDirectory);
2481  self::assertDirectoryExists($subDirectory);
2482  }
2483 
2489  {
2490  return [
2491  'no double slash if concatenated with Environment::getPublicPath()' => ['fileadmin/testDir1'],
2492  'double slash if concatenated with Environment::getPublicPath()' => ['/fileadmin/testDir2'],
2493  ];
2494  }
2495 
2500  public function ‪mkdirDeepCreatesDirectoryWithDoubleSlashes($directoryToCreate): void
2501  {
2502  vfsStream::setup('root', null, ['public' => []]);
2503  ‪GeneralUtility::mkdir_deep('vfs://root/public/' . $directoryToCreate);
2504  self::assertDirectoryExists('vfs://root/public/' . $directoryToCreate);
2505  }
2506 
2510  public function ‪mkdirDeepFixesPermissionsOfCreatedDirectory(): void
2511  {
2512  if (‪Environment::isWindows()) {
2513  self::markTestSkipped(self::NO_FIX_PERMISSIONS_ON_WINDOWS);
2514  }
2515  $directory = ‪StringUtility::getUniqueId('mkdirdeeptest_');
2516  $oldUmask = umask(19);
2517  ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['folderCreateMask'] = '0777';
2518  ‪GeneralUtility::mkdir_deep(‪Environment::getVarPath() . '/tests/' . $directory);
2519  $this->testFilesToDelete[] = ‪Environment::getVarPath() . '/tests/' . $directory;
2520  clearstatcache();
2521  umask($oldUmask);
2522  self::assertEquals('777', substr(decoct(fileperms(‪Environment::getVarPath() . '/tests/' . $directory)), -3, 3));
2523  }
2524 
2528  public function ‪mkdirDeepFixesPermissionsOnNewParentDirectory(): void
2529  {
2530  if (‪Environment::isWindows()) {
2531  self::markTestSkipped(self::NO_FIX_PERMISSIONS_ON_WINDOWS);
2532  }
2533  $directory = ‪StringUtility::getUniqueId('mkdirdeeptest_');
2534  $subDirectory = $directory . '/bar';
2535  ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['folderCreateMask'] = '0777';
2536  $oldUmask = umask(19);
2537  ‪GeneralUtility::mkdir_deep(‪Environment::getVarPath() . '/tests/' . $subDirectory);
2538  $this->testFilesToDelete[] = ‪Environment::getVarPath() . '/tests/' . $directory;
2539  clearstatcache();
2540  umask($oldUmask);
2541  self::assertEquals('777', substr(decoct(fileperms(‪Environment::getVarPath() . '/tests/' . $directory)), -3, 3));
2542  }
2543 
2548  {
2549  if (‪Environment::isWindows()) {
2550  self::markTestSkipped(self::NO_FIX_PERMISSIONS_ON_WINDOWS);
2551  }
2552  $baseDirectory = ‪Environment::getVarPath() . '/tests/';
2553  $existingDirectory = ‪StringUtility::getUniqueId('test_existing_') . '/';
2554  $newSubDirectory = ‪StringUtility::getUniqueId('test_new_');
2555  @mkdir($baseDirectory . $existingDirectory);
2556  $this->testFilesToDelete[] = $baseDirectory . $existingDirectory;
2557  chmod($baseDirectory . $existingDirectory, 482);
2558  ‪GeneralUtility::mkdir_deep($baseDirectory . $existingDirectory . $newSubDirectory);
2559  self::assertEquals(742, (int)substr(decoct(fileperms($baseDirectory . $existingDirectory)), 2));
2560  }
2561 
2565  public function ‪mkdirDeepCreatesDirectoryInVfsStream(): void
2566  {
2567  vfsStreamWrapper::register();
2568  $baseDirectory = ‪StringUtility::getUniqueId('test_');
2569  vfsStreamWrapper::setRoot(new vfsStreamDirectory($baseDirectory));
2570  ‪GeneralUtility::mkdir_deep('vfs://' . $baseDirectory . '/sub');
2571  self::assertDirectoryExists('vfs://' . $baseDirectory . '/sub');
2572  }
2573 
2578  {
2579  $this->expectException(\RuntimeException::class);
2580  $this->expectExceptionCode(1170251401);
2581 
2582  ‪GeneralUtility::mkdir_deep('http://localhost');
2583  }
2584 
2589  {
2590  $this->expectException(\InvalidArgumentException::class);
2591  $this->expectExceptionCode(1303662955);
2592 
2593  // @phpstan-ignore-next-line We're explicitly checking the behavior for a contract violation.
2595  }
2596 
2598  // Tests concerning rmdir
2600 
2604  public function ‪rmdirRemovesFile(): void
2605  {
2606  $file = ‪Environment::getVarPath() . '/tests/' . ‪StringUtility::getUniqueId('file_');
2607  touch($file);
2608  ‪GeneralUtility::rmdir($file);
2609  self::assertFileDoesNotExist($file);
2610  }
2611 
2615  public function ‪rmdirReturnTrueIfFileWasRemoved(): void
2616  {
2617  $file = ‪Environment::getVarPath() . '/tests/' . ‪StringUtility::getUniqueId('file_');
2618  touch($file);
2619  self::assertTrue(‪GeneralUtility::rmdir($file));
2620  }
2621 
2625  public function ‪rmdirReturnFalseIfNoFileWasRemoved(): void
2626  {
2627  $file = ‪Environment::getVarPath() . '/tests/' . ‪StringUtility::getUniqueId('file_');
2628  self::assertFalse(‪GeneralUtility::rmdir($file));
2629  }
2630 
2634  public function ‪rmdirRemovesDirectory(): void
2635  {
2636  $directory = ‪Environment::getVarPath() . '/tests/' . ‪StringUtility::getUniqueId('directory_');
2637  mkdir($directory);
2638  ‪GeneralUtility::rmdir($directory);
2639  self::assertFileDoesNotExist($directory);
2640  }
2641 
2645  public function ‪rmdirRemovesDirectoryWithTrailingSlash(): void
2646  {
2647  $directory = ‪Environment::getVarPath() . '/tests/' . ‪StringUtility::getUniqueId('directory_') . '/';
2648  mkdir($directory);
2649  ‪GeneralUtility::rmdir($directory);
2650  self::assertFileDoesNotExist($directory);
2651  }
2652 
2657  {
2658  $directory = ‪Environment::getVarPath() . '/tests/' . ‪StringUtility::getUniqueId('directory_') . '/';
2659  mkdir($directory);
2660  $file = ‪StringUtility::getUniqueId('file_');
2661  touch($directory . $file);
2662  $this->testFilesToDelete[] = $directory;
2663  $return = ‪GeneralUtility::rmdir($directory);
2664  self::assertFileExists($directory);
2665  self::assertFileExists($directory . $file);
2666  self::assertFalse($return);
2667  }
2668 
2673  {
2674  $directory = ‪Environment::getVarPath() . '/tests/' . ‪StringUtility::getUniqueId('directory_') . '/';
2675  mkdir($directory);
2676  mkdir($directory . 'sub/');
2677  touch($directory . 'sub/file');
2678  $return = ‪GeneralUtility::rmdir($directory, true);
2679  self::assertFileDoesNotExist($directory);
2680  self::assertTrue($return);
2681  }
2682 
2686  public function ‪rmdirRemovesLinkToDirectory(): void
2687  {
2688  $existingDirectory = ‪Environment::getVarPath() . '/tests/' . ‪StringUtility::getUniqueId('notExists_') . '/';
2689  mkdir($existingDirectory);
2690  $this->testFilesToDelete[] = $existingDirectory;
2691  $symlinkName = ‪Environment::getVarPath() . '/tests/' . ‪StringUtility::getUniqueId('link_');
2692  symlink($existingDirectory, $symlinkName);
2693  ‪GeneralUtility::rmdir($symlinkName, true);
2694  self::assertFalse(is_link($symlinkName));
2695  }
2696 
2700  public function ‪rmdirRemovesDeadLinkToDirectory(): void
2701  {
2702  $notExistingDirectory = ‪Environment::getVarPath() . '/tests/' . ‪StringUtility::getUniqueId('notExists_') . '/';
2703  $symlinkName = ‪Environment::getVarPath() . '/tests/' . ‪StringUtility::getUniqueId('link_');
2704  mkdir($notExistingDirectory);
2705  symlink($notExistingDirectory, $symlinkName);
2706  rmdir($notExistingDirectory);
2707 
2708  ‪GeneralUtility::rmdir($symlinkName, true);
2709  self::assertFalse(is_link($symlinkName));
2710  }
2711 
2715  public function ‪rmdirRemovesDeadLinkToFile(): void
2716  {
2717  $notExistingFile = ‪Environment::getVarPath() . '/tests/' . ‪StringUtility::getUniqueId('notExists_');
2718  $symlinkName = ‪Environment::getVarPath() . '/tests/' . ‪StringUtility::getUniqueId('link_');
2719  touch($notExistingFile);
2720  symlink($notExistingFile, $symlinkName);
2721  unlink($notExistingFile);
2722  ‪GeneralUtility::rmdir($symlinkName, true);
2723  self::assertFalse(is_link($symlinkName));
2724  }
2725 
2727  // Tests concerning getFilesInDir
2729 
2735  protected function ‪getFilesInDirCreateTestDirectory(): string
2736  {
2737  $structure = [
2738  'subDirectory' => [
2739  'test.php' => 'butter',
2740  'other.php' => 'milk',
2741  'stuff.csv' => 'honey',
2742  ],
2743  'excludeMe.txt' => 'cocoa nibs',
2744  'double.setup.typoscript' => 'cool TS',
2745  'testB.txt' => 'olive oil',
2746  'testA.txt' => 'eggs',
2747  'testC.txt' => 'carrots',
2748  'test.js' => 'oranges',
2749  'test.css' => 'apples',
2750  '.secret.txt' => 'sammon',
2751  ];
2752  vfsStream::setup('test', null, $structure);
2753  $vfsUrl = vfsStream::url('test');
2754 
2755  // set random values for mtime
2756  foreach ($structure as $structureLevel1Key => $structureLevel1Content) {
2757  $newMtime = random_int(0, mt_getrandmax());
2758  if (is_array($structureLevel1Content)) {
2759  foreach ($structureLevel1Content as $structureLevel2Key => $structureLevel2Content) {
2760  touch($vfsUrl . '/' . $structureLevel1Key . '/' . $structureLevel2Key, $newMtime);
2761  }
2762  } else {
2763  touch($vfsUrl . '/' . $structureLevel1Key, $newMtime);
2764  }
2765  }
2766 
2767  return $vfsUrl;
2768  }
2769 
2773  public function ‪getFilesInDirFindsRegularFile(): void
2774  {
2775  $vfsStreamUrl = $this->‪getFilesInDirCreateTestDirectory();
2776  $files = GeneralUtility::getFilesInDir($vfsStreamUrl);
2777  self::assertContains('testA.txt', $files);
2778  }
2779 
2783  public function ‪getFilesInDirFindsHiddenFile(): void
2784  {
2785  $vfsStreamUrl = $this->‪getFilesInDirCreateTestDirectory();
2786  $files = GeneralUtility::getFilesInDir($vfsStreamUrl);
2787  self::assertContains('.secret.txt', $files);
2788  }
2789 
2795  public function ‪fileExtensionDataProvider(): array
2796  {
2797  return [
2798  'no space' => [
2799  'setup.typoscript,txt,js,css',
2800  ],
2801  'spaces' => [
2802  'setup.typoscript, txt, js, css',
2803  ],
2804  'mixed' => [
2805  'setup.typoscript , txt,js, css',
2806  ],
2807  'wild' => [
2808  'setup.typoscript, txt, js , css',
2809  ],
2810  ];
2811  }
2812 
2817  public function ‪getFilesInDirByExtensionFindsFiles($fileExtensions): void
2818  {
2819  $vfsStreamUrl = $this->‪getFilesInDirCreateTestDirectory();
2820  $files = GeneralUtility::getFilesInDir($vfsStreamUrl, $fileExtensions);
2821  self::assertContains('double.setup.typoscript', $files);
2822  self::assertContains('testA.txt', $files);
2823  self::assertContains('test.js', $files);
2824  self::assertContains('test.css', $files);
2825  }
2826 
2831  {
2832  $vfsStreamUrl = $this->‪getFilesInDirCreateTestDirectory();
2833  $files = GeneralUtility::getFilesInDir($vfsStreamUrl, 'txt,js');
2834  self::assertContains('testA.txt', $files);
2835  self::assertContains('test.js', $files);
2836  self::assertNotContains('test.css', $files);
2837  }
2838 
2842  public function ‪getFilesInDirExcludesFilesMatchingPattern(): void
2843  {
2844  $vfsStreamUrl = $this->‪getFilesInDirCreateTestDirectory();
2845  $files = GeneralUtility::getFilesInDir($vfsStreamUrl, '', false, '', 'excludeMe.*');
2846  self::assertContains('test.js', $files);
2847  self::assertNotContains('excludeMe.txt', $files);
2848  }
2849 
2853  public function ‪getFilesInDirCanPrependPath(): void
2854  {
2855  $vfsStreamUrl = $this->‪getFilesInDirCreateTestDirectory();
2856  self::assertContains(
2857  $vfsStreamUrl . '/testA.txt',
2858  GeneralUtility::getFilesInDir($vfsStreamUrl, '', true)
2859  );
2860  }
2861 
2865  public function ‪getFilesInDirDoesSortAlphabeticallyByDefault(): void
2866  {
2867  $vfsStreamUrl = $this->‪getFilesInDirCreateTestDirectory();
2868  self::assertSame(
2869  array_values(GeneralUtility::getFilesInDir($vfsStreamUrl, '', false)),
2870  ['.secret.txt', 'double.setup.typoscript', 'excludeMe.txt', 'test.css', 'test.js', 'testA.txt', 'testB.txt', 'testC.txt']
2871  );
2872  }
2873 
2877  public function ‪getFilesInDirCanOrderByMtime(): void
2878  {
2879  $vfsStreamUrl = $this->‪getFilesInDirCreateTestDirectory();
2880  $files = [];
2881  $iterator = new \DirectoryIterator($vfsStreamUrl);
2882  foreach ($iterator as $fileinfo) {
2883  if ($fileinfo->isFile()) {
2884  $files[$fileinfo->getFilename()] = $fileinfo->getMTime();
2885  }
2886  }
2887  asort($files);
2888  self::assertSame(
2889  array_values(GeneralUtility::getFilesInDir($vfsStreamUrl, '', false, 'mtime')),
2890  array_keys($files)
2891  );
2892  }
2893 
2898  {
2899  $vfsStreamUrl = $this->‪getFilesInDirCreateTestDirectory();
2900  self::assertArrayHasKey(
2901  md5($vfsStreamUrl . '/testA.txt'),
2902  GeneralUtility::getFilesInDir($vfsStreamUrl)
2903  );
2904  }
2905 
2909  public function ‪getFilesInDirDoesNotFindDirectories(): void
2910  {
2911  $vfsStreamUrl = $this->‪getFilesInDirCreateTestDirectory();
2912  self::assertNotContains(
2913  'subDirectory',
2914  GeneralUtility::getFilesInDir($vfsStreamUrl)
2915  );
2916  }
2917 
2924  public function ‪getFilesInDirDoesNotFindDotfiles(): void
2925  {
2926  $vfsStreamUrl = $this->‪getFilesInDirCreateTestDirectory();
2927  $files = GeneralUtility::getFilesInDir($vfsStreamUrl);
2928  self::assertNotContains('..', $files);
2929  self::assertNotContains('.', $files);
2930  }
2931 
2933  // Tests concerning split_fileref
2938  public function ‪splitFileRefReturnsFileTypeNotForFolders(): void
2939  {
2940  $directoryName = ‪StringUtility::getUniqueId('test_') . '.com';
2941  $directoryPath = ‪Environment::getVarPath() . '/tests/';
2942  $directory = $directoryPath . $directoryName;
2943  mkdir($directory, octdec(‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['folderCreateMask']));
2944  $fileInfo = GeneralUtility::split_fileref($directory);
2945  $directoryCreated = is_dir($directory);
2946  rmdir($directory);
2947  self::assertTrue($directoryCreated);
2948  self::assertIsArray($fileInfo);
2949  self::assertEquals($directoryPath, $fileInfo['path']);
2950  self::assertEquals($directoryName, $fileInfo['file']);
2951  self::assertEquals($directoryName, $fileInfo['filebody']);
2952  self::assertEquals('', $fileInfo['fileext']);
2953  self::assertArrayNotHasKey('realFileext', $fileInfo);
2954  }
2955 
2960  {
2961  $testFile = 'fileadmin/media/someFile.png';
2962  $fileInfo = GeneralUtility::split_fileref($testFile);
2963  self::assertIsArray($fileInfo);
2964  self::assertEquals('fileadmin/media/', $fileInfo['path']);
2965  self::assertEquals('someFile.png', $fileInfo['file']);
2966  self::assertEquals('someFile', $fileInfo['filebody']);
2967  self::assertEquals('png', $fileInfo['fileext']);
2968  }
2969 
2971  // Tests concerning dirname
2973 
2977  public function ‪dirnameDataProvider(): array
2978  {
2979  return [
2980  'absolute path with multiple part and file' => ['/dir1/dir2/script.php', '/dir1/dir2'],
2981  'absolute path with one part' => ['/dir1/', '/dir1'],
2982  'absolute path to file without extension' => ['/dir1/something', '/dir1'],
2983  'relative path with one part and file' => ['dir1/script.php', 'dir1'],
2984  'relative one-character path with one part and file' => ['d/script.php', 'd'],
2985  'absolute zero-part path with file' => ['/script.php', ''],
2986  'empty string' => ['', ''],
2987  ];
2988  }
2989 
2996  public function ‪dirnameWithDataProvider(string $input, string $expectedValue): void
2997  {
2998  self::assertEquals($expectedValue, GeneralUtility::dirname($input));
2999  }
3000 
3002  // Tests concerning resolveBackPath
3004 
3008  public function ‪resolveBackPathDataProvider(): array
3009  {
3010  return [
3011  'empty path' => ['', ''],
3012  'this directory' => ['./', './'],
3013  'relative directory without ..' => ['dir1/dir2/dir3/', 'dir1/dir2/dir3/'],
3014  'relative path without ..' => ['dir1/dir2/script.php', 'dir1/dir2/script.php'],
3015  'absolute directory without ..' => ['/dir1/dir2/dir3/', '/dir1/dir2/dir3/'],
3016  'absolute path without ..' => ['/dir1/dir2/script.php', '/dir1/dir2/script.php'],
3017  'only one directory upwards without trailing slash' => ['..', '..'],
3018  'only one directory upwards with trailing slash' => ['../', '../'],
3019  'one level with trailing ..' => ['dir1/..', ''],
3020  'one level with trailing ../' => ['dir1/../', ''],
3021  'two levels with trailing ..' => ['dir1/dir2/..', 'dir1'],
3022  'two levels with trailing ../' => ['dir1/dir2/../', 'dir1/'],
3023  'leading ../ without trailing /' => ['../dir1', '../dir1'],
3024  'leading ../ with trailing /' => ['../dir1/', '../dir1/'],
3025  'leading ../ and inside path' => ['../dir1/dir2/../dir3/', '../dir1/dir3/'],
3026  'one times ../ in relative directory' => ['dir1/../dir2/', 'dir2/'],
3027  'one times ../ in absolute directory' => ['/dir1/../dir2/', '/dir2/'],
3028  'one times ../ in relative path' => ['dir1/../dir2/script.php', 'dir2/script.php'],
3029  'one times ../ in absolute path' => ['/dir1/../dir2/script.php', '/dir2/script.php'],
3030  'consecutive ../' => ['dir1/dir2/dir3/../../../dir4', 'dir4'],
3031  'distributed ../ with trailing /' => ['dir1/../dir2/dir3/../', 'dir2/'],
3032  'distributed ../ without trailing /' => ['dir1/../dir2/dir3/..', 'dir2'],
3033  'multiple distributed and consecutive ../ together' => ['dir1/dir2/dir3/dir4/../../dir5/dir6/dir7/../dir8/', 'dir1/dir2/dir5/dir6/dir8/'],
3034  'dirname with leading ..' => ['dir1/..dir2/dir3/', 'dir1/..dir2/dir3/'],
3035  'dirname with trailing ..' => ['dir1/dir2../dir3/', 'dir1/dir2../dir3/'],
3036  'more times upwards than downwards in directory' => ['dir1/../../', '../'],
3037  'more times upwards than downwards in path' => ['dir1/../../script.php', '../script.php'],
3038  ];
3039  }
3040 
3047  public function ‪resolveBackPathWithDataProvider(string $input, string $expectedValue): void
3048  {
3049  self::assertEquals($expectedValue, GeneralUtility::resolveBackPath($input));
3050  }
3051 
3053  // Tests concerning makeInstance, setSingletonInstance, addInstance, purgeInstances
3058  public function ‪makeInstanceWithEmptyClassNameThrowsException(): void
3059  {
3060  $this->expectException(\InvalidArgumentException::class);
3061  $this->expectExceptionCode(1288965219);
3062 
3063  GeneralUtility::makeInstance('');
3064  }
3065 
3069  public function ‪makeInstanceWithNullClassNameThrowsException(): void
3070  {
3071  $this->expectException(\InvalidArgumentException::class);
3072  $this->expectExceptionCode(1288965219);
3073 
3074  // @phpstan-ignore-next-line We're explicitly checking the behavior for a contract violation.
3075  GeneralUtility::makeInstance(null);
3076  }
3077 
3082  {
3083  $this->expectException(\InvalidArgumentException::class);
3084  $this->expectExceptionCode(1288965219);
3085 
3086  // @phpstan-ignore-next-line We're explicitly checking the behavior for a contract violation.
3087  GeneralUtility::makeInstance(0);
3088  }
3089 
3093  public function ‪makeInstanceWithEmptyArrayThrowsException(): void
3094  {
3095  $this->expectException(\InvalidArgumentException::class);
3096  $this->expectExceptionCode(1288965219);
3097 
3098  // @phpstan-ignore-next-line We're explicitly checking the behavior for a contract violation.
3099  GeneralUtility::makeInstance([]);
3100  }
3101 
3105  public function ‪makeInstanceWithNonEmptyArrayThrowsException(): void
3106  {
3107  $this->expectException(\InvalidArgumentException::class);
3108  $this->expectExceptionCode(1288965219);
3109 
3110  // @phpstan-ignore-next-line We're explicitly checking the behavior for a contract violation.
3111  GeneralUtility::makeInstance(['foo']);
3112  }
3113 
3118  {
3119  $this->expectException(\InvalidArgumentException::class);
3120  $this->expectExceptionCode(1420281366);
3121 
3122  GeneralUtility::makeInstance('\\TYPO3\\CMS\\Backend\\Controller\\BackendController');
3123  }
3124 
3128  public function ‪makeInstanceReturnsClassInstance(): void
3129  {
3130  self::assertInstanceOf(\stdClass::class, GeneralUtility::makeInstance(\stdClass::class));
3131  }
3132 
3136  public function ‪makeInstancePassesParametersToConstructor(): void
3137  {
3138  $instance = GeneralUtility::makeInstance(TwoParametersConstructorFixture::class, 'one parameter', 'another parameter');
3139  self::assertEquals('one parameter', $instance->constructorParameter1, 'The first constructor parameter has not been set.');
3140  self::assertEquals('another parameter', $instance->constructorParameter2, 'The second constructor parameter has not been set.');
3141  }
3142 
3147  {
3149  ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects'][OriginalClassFixture::class] = ['className' => ReplacementClassFixture::class];
3150  self::assertInstanceOf(ReplacementClassFixture::class, GeneralUtility::makeInstance(OriginalClassFixture::class));
3151  }
3152 
3157  {
3159  ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects'][OriginalClassFixture::class] = ['className' => ReplacementClassFixture::class];
3160  ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects'][ReplacementClassFixture::class] = ['className' => OtherReplacementClassFixture::class];
3161  self::assertInstanceOf(OtherReplacementClassFixture::class, GeneralUtility::makeInstance(OriginalClassFixture::class));
3162  }
3163 
3168  {
3169  $className = \stdClass::class;
3170  self::assertNotSame(GeneralUtility::makeInstance($className), GeneralUtility::makeInstance($className));
3171  }
3172 
3177  {
3178  $className = get_class($this->createMock(SingletonInterface::class));
3179  self::assertSame(GeneralUtility::makeInstance($className), GeneralUtility::makeInstance($className));
3180  }
3181 
3186  {
3187  $className = get_class($this->createMock(SingletonInterface::class));
3188  $instance = GeneralUtility::makeInstance($className);
3189  GeneralUtility::purgeInstances();
3190  self::assertNotSame($instance, GeneralUtility::makeInstance($className));
3191  }
3192 
3196  public function ‪makeInstanceInjectsLogger(): void
3197  {
3198  $instance = GeneralUtility::makeInstance(GeneralUtilityMakeInstanceInjectLoggerFixture::class);
3199  self::assertInstanceOf(LoggerInterface::class, $instance->getLogger());
3200  }
3201 
3206  {
3207  $this->expectException(\InvalidArgumentException::class);
3208  $this->expectExceptionCode(1288967479);
3209 
3210  $instance = $this->createMock(SingletonInterface::class);
3211  GeneralUtility::setSingletonInstance('', $instance);
3212  }
3213 
3218  {
3219  $this->expectException(\InvalidArgumentException::class);
3220  $this->expectExceptionCode(1288967686);
3221 
3222  $instance = $this->getMockBuilder(SingletonInterface::class)
3223  ->addMethods(['foo'])
3224  ->getMock();
3225  $singletonClassName = get_class($this->createMock(SingletonInterface::class));
3226  GeneralUtility::setSingletonInstance($singletonClassName, $instance);
3227  }
3228 
3233  {
3234  $instance = $this->createMock(SingletonInterface::class);
3235  $singletonClassName = get_class($instance);
3236  GeneralUtility::setSingletonInstance($singletonClassName, $instance);
3237  self::assertSame($instance, GeneralUtility::makeInstance($singletonClassName));
3238  }
3239 
3244  {
3245  $instance1 = $this->createMock(SingletonInterface::class);
3246  $singletonClassName = get_class($instance1);
3247  $instance2 = new $singletonClassName();
3248  GeneralUtility::setSingletonInstance($singletonClassName, $instance1);
3249  GeneralUtility::setSingletonInstance($singletonClassName, $instance2);
3250  self::assertSame($instance2, GeneralUtility::makeInstance($singletonClassName));
3251  }
3252 
3257  {
3258  $instance = $this->createMock(SingletonInterface::class);
3259  $instanceClassName = get_class($instance);
3260  GeneralUtility::setSingletonInstance($instanceClassName, $instance);
3261  $registeredSingletonInstances = GeneralUtility::getSingletonInstances();
3262  self::assertArrayHasKey($instanceClassName, $registeredSingletonInstances);
3263  self::assertSame($registeredSingletonInstances[$instanceClassName], $instance);
3264  }
3265 
3270  {
3271  ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects'][SingletonClassFixture::class]['className'] = ExtendedSingletonClassFixture::class;
3272  $anotherInstance = new ExtendedSingletonClassFixture();
3273  GeneralUtility::makeInstance(SingletonClassFixture::class);
3274  GeneralUtility::setSingletonInstance(SingletonClassFixture::class, $anotherInstance);
3275  $result = GeneralUtility::makeInstance(SingletonClassFixture::class);
3276  self::assertSame($anotherInstance, $result);
3277  self::assertEquals(ExtendedSingletonClassFixture::class, get_class($anotherInstance));
3278  }
3279 
3284  {
3285  $instance = $this->createMock(SingletonInterface::class);
3286  $instanceClassName = get_class($instance);
3287  GeneralUtility::setSingletonInstance($instanceClassName, $instance);
3288  GeneralUtility::resetSingletonInstances([]);
3289  $registeredSingletonInstances = GeneralUtility::getSingletonInstances();
3290  self::assertArrayNotHasKey($instanceClassName, $registeredSingletonInstances);
3291  }
3292 
3296  public function ‪resetSingletonInstancesSetsGivenInstance(): void
3297  {
3298  $instance = $this->createMock(SingletonInterface::class);
3299  $instanceClassName = get_class($instance);
3300  GeneralUtility::resetSingletonInstances(
3301  [$instanceClassName => $instance]
3302  );
3303  $registeredSingletonInstances = GeneralUtility::getSingletonInstances();
3304  self::assertArrayHasKey($instanceClassName, $registeredSingletonInstances);
3305  self::assertSame($registeredSingletonInstances[$instanceClassName], $instance);
3306  }
3307 
3311  public function ‪addInstanceForEmptyClassNameThrowsException(): void
3312  {
3313  $this->expectException(\InvalidArgumentException::class);
3314  $this->expectExceptionCode(1288967479);
3315 
3316  GeneralUtility::addInstance('', new \stdClass());
3317  }
3318 
3323  {
3324  $this->expectException(\InvalidArgumentException::class);
3325  $this->expectExceptionCode(1288967686);
3326 
3327  $instance = $this->getMockBuilder(\stdClass::class)
3328  ->addMethods(['bar'])
3329  ->getMock();
3330  $singletonClassName = get_class($this->createMock(\stdClass::class));
3331  GeneralUtility::addInstance($singletonClassName, $instance);
3332  }
3333 
3338  {
3339  $this->expectException(\InvalidArgumentException::class);
3340  $this->expectExceptionCode(1288969325);
3341 
3342  $instance = $this->createMock(SingletonInterface::class);
3343  GeneralUtility::addInstance(get_class($instance), $instance);
3344  }
3345 
3350  {
3351  $instance = $this->createMock(\stdClass::class);
3352  $className = get_class($instance);
3353  GeneralUtility::addInstance($className, $instance);
3354  self::assertSame($instance, GeneralUtility::makeInstance($className));
3355  }
3356 
3361  {
3362  $instance = $this->createMock(\stdClass::class);
3363  $className = get_class($instance);
3364  GeneralUtility::addInstance($className, $instance);
3365  self::assertNotSame(GeneralUtility::makeInstance($className), GeneralUtility::makeInstance($className));
3366  }
3367 
3372  {
3373  $instance1 = $this->createMock(\stdClass::class);
3374  $className = get_class($instance1);
3375  GeneralUtility::addInstance($className, $instance1);
3376  $instance2 = new $className();
3377  GeneralUtility::addInstance($className, $instance2);
3378  self::assertSame($instance1, GeneralUtility::makeInstance($className), 'The first returned instance does not match the first added instance.');
3379  self::assertSame($instance2, GeneralUtility::makeInstance($className), 'The second returned instance does not match the second added instance.');
3380  }
3381 
3385  public function ‪purgeInstancesDropsAddedInstance(): void
3386  {
3387  $instance = $this->createMock(\stdClass::class);
3388  $className = get_class($instance);
3389  GeneralUtility::addInstance($className, $instance);
3390  GeneralUtility::purgeInstances();
3391  self::assertNotSame($instance, GeneralUtility::makeInstance($className));
3392  }
3393 
3397  public function ‪getFileAbsFileNameDataProvider(): array
3398  {
3399  return [
3400  'relative path is prefixed with public path' => [
3401  'fileadmin/foo.txt',
3402  ‪Environment::getPublicPath() . '/fileadmin/foo.txt',
3403  ],
3404  'relative path, referencing current directory is prefixed with public path' => [
3405  './fileadmin/foo.txt',
3406  ‪Environment::getPublicPath() . '/./fileadmin/foo.txt',
3407  ],
3408  'relative paths with back paths are not allowed and returned empty' => [
3409  '../fileadmin/foo.txt',
3410  '',
3411  ],
3412  'absolute paths with back paths are not allowed and returned empty' => [
3413  ‪Environment::getPublicPath() . '/../sysext/core/Resources/Public/Icons/Extension.png',
3414  '',
3415  ],
3416  'allowed absolute paths are returned as is' => [
3417  ‪Environment::getPublicPath() . '/fileadmin/foo.txt',
3418  ‪Environment::getPublicPath() . '/fileadmin/foo.txt',
3419  ],
3420  'disallowed absolute paths are returned empty' => [
3421  '/somewhere/fileadmin/foo.txt',
3422  '',
3423  ],
3424  'EXT paths are resolved to absolute paths' => [
3425  'EXT:foo/Resources/Private/Templates/Home.html',
3426  '/path/to/foo/Resources/Private/Templates/Home.html',
3427  ],
3428  ];
3429  }
3430 
3437  public function ‪getFileAbsFileNameReturnsCorrectValues(string $path, string $expected): void
3438  {
3439  // build the dummy package "foo" for use in ExtensionManagementUtility::extPath('foo');
3440  $package = $this->getMockBuilder(Package::class)
3441  ->disableOriginalConstructor()
3442  ->onlyMethods(['getPackagePath'])
3443  ->getMock();
3444  $packageManager = $this->getMockBuilder(PackageManager::class)
3445  ->onlyMethods(['isPackageActive', 'getPackage', 'getActivePackages'])
3446  ->disableOriginalConstructor()
3447  ->getMock();
3448  $package
3449  ->method('getPackagePath')
3450  ->willReturn('/path/to/foo/');
3451  $packageManager
3452  ->method('getActivePackages')
3453  ->willReturn(['foo' => $package]);
3454  $packageManager
3455  ->method('isPackageActive')
3456  ->with(self::equalTo('foo'))
3457  ->willReturn(true);
3458  $packageManager
3459  ->method('getPackage')
3460  ->with('foo')
3461  ->willReturn($package);
3463 
3464  $result = GeneralUtility::getFileAbsFileName($path);
3465  self::assertEquals($expected, $result);
3466  }
3467 
3473  public function ‪validPathStrInvalidCharactersDataProvider(): array
3474  {
3475  $data = [
3476  'double slash in path' => ['path//path'],
3477  'backslash in path' => ['path\\path'],
3478  'directory up in path' => ['path/../path'],
3479  'directory up at the beginning' => ['../path'],
3480  'NUL character in path' => ['path' . "\0" . 'path'],
3481  'BS character in path' => ['path' . chr(8) . 'path'],
3482  'invalid UTF-8-sequence' => ["\xc0" . 'path/path'],
3483  'Could be overlong NUL in some UTF-8 implementations, invalid in RFC3629' => ["\xc0\x80" . 'path/path'],
3484  ];
3485 
3486  // Mixing with regular utf-8
3487  $utf8Characters = 'Ссылка/';
3488  foreach ($data as $key => $value) {
3489  $data[$key . ' with UTF-8 characters prepended'] = [$utf8Characters . $value[0]];
3490  $data[$key . ' with UTF-8 characters appended'] = [$value[0] . $utf8Characters];
3491  }
3492 
3493  // Encoding with UTF-16
3494  foreach ($data as $key => $value) {
3495  $data[$key . ' encoded with UTF-16'] = [mb_convert_encoding($value[0], 'UTF-16')];
3496  }
3497 
3498  return $data;
3499  }
3500 
3508  public function ‪validPathStrDetectsInvalidCharacters(string $path): void
3509  {
3510  self::assertFalse(GeneralUtility::validPathStr($path));
3511  }
3512 
3516  public function ‪validPathStrDataProvider(): array
3517  {
3518  $data = [
3519  'normal ascii path' => ['fileadmin/templates/myfile..xml'],
3520  'special character' => ['fileadmin/templates/Ссылка (fce).xml'],
3521  ];
3522 
3523  return $data;
3524  }
3525 
3532  public function ‪validPathStrWorksWithUnicodeFileNames($path): void
3533  {
3534  self::assertTrue(GeneralUtility::validPathStr($path));
3535  }
3536 
3538  // Tests concerning copyDirectory
3540 
3545  {
3546  $sourceDirectory = 'typo3temp/var/tests/' . ‪StringUtility::getUniqueId('test_') . '/';
3547  $absoluteSourceDirectory = ‪Environment::getPublicPath() . '/' . $sourceDirectory;
3548  $this->testFilesToDelete[] = $absoluteSourceDirectory;
3549  ‪GeneralUtility::mkdir($absoluteSourceDirectory);
3550 
3551  $targetDirectory = 'typo3temp/var/tests/' . ‪StringUtility::getUniqueId('test_') . '/';
3552  $absoluteTargetDirectory = ‪Environment::getPublicPath() . '/' . $targetDirectory;
3553  $this->testFilesToDelete[] = $absoluteTargetDirectory;
3554 
3555  ‪GeneralUtility::writeFileToTypo3tempDir($absoluteSourceDirectory . 'file', '42');
3556  ‪GeneralUtility::mkdir($absoluteSourceDirectory . 'foo');
3557  ‪GeneralUtility::writeFileToTypo3tempDir($absoluteSourceDirectory . 'foo/file', '42');
3558 
3559  GeneralUtility::copyDirectory($sourceDirectory, $targetDirectory);
3560 
3561  self::assertFileExists($absoluteTargetDirectory . 'file');
3562  self::assertFileExists($absoluteTargetDirectory . 'foo/file');
3563  }
3564 
3569  {
3570  $sourceDirectory = 'typo3temp/var/tests/' . ‪StringUtility::getUniqueId('test_') . '/';
3571  $absoluteSourceDirectory = ‪Environment::getPublicPath() . '/' . $sourceDirectory;
3572  $this->testFilesToDelete[] = $absoluteSourceDirectory;
3573  ‪GeneralUtility::mkdir($absoluteSourceDirectory);
3574 
3575  $targetDirectory = 'typo3temp/var/tests/' . ‪StringUtility::getUniqueId('test_') . '/';
3576  $absoluteTargetDirectory = ‪Environment::getPublicPath() . '/' . $targetDirectory;
3577  $this->testFilesToDelete[] = $absoluteTargetDirectory;
3578 
3579  ‪GeneralUtility::writeFileToTypo3tempDir($absoluteSourceDirectory . 'file', '42');
3580  ‪GeneralUtility::mkdir($absoluteSourceDirectory . 'foo');
3581  ‪GeneralUtility::writeFileToTypo3tempDir($absoluteSourceDirectory . 'foo/file', '42');
3582 
3583  GeneralUtility::copyDirectory($absoluteSourceDirectory, $absoluteTargetDirectory);
3584 
3585  self::assertFileExists($absoluteTargetDirectory . 'file');
3586  self::assertFileExists($absoluteTargetDirectory . 'foo/file');
3587  }
3588 
3590  // Tests concerning deprecation log
3592 
3594  // Tests concerning callUserFunction
3596 
3603  public function ‪callUserFunctionWillThrowExceptionForInvalidParameters(string $functionName, int $expectedException): void
3604  {
3605  $this->expectException(\InvalidArgumentException::class);
3606  $this->expectExceptionCode($expectedException);
3607 
3608  $inputData = ['foo' => 'bar'];
3609  GeneralUtility::callUserFunction($functionName, $inputData, $this);
3610  }
3611 
3618  public function ‪callUserFunctionInvalidParameterDataprovider(): array
3619  {
3620  return [
3621  'Function is not prefixed' => [self::class . '->calledUserFunction', 1294585865],
3622  'Class doesn\'t exists' => ['t3lib_divTest21345->user_calledUserFunction', 1294585866],
3623  'No method name' => [self::class, 1294585867],
3624  'No class name' => ['->user_calledUserFunction', 1294585866],
3625  'No function name' => ['', 1294585867],
3626  ];
3627  }
3628 
3636  public function ‪callUserFunctionCanCallFunction(): void
3637  {
3638  $inputData = ['foo' => 'bar'];
3639  $result = GeneralUtility::callUserFunction(static function () {
3640  return 'Worked fine';
3641  }, $inputData, $this, '');
3642  self::assertEquals('Worked fine', $result);
3643  }
3644 
3648  public function ‪callUserFunctionCanCallMethod(): void
3649  {
3650  $inputData = ['foo' => 'bar'];
3651  $result = GeneralUtility::callUserFunction(self::class . '->user_calledUserFunction', $inputData, $this);
3652  self::assertEquals('Worked fine', $result);
3653  }
3654 
3658  public function ‪user_calledUserFunction(): string
3659  {
3660  return 'Worked fine';
3661  }
3662 
3666  public function ‪callUserFunctionAcceptsClosures(): void
3667  {
3668  $inputData = ['foo' => 'bar'];
3669  $closure = static function ($parameters, $reference) use ($inputData) {
3670  $reference->assertEquals($inputData, $parameters, 'Passed data doesn\'t match expected output');
3671  return 'Worked fine';
3672  };
3673  self::assertEquals('Worked fine', GeneralUtility::callUserFunction($closure, $inputData, $this));
3674  }
3675 
3679  public function ‪callUserFunctionTrimsSpaces(): void
3680  {
3681  $inputData = ['foo' => 'bar'];
3682  $result = GeneralUtility::callUserFunction("\t" . self::class . '->user_calledUserFunction ', $inputData, $this);
3683  self::assertEquals('Worked fine', $result);
3684  }
3685 
3690  {
3691  $directory = ‪Environment::getVarPath() . '/tests/' . ‪StringUtility::getUniqueId('directory_');
3692  mkdir($directory);
3693  $filesAndDirectories = GeneralUtility::getAllFilesAndFoldersInPath([], $directory, '', true);
3694  $check = true;
3695  foreach ($filesAndDirectories as $md5 => $path) {
3696  if (!preg_match('/^[a-f0-9]{32}$/', $md5)) {
3697  $check = false;
3698  }
3699  }
3700  ‪GeneralUtility::rmdir($directory);
3701  self::assertTrue($check);
3702  }
3703 
3711  {
3712  $input = [
3713  'el' => [],
3714  ];
3715 
3716  ‪$output = GeneralUtility::array2xml($input);
3717 
3718  self::assertEquals('<phparray>
3719  <el type="array"></el>
3720 </phparray>', ‪$output);
3721  }
3722 
3726  public function ‪xml2arrayUsesCache(): void
3727  {
3728  $cacheManagerProphecy = $this->prophesize(CacheManager::class);
3729  $cacheProphecy = $this->prophesize(FrontendInterface::class);
3730  $cacheManagerProphecy->getCache('runtime')->willReturn($cacheProphecy->reveal());
3731  $cacheProphecy->get('generalUtilityXml2Array')->shouldBeCalled()->willReturn(false);
3732  $cacheProphecy->set('generalUtilityXml2Array', Argument::cetera())->shouldBeCalled();
3733  GeneralUtility::setSingletonInstance(CacheManager::class, $cacheManagerProphecy->reveal());
3734  ‪GeneralUtility::xml2array('<?xml version="1.0" encoding="utf-8" standalone="yes"?>', 'T3:');
3735  }
3736 
3740  public function ‪xml2arrayProcessHandlesWhitespacesDataProvider(): array
3741  {
3742  $headerVariants = [
3743  'utf-8' => '<?xml version="1.0" encoding="utf-8" standalone="yes"?>',
3744  'UTF-8' => '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>',
3745  'no-encoding' => '<?xml version="1.0" standalone="yes"?>',
3746  'iso-8859-1' => '<?xml version="1.0" encoding="iso-8859-1" standalone="yes"?>',
3747  'ISO-8859-1' => '<?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?>',
3748  ];
3749  $data = [];
3750  foreach ($headerVariants as $identifier => $headerVariant) {
3751  $data += [
3752  'inputWithoutWhitespaces-' . $identifier => [
3753  $headerVariant . '<T3FlexForms>
3754  <data>
3755  <field index="settings.persistenceIdentifier">
3756  <value index="vDEF">egon</value>
3757  </field>
3758  </data>
3759  </T3FlexForms>',
3760  ],
3761  'inputWithPrecedingWhitespaces-' . $identifier => [
3762  CR . ' ' . $headerVariant . '<T3FlexForms>
3763  <data>
3764  <field index="settings.persistenceIdentifier">
3765  <value index="vDEF">egon</value>
3766  </field>
3767  </data>
3768  </T3FlexForms>',
3769  ],
3770  'inputWithTrailingWhitespaces-' . $identifier => [
3771  $headerVariant . '<T3FlexForms>
3772  <data>
3773  <field index="settings.persistenceIdentifier">
3774  <value index="vDEF">egon</value>
3775  </field>
3776  </data>
3777  </T3FlexForms>' . CR . ' ',
3778  ],
3779  'inputWithPrecedingAndTrailingWhitespaces-' . $identifier => [
3780  CR . ' ' . $headerVariant . '<T3FlexForms>
3781  <data>
3782  <field index="settings.persistenceIdentifier">
3783  <value index="vDEF">egon</value>
3784  </field>
3785  </data>
3786  </T3FlexForms>' . CR . ' ',
3787  ],
3788  ];
3789  }
3790  return $data;
3791  }
3792 
3797  public function ‪xml2arrayProcessHandlesWhitespaces(string $input): void
3798  {
3799  $expected = [
3800  'data' => [
3801  'settings.persistenceIdentifier' => [
3802  'vDEF' => 'egon',
3803  ],
3804  ],
3805  ];
3806  self::assertSame($expected, ‪GeneralUtility::xml2arrayProcess($input));
3807  }
3808 
3813  {
3814  return [
3815  'inputWithNameSpaceOnRootLevel' => [
3816  '<?xml version="1.0" encoding="utf-8" standalone="yes"?>
3817  <T3:T3FlexForms>
3818  <data>
3819  <field index="settings.persistenceIdentifier">
3820  <value index="vDEF">egon</value>
3821  </field>
3822  </data>
3823  </T3:T3FlexForms>',
3824  ],
3825  'inputWithNameSpaceOnNonRootLevel' => [
3826  '<?xml version="1.0" encoding="utf-8" standalone="yes"?>
3827  <T3FlexForms>
3828  <data>
3829  <T3:field index="settings.persistenceIdentifier">
3830  <value index="vDEF">egon</value>
3831  </T3:field>
3832  </data>
3833  </T3FlexForms>',
3834  ],
3835  'inputWithNameSpaceOnRootAndNonRootLevel' => [
3836  '<?xml version="1.0" encoding="utf-8" standalone="yes"?>
3837  <T3:T3FlexForms>
3838  <data>
3839  <T3:field index="settings.persistenceIdentifier">
3840  <value index="vDEF">egon</value>
3841  </T3:field>
3842  </data>
3843  </T3:T3FlexForms>',
3844  ],
3845  ];
3846  }
3847 
3852  public function ‪xml2arrayProcessHandlesTagNamespaces(string $input): void
3853  {
3854  $expected = [
3855  'data' => [
3856  'settings.persistenceIdentifier' => [
3857  'vDEF' => 'egon',
3858  ],
3859  ],
3860  ];
3861  self::assertSame($expected, ‪GeneralUtility::xml2arrayProcess($input, 'T3:'));
3862  }
3863 
3867  public function ‪xml2arrayProcessHandlesDocumentTagDataProvider(): array
3868  {
3869  return [
3870  'input' => [
3871  '<?xml version="1.0" encoding="utf-8" standalone="yes"?>
3872  <T3FlexForms>
3873  <data>
3874  <field index="settings.persistenceIdentifier">
3875  <value index="vDEF">egon</value>
3876  </field>
3877  </data>
3878  </T3FlexForms>',
3879  'T3FlexForms',
3880  ],
3881  'input-with-root-namespace' => [
3882  '<?xml version="1.0" encoding="utf-8" standalone="yes"?>
3883  <T3:T3FlexForms>
3884  <data>
3885  <field index="settings.persistenceIdentifier">
3886  <value index="vDEF">egon</value>
3887  </field>
3888  </data>
3889  </T3:T3FlexForms>',
3890  'T3:T3FlexForms',
3891  ],
3892  'input-with-namespace' => [
3893  '<?xml version="1.0" encoding="utf-8" standalone="yes"?>
3894  <T3FlexForms>
3895  <data>
3896  <T3:field index="settings.persistenceIdentifier">
3897  <value index="vDEF">egon</value>
3898  </T3:field>
3899  </data>
3900  </T3FlexForms>',
3901  'T3FlexForms',
3902  ],
3903  ];
3904  }
3905 
3910  public function ‪xml2arrayProcessHandlesDocumentTag(string $input, string $docTag): void
3911  {
3912  $expected = [
3913  'data' => [
3914  'settings.persistenceIdentifier' => [
3915  'vDEF' => 'egon',
3916  ],
3917  ],
3918  '_DOCUMENT_TAG' => $docTag,
3919  ];
3920  self::assertSame($expected, ‪GeneralUtility::xml2arrayProcess($input, '', true));
3921  }
3922 
3927  {
3928  return [
3929  '1mb' => [
3930  '<?xml version="1.0" encoding="utf-8" standalone="yes"?>
3931  <T3:T3FlexForms>
3932  <data>
3933  <field index="settings.persistenceIdentifier">
3934  <value index="vDEF">' . str_repeat('1', 1024 * 1024) . '</value>
3935  </field>
3936  </data>
3937  </T3:T3FlexForms>',
3938  str_repeat('1', 1024 * 1024),
3939  ],
3940  '5mb' => [
3941  '<?xml version="1.0" encoding="utf-8" standalone="yes"?>
3942  <T3:T3FlexForms>
3943  <data>
3944  <field index="settings.persistenceIdentifier">
3945  <value index="vDEF">' . str_repeat('1', 5 * 1024 * 1024) . '</value>
3946  </field>
3947  </data>
3948  </T3:T3FlexForms>',
3949  str_repeat('1', 5 * 1024 * 1024),
3950  ],
3951  ];
3952  }
3953 
3960  public function ‪xml2ArrayProcessHandlesBigXmlContent(string $input, string $testValue): void
3961  {
3962  $expected = [
3963  'data' => [
3964  'settings.persistenceIdentifier' => [
3965  'vDEF' => $testValue,
3966  ],
3967  ],
3968  ];
3969  self::assertSame($expected, ‪GeneralUtility::xml2arrayProcess($input));
3970  }
3971 
3976  {
3977  $prefix = '<?xml version="1.0" encoding="utf-8" standalone="yes"?><T3FlexForms><field index="index">';
3978  $suffix = '</field></T3FlexForms>';
3979  return [
3980  'no-type string' => [
3981  $prefix . '<value index="vDEF">foo bar</value>' . $suffix,
3982  'foo bar',
3983  ],
3984  'no-type integer' => [
3985  $prefix . '<value index="vDEF">123</value>' . $suffix,
3986  '123',
3987  ],
3988  'no-type double' => [
3989  $prefix . '<value index="vDEF">1.23</value>' . $suffix,
3990  '1.23',
3991  ],
3992  'integer integer' => [
3993  $prefix . '<value index="vDEF" type="integer">123</value>' . $suffix,
3994  123,
3995  ],
3996  'integer double' => [
3997  $prefix . '<value index="vDEF" type="integer">1.23</value>' . $suffix,
3998  1,
3999  ],
4000  'double integer' => [
4001  $prefix . '<value index="vDEF" type="double">123</value>' . $suffix,
4002  123.0,
4003  ],
4004  'double double' => [
4005  $prefix . '<value index="vDEF" type="double">1.23</value>' . $suffix,
4006  1.23,
4007  ],
4008  'boolean 0' => [
4009  $prefix . '<value index="vDEF" type="boolean">0</value>' . $suffix,
4010  false,
4011  ],
4012  'boolean 1' => [
4013  $prefix . '<value index="vDEF" type="boolean">1</value>' . $suffix,
4014  true,
4015  ],
4016  'boolean true' => [
4017  $prefix . '<value index="vDEF" type="boolean">true</value>' . $suffix,
4018  true,
4019  ],
4020  'boolean false' => [
4021  $prefix . '<value index="vDEF" type="boolean">false</value>' . $suffix,
4022  true, // sic(!)
4023  ],
4024  'NULL' => [
4025  $prefix . '<value index="vDEF" type="NULL"></value>' . $suffix,
4026  null,
4027  ],
4028  'NULL string' => [
4029  $prefix . '<value index="vDEF" type="NULL">foo bar</value>' . $suffix,
4030  null,
4031  ],
4032  'NULL integer' => [
4033  $prefix . '<value index="vDEF" type="NULL">123</value>' . $suffix,
4034  null,
4035  ],
4036  'NULL double' => [
4037  $prefix . '<value index="vDEF" type="NULL">1.23</value>' . $suffix,
4038  null,
4039  ],
4040  'array' => [
4041  $prefix . '<value index="vDEF" type="array"></value>' . $suffix,
4042  [],
4043  ],
4044  ];
4045  }
4046 
4053  public function ‪xml2ArrayProcessHandlesAttributeTypes(string $input, $expected): void
4054  {
4055  $result = ‪GeneralUtility::xml2arrayProcess($input);
4056  self::assertSame($expected, $result['index']['vDEF']);
4057  }
4058 
4059  public function ‪locationHeaderUrlDataProvider(): array
4060  {
4061  return [
4062  'simple relative path' => [
4063  'foo',
4064  'foo.bar.test',
4065  'http://foo.bar.test/foo',
4066  ],
4067  'path beginning with slash' => [
4068  '/foo',
4069  'foo.bar.test',
4070  'http://foo.bar.test/foo',
4071  ],
4072  'path with full domain and https scheme' => [
4073  'https://example.com/foo',
4074  'foo.bar.test',
4075  'https://example.com/foo',
4076  ],
4077  'path with full domain and http scheme' => [
4078  'http://example.com/foo',
4079  'foo.bar.test',
4080  'http://example.com/foo',
4081  ],
4082  'path with full domain and relative scheme' => [
4083  '//example.com/foo',
4084  'foo.bar.test',
4085  '//example.com/foo',
4086  ],
4087  ];
4088  }
4089 
4098  public function ‪locationHeaderUrl(string $path, string $host, string $expected): void
4099  {
4102  true,
4103  false,
4109  ‪Environment::isWindows() ? 'WINDOWS' : 'UNIX'
4110  );
4111  $_SERVER['HTTP_HOST'] = $host;
4112  $_SERVER['SCRIPT_NAME'] = '/index.php';
4113  $result = GeneralUtility::locationHeaderUrl($path);
4114  self::assertSame($expected, $result);
4115  }
4116 
4121  {
4122  ‪$GLOBALS['TYPO3_CONF_VARS']['BE']['versionNumberInFilename'] = true;
4123 
4124  $uniqueFilename = ‪StringUtility::getUniqueId() . 'backend';
4125  $testFileDirectory = ‪Environment::getVarPath() . '/tests/';
4126  $testFilepath = $testFileDirectory . $uniqueFilename . '.css';
4127  $this->testFilesToDelete[] = $testFilepath;
4128  ‪GeneralUtility::mkdir_deep($testFileDirectory);
4129  touch($testFilepath);
4130 
4131  $versionedFilename = GeneralUtility::createVersionNumberedFilename($testFilepath);
4132 
4133  self::assertMatchesRegularExpression('/^.*\/tests\/' . $uniqueFilename . '\.[0-9]+\.css/', $versionedFilename);
4134  }
4135 
4140  {
4143  true,
4144  false,
4149  ‪Environment::getPublicPath() . '/index.php',
4150  ‪Environment::isWindows() ? 'WINDOWS' : 'UNIX'
4151  );
4152  $request = new ServerRequest('https://www.example.com', 'GET');
4153  ‪$GLOBALS['TYPO3_REQUEST'] = $request->withAttribute('applicationType', ‪SystemEnvironmentBuilder::REQUESTTYPE_FE);
4154  $uniqueFilename = ‪StringUtility::getUniqueId('main_');
4155  $testFileDirectory = ‪Environment::getPublicPath() . '/static/';
4156  $testFilepath = $testFileDirectory . $uniqueFilename . '.css';
4157  ‪GeneralUtility::mkdir_deep($testFileDirectory);
4158  touch($testFilepath);
4159 
4160  ‪$GLOBALS['TYPO3_CONF_VARS']['FE']['versionNumberInFilename'] = 'querystring';
4161  $incomingFileName = '/' . ‪PathUtility::stripPathSitePrefix($testFilepath);
4162  $versionedFilename = GeneralUtility::createVersionNumberedFilename($incomingFileName);
4163  self::assertStringContainsString('.css?', $versionedFilename);
4164  self::assertStringStartsWith('/static/main_', $versionedFilename);
4165 
4166  $incomingFileName = ‪PathUtility::stripPathSitePrefix($testFilepath);
4167  $versionedFilename = GeneralUtility::createVersionNumberedFilename($incomingFileName);
4168  self::assertStringContainsString('.css?', $versionedFilename);
4169  self::assertStringStartsWith('static/main_', $versionedFilename);
4170 
4171  ‪GeneralUtility::rmdir($testFileDirectory, true);
4172  }
4173 
4177  public function ‪getMaxUploadFileSizeReturnsPositiveInt(): void
4178  {
4179  $result = GeneralUtility::getMaxUploadFileSize();
4180  self::assertIsInt($result);
4181  self::assertGreaterThan(0, $result);
4182  }
4183 }
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\resolveBackPathWithDataProvider
‪resolveBackPathWithDataProvider(string $input, string $expectedValue)
Definition: GeneralUtilityTest.php:3044
‪TYPO3\CMS\Core\Utility\GeneralUtility\underscoredToLowerCamelCase
‪static string underscoredToLowerCamelCase($string)
Definition: GeneralUtility.php:841
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\cmpFqdnInvalidDataProvider
‪static array cmpFqdnInvalidDataProvider()
Definition: GeneralUtilityTest.php:471
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\jsonEncodeForHtmlAttributeTestDataProvider
‪static jsonEncodeForHtmlAttributeTestDataProvider()
Definition: GeneralUtilityTest.php:2024
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\gpDataProvider
‪array gpDataProvider()
Definition: GeneralUtilityTest.php:140
‪TYPO3\CMS\Core\Utility\GeneralUtility\trimExplode
‪static list< string > trimExplode($delim, $string, $removeEmptyValues=false, $limit=0)
Definition: GeneralUtility.php:999
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\writeFileToTypo3tempDirWorksWithValidPath
‪writeFileToTypo3tempDirWorksWithValidPath(string $filePath)
Definition: GeneralUtilityTest.php:2444
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\xml2arrayProcessHandlesDocumentTag
‪xml2arrayProcessHandlesDocumentTag(string $input, string $docTag)
Definition: GeneralUtilityTest.php:3907
‪TYPO3\CMS\Core\Utility\GeneralUtility\xml2array
‪static mixed xml2array($string, $NSprefix='', $reportDocTag=false)
Definition: GeneralUtility.php:1482
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\makeInstanceWithZeroStringClassNameThrowsException
‪makeInstanceWithZeroStringClassNameThrowsException()
Definition: GeneralUtilityTest.php:3078
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\createVersionNumberedFilenameDoesNotResolveBackpathForAbsolutePath
‪createVersionNumberedFilenameDoesNotResolveBackpathForAbsolutePath()
Definition: GeneralUtilityTest.php:4117
‪TYPO3\CMS\Core\Utility\GeneralUtility\revExplode
‪static list< string > revExplode($delimiter, $string, $count=0)
Definition: GeneralUtility.php:964
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\makeInstanceResolvesConfiguredImplementationsRecursively
‪makeInstanceResolvesConfiguredImplementationsRecursively()
Definition: GeneralUtilityTest.php:3153
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\getSingletonInstancesContainsPreviouslySetSingletonInstance
‪getSingletonInstancesContainsPreviouslySetSingletonInstance()
Definition: GeneralUtilityTest.php:3253
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\rmdirDoesNotRemoveDirectoryWithFilesAndReturnsFalseIfRecursiveDeletionIsOff
‪rmdirDoesNotRemoveDirectoryWithFilesAndReturnsFalseIfRecursiveDeletionIsOff()
Definition: GeneralUtilityTest.php:2653
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\xml2ArrayProcessHandlesBigXmlContent
‪xml2ArrayProcessHandlesBigXmlContent(string $input, string $testValue)
Definition: GeneralUtilityTest.php:3957
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\underscoredToLowerCamelCase
‪underscoredToLowerCamelCase($expected, $inputString)
Definition: GeneralUtilityTest.php:1316
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\validPathStrDataProvider
‪validPathStrDataProvider()
Definition: GeneralUtilityTest.php:3513
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\jsonEncodeForJavaScriptTest
‪jsonEncodeForJavaScriptTest($value, string $expectation)
Definition: GeneralUtilityTest.php:2075
‪TYPO3\CMS\Core\Utility\PathUtility
Definition: PathUtility.php:25
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\cmpIPv6DataProviderNotMatching
‪static array cmpIPv6DataProviderNotMatching()
Definition: GeneralUtilityTest.php:327
‪TYPO3\CMS\Core\Tests\Unit\Utility\Fixtures\GeneralUtilityFilesystemFixture\writeFileToTypo3tempDir
‪static writeFileToTypo3tempDir($filepath, $content)
Definition: GeneralUtilityFilesystemFixture.php:55
‪TYPO3\CMS\Core\Tests\Unit\Utility\Fixtures\GeneralUtilityMakeInstanceInjectLoggerFixture
Definition: GeneralUtilityMakeInstanceInjectLoggerFixture.php:28
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\getFilesInDirReturnsArrayWithMd5OfElementAndPathAsArrayKey
‪getFilesInDirReturnsArrayWithMd5OfElementAndPathAsArrayKey()
Definition: GeneralUtilityTest.php:2894
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\implodeArrayForUrlCanSkipEmptyParameters
‪implodeArrayForUrlCanSkipEmptyParameters()
Definition: GeneralUtilityTest.php:818
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\sanitizeLocalUrlAcceptsNotEncodedValidPaths
‪sanitizeLocalUrlAcceptsNotEncodedValidPaths(string $path)
Definition: GeneralUtilityTest.php:1491
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\explodeUrl2ArrayTransformsParameterStringToFlatArrayDataProvider
‪explodeUrl2ArrayTransformsParameterStringToFlatArrayDataProvider()
Definition: GeneralUtilityTest.php:835
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\makeInstanceWithBeginningSlashInClassNameThrowsException
‪makeInstanceWithBeginningSlashInClassNameThrowsException()
Definition: GeneralUtilityTest.php:3114
‪TYPO3\CMS\Core\Tests\Unit\Utility\Fixtures\GeneralUtilityFixture\resetFinalClassNameCache
‪static resetFinalClassNameCache()
Definition: GeneralUtilityFixture.php:30
‪TYPO3\CMS\Core\Core\Environment\getPublicPath
‪static string getPublicPath()
Definition: Environment.php:206
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\validPathStrInvalidCharactersDataProvider
‪array validPathStrInvalidCharactersDataProvider()
Definition: GeneralUtilityTest.php:3470
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\underscoredToLowerCamelCaseDataProvider
‪array underscoredToLowerCamelCaseDataProvider()
Definition: GeneralUtilityTest.php:1304
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\copyDirectoryCopiesFilesAndDirectoriesWithRelativePaths
‪copyDirectoryCopiesFilesAndDirectoriesWithRelativePaths()
Definition: GeneralUtilityTest.php:3541
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\validIpReturnsTrueForValidIp
‪validIpReturnsTrueForValidIp($ip)
Definition: GeneralUtilityTest.php:401
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\array2xmlConvertsEmptyArraysToElementWithoutContent
‪array2xmlConvertsEmptyArraysToElementWithoutContent()
Definition: GeneralUtilityTest.php:3707
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\cmpFqdnReturnsTrue
‪cmpFqdnReturnsTrue($baseHost, $list)
Definition: GeneralUtilityTest.php:461
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\invalidIpDataProvider
‪static array invalidIpDataProvider()
Definition: GeneralUtilityTest.php:411
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\hmacReturnsEqualHashesForEqualInput
‪hmacReturnsEqualHashesForEqualInput()
Definition: GeneralUtilityTest.php:1940
‪TYPO3\CMS\Core\Tests\Unit\Utility\Fixtures\GeneralUtilityFixture
Definition: GeneralUtilityFixture.php:26
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\mkdirCreatesHiddenDirectory
‪mkdirCreatesHiddenDirectory()
Definition: GeneralUtilityTest.php:2323
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\inListForItemNotContainedReturnsFalseDataProvider
‪array inListForItemNotContainedReturnsFalseDataProvider()
Definition: GeneralUtilityTest.php:531
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\hmacReturnsNoEqualHashesForNonEqualInput
‪hmacReturnsNoEqualHashesForNonEqualInput()
Definition: GeneralUtilityTest.php:1951
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\NO_FIX_PERMISSIONS_ON_WINDOWS
‪const NO_FIX_PERMISSIONS_ON_WINDOWS
Definition: GeneralUtilityTest.php:55
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\makeInstanceWithEmptyArrayThrowsException
‪makeInstanceWithEmptyArrayThrowsException()
Definition: GeneralUtilityTest.php:3090
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\validEmailValidDataProvider
‪array validEmailValidDataProvider()
Definition: GeneralUtilityTest.php:696
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\htmlspecialcharsDecodeReturnsDecodedString
‪htmlspecialcharsDecodeReturnsDecodedString()
Definition: GeneralUtilityTest.php:680
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\rmdirRemovesDirectoriesRecursiveAndReturnsTrue
‪rmdirRemovesDirectoriesRecursiveAndReturnsTrue()
Definition: GeneralUtilityTest.php:2669
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\locationHeaderUrl
‪locationHeaderUrl(string $path, string $host, string $expected)
Definition: GeneralUtilityTest.php:4095
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\getAllFilesAndFoldersInPathReturnsArrayWithMd5Keys
‪getAllFilesAndFoldersInPathReturnsArrayWithMd5Keys()
Definition: GeneralUtilityTest.php:3686
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\mkdirDeepCreatesDirectoryWithDoubleSlashes
‪mkdirDeepCreatesDirectoryWithDoubleSlashes($directoryToCreate)
Definition: GeneralUtilityTest.php:2497
‪TYPO3\CMS\Core\Tests\Unit\Utility\Fixtures\SingletonClassFixture
Definition: SingletonClassFixture.php:25
‪TYPO3\CMS\Core\Utility\PathUtility\stripPathSitePrefix
‪static string stripPathSitePrefix($path)
Definition: PathUtility.php:445
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\implodeArrayForUrlBuildsValidParameterString
‪implodeArrayForUrlBuildsValidParameterString($name, $input, $expected)
Definition: GeneralUtilityTest.php:810
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\setSingletonInstanceMakesMakeInstanceReturnThatInstance
‪setSingletonInstanceMakesMakeInstanceReturnThatInstance()
Definition: GeneralUtilityTest.php:3229
‪TYPO3\CMS\Core\Core\SystemEnvironmentBuilder
Definition: SystemEnvironmentBuilder.php:41
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\sanitizeLocalUrlValidUrlsDataProvider
‪array sanitizeLocalUrlValidUrlsDataProvider()
Definition: GeneralUtilityTest.php:1533
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\rmdirRemovesFile
‪rmdirRemovesFile()
Definition: GeneralUtilityTest.php:2601
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\mkdirDeepCreatesDirectoryWithAndWithoutDoubleSlashesDataProvider
‪array mkdirDeepCreatesDirectoryWithAndWithoutDoubleSlashesDataProvider()
Definition: GeneralUtilityTest.php:2485
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\validEmailInvalidDataProvider
‪array validEmailInvalidDataProvider()
Definition: GeneralUtilityTest.php:732
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\makeInstanceInjectsLogger
‪makeInstanceInjectsLogger()
Definition: GeneralUtilityTest.php:3193
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\copyDirectoryCopiesFilesAndDirectoriesWithAbsolutePaths
‪copyDirectoryCopiesFilesAndDirectoriesWithAbsolutePaths()
Definition: GeneralUtilityTest.php:3565
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\callUserFunctionCanCallMethod
‪callUserFunctionCanCallMethod()
Definition: GeneralUtilityTest.php:3645
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\getDirsReturnsStringErrorOnPathFailure
‪getDirsReturnsStringErrorOnPathFailure()
Definition: GeneralUtilityTest.php:1915
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\createVersionNumberedFilenameKeepsInvalidAbsolutePathInFrontendAndAddsQueryString
‪createVersionNumberedFilenameKeepsInvalidAbsolutePathInFrontendAndAddsQueryString()
Definition: GeneralUtilityTest.php:4136
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\unlink_tempfileRemovesValidFileInTypo3temp
‪unlink_tempfileRemovesValidFileInTypo3temp()
Definition: GeneralUtilityTest.php:1690
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\addInstanceMakesMakeInstanceReturnThatInstance
‪addInstanceMakesMakeInstanceReturnThatInstance()
Definition: GeneralUtilityTest.php:3346
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\callUserFunctionWillThrowExceptionForInvalidParameters
‪callUserFunctionWillThrowExceptionForInvalidParameters(string $functionName, int $expectedException)
Definition: GeneralUtilityTest.php:3600
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\xml2arrayUsesCache
‪xml2arrayUsesCache()
Definition: GeneralUtilityTest.php:3723
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\getFilesInDirByExtensionDoesNotFindFilesWithOtherExtensions
‪getFilesInDirByExtensionDoesNotFindFilesWithOtherExtensions()
Definition: GeneralUtilityTest.php:2827
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\getFilesInDirDoesSortAlphabeticallyByDefault
‪getFilesInDirDoesSortAlphabeticallyByDefault()
Definition: GeneralUtilityTest.php:2862
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\sanitizeLocalUrlDeniesPlainInvalidUrlsInBackendContext
‪sanitizeLocalUrlDeniesPlainInvalidUrlsInBackendContext(string $url)
Definition: GeneralUtilityTest.php:1633
‪TYPO3\CMS\Core\Tests\Unit\Utility\Fixtures\ExtendedSingletonClassFixture
Definition: ExtendedSingletonClassFixture.php:23
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\fixPermissionsSetsPermissionsToHiddenFile
‪fixPermissionsSetsPermissionsToHiddenFile()
Definition: GeneralUtilityTest.php:2103
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\makeInstanceCalledTwoTimesForSingletonClassReturnsSameInstance
‪makeInstanceCalledTwoTimesForSingletonClassReturnsSameInstance()
Definition: GeneralUtilityTest.php:3173
‪TYPO3\CMS\Core\Core\Environment\isWindows
‪static bool isWindows()
Definition: Environment.php:318
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\explodeUrl2ArrayTransformsParameterStringToFlatArray
‪explodeUrl2ArrayTransformsParameterStringToFlatArray(string $input, array $expected)
Definition: GeneralUtilityTest.php:852
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\sanitizeLocalUrlInvalidDataProvider
‪array sanitizeLocalUrlInvalidDataProvider()
Definition: GeneralUtilityTest.php:1614
‪TYPO3\CMS\Core\Tests\Unit\Utility
‪TYPO3\CMS\Core\Core\Environment\getCurrentScript
‪static string getCurrentScript()
Definition: Environment.php:246
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\callUserFunctionInvalidParameterDataprovider
‪array callUserFunctionInvalidParameterDataprovider()
Definition: GeneralUtilityTest.php:3615
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\mkdirDeepCreatesDirectoryInVfsStream
‪mkdirDeepCreatesDirectoryInVfsStream()
Definition: GeneralUtilityTest.php:2562
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\quoteJsValueTest
‪quoteJsValueTest(string $input, string $expected)
Definition: GeneralUtilityTest.php:2019
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\canRetrieveGlobalInputsThroughPost
‪canRetrieveGlobalInputsThroughPost($key, $post, $expected)
Definition: GeneralUtilityTest.php:225
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\rmdirRemovesDirectoryWithTrailingSlash
‪rmdirRemovesDirectoryWithTrailingSlash()
Definition: GeneralUtilityTest.php:2642
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\splitFileRefReturnsFileTypeForFilesWithoutPathSite
‪splitFileRefReturnsFileTypeForFilesWithoutPathSite()
Definition: GeneralUtilityTest.php:2956
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\camelCaseToLowerCaseUnderscored
‪camelCaseToLowerCaseUnderscored($expected, $inputString)
Definition: GeneralUtilityTest.php:1343
‪TYPO3\CMS\Core\Tests\Unit\Utility\Fixtures\GeneralUtilityFilesystemFixture
Definition: GeneralUtilityFilesystemFixture.php:26
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\getIndpEnvTypo3HostOnlyParsesHostnamesAndIpAddresses
‪getIndpEnvTypo3HostOnlyParsesHostnamesAndIpAddresses($httpHost, $expectedIp)
Definition: GeneralUtilityTest.php:1255
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\makeInstanceWithEmptyClassNameThrowsException
‪makeInstanceWithEmptyClassNameThrowsException()
Definition: GeneralUtilityTest.php:3055
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\jsonEncodeForHtmlAttributeTest
‪jsonEncodeForHtmlAttributeTest($value, bool $useHtmlEntities, string $expectation)
Definition: GeneralUtilityTest.php:2051
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\callUserFunctionTrimsSpaces
‪callUserFunctionTrimsSpaces()
Definition: GeneralUtilityTest.php:3676
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\fixPermissionsSetsDefaultPermissionsToFile
‪fixPermissionsSetsDefaultPermissionsToFile()
Definition: GeneralUtilityTest.php:2272
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\isConnected
‪bool isConnected()
Definition: GeneralUtilityTest.php:94
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\sanitizeLocalUrlAcceptsNotEncodedValidUrls
‪sanitizeLocalUrlAcceptsNotEncodedValidUrls(string $url, string $host, string $subDirectory)
Definition: GeneralUtilityTest.php:1566
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\trimExplodeReturnsCorrectResult
‪trimExplodeReturnsCorrectResult(string $delimiter, string $testString, bool $removeEmpty, int $limit, array $expectedResult)
Definition: GeneralUtilityTest.php:964
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\getFileAbsFileNameReturnsCorrectValues
‪getFileAbsFileNameReturnsCorrectValues(string $path, string $expected)
Definition: GeneralUtilityTest.php:3434
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\cmpIPv4DataProviderMatching
‪static array cmpIPv4DataProviderMatching()
Definition: GeneralUtilityTest.php:239
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\callUserFunctionAcceptsClosures
‪callUserFunctionAcceptsClosures()
Definition: GeneralUtilityTest.php:3663
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\makeInstancePassesParametersToConstructor
‪makeInstancePassesParametersToConstructor()
Definition: GeneralUtilityTest.php:3133
‪TYPO3\CMS\Core\Utility\GeneralUtility\camelCaseToLowerCaseUnderscored
‪static string camelCaseToLowerCaseUnderscored($string)
Definition: GeneralUtility.php:853
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\xml2arrayProcessHandlesWhitespacesDataProvider
‪string[][] xml2arrayProcessHandlesWhitespacesDataProvider()
Definition: GeneralUtilityTest.php:3737
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\normalizeCompressIPv6DataProviderCorrect
‪static array normalizeCompressIPv6DataProviderCorrect()
Definition: GeneralUtilityTest.php:358
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\mkdirDeepDoesNotChangePermissionsOfExistingSubDirectories
‪mkdirDeepDoesNotChangePermissionsOfExistingSubDirectories()
Definition: GeneralUtilityTest.php:2544
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\xml2arrayProcessHandlesDocumentTagDataProvider
‪array[] xml2arrayProcessHandlesDocumentTagDataProvider()
Definition: GeneralUtilityTest.php:3864
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\mkdirCreatesDirectory
‪mkdirCreatesDirectory()
Definition: GeneralUtilityTest.php:2311
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\normalizeIPv6CorrectlyNormalizesAddresses
‪normalizeIPv6CorrectlyNormalizesAddresses($compressed, $normalized)
Definition: GeneralUtilityTest.php:374
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\intExplodeConvertsStringsToInteger
‪intExplodeConvertsStringsToInteger()
Definition: GeneralUtilityTest.php:779
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\mkdirDeepThrowsExceptionIfBaseDirectoryIsNotOfTypeString
‪mkdirDeepThrowsExceptionIfBaseDirectoryIsNotOfTypeString()
Definition: GeneralUtilityTest.php:2585
‪TYPO3\CMS\Core\Tests\Unit\Utility\Fixtures\TwoParametersConstructorFixture
Definition: TwoParametersConstructorFixture.php:24
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\rmdirRemovesDirectory
‪rmdirRemovesDirectory()
Definition: GeneralUtilityTest.php:2631
‪TYPO3\CMS\Core\Tests\Unit\Utility\Fixtures\ReplacementClassFixture
Definition: ReplacementClassFixture.php:23
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\invalidFilePathForTypo3tempDirDataProvider
‪array invalidFilePathForTypo3tempDirDataProvider()
Definition: GeneralUtilityTest.php:2369
‪TYPO3\CMS\Core\Utility\GeneralUtility\implodeArrayForUrl
‪static string implodeArrayForUrl($name, array $theArray, $str='', $skipBlank=false, $rawurlencodeParamName=false)
Definition: GeneralUtility.php:1037
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\inListForItemNotContainedReturnsFalse
‪inListForItemNotContainedReturnsFalse(string $haystack)
Definition: GeneralUtilityTest.php:521
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\addInstanceForClassThatIsNoSubclassOfProvidedClassThrowsException
‪addInstanceForClassThatIsNoSubclassOfProvidedClassThrowsException()
Definition: GeneralUtilityTest.php:3319
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\fixPermissionsDoesNotSetPermissionsToNotAllowedPath
‪fixPermissionsDoesNotSetPermissionsToNotAllowedPath()
Definition: GeneralUtilityTest.php:2236
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\mkdirDeepFixesPermissionsOfCreatedDirectory
‪mkdirDeepFixesPermissionsOfCreatedDirectory()
Definition: GeneralUtilityTest.php:2507
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\validEmailReturnsTrueForValidMailAddress
‪validEmailReturnsTrueForValidMailAddress($address)
Definition: GeneralUtilityTest.php:722
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\expandListExpandsIntegerRangesDataProvider
‪array expandListExpandsIntegerRangesDataProvider()
Definition: GeneralUtilityTest.php:559
‪TYPO3\CMS\Core\Core\Environment\getContext
‪static ApplicationContext getContext()
Definition: Environment.php:141
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\getFilesInDirCreateTestDirectory
‪string getFilesInDirCreateTestDirectory()
Definition: GeneralUtilityTest.php:2732
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\sanitizeLocalUrlDeniesPlainInvalidUrlsInFrontendContext
‪sanitizeLocalUrlDeniesPlainInvalidUrlsInFrontendContext(string $url)
Definition: GeneralUtilityTest.php:1656
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\getIndpEnvTypo3PortParsesHostnamesAndIpAddresses
‪getIndpEnvTypo3PortParsesHostnamesAndIpAddresses($httpHost, $dummy, $expectedPort)
Definition: GeneralUtilityTest.php:1265
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\unlink_tempfileRemovesHiddenFile
‪unlink_tempfileRemovesHiddenFile()
Definition: GeneralUtilityTest.php:1703
‪TYPO3\CMS\Core\Utility\GeneralUtility\get_dirs
‪static string[] string null get_dirs($path)
Definition: GeneralUtility.php:2018
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\getFilesInDirDoesNotFindDirectories
‪getFilesInDirDoesNotFindDirectories()
Definition: GeneralUtilityTest.php:2906
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\makeInstanceCalledTwoTimesForSingletonClassWithPurgeInstancesInbetweenReturnsDifferentInstances
‪makeInstanceCalledTwoTimesForSingletonClassWithPurgeInstancesInbetweenReturnsDifferentInstances()
Definition: GeneralUtilityTest.php:3182
‪TYPO3\CMS\Core\Utility\ExtensionManagementUtility
Definition: ExtensionManagementUtility.php:43
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\fixPermissionsSetsPermissionsToHiddenDirectory
‪fixPermissionsSetsPermissionsToHiddenDirectory()
Definition: GeneralUtilityTest.php:2164
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\implodeArrayForUrlDataProvider
‪array implodeArrayForUrlDataProvider()
Definition: GeneralUtilityTest.php:795
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\setUp
‪setUp()
Definition: GeneralUtilityTest.php:70
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\makeInstanceWithNullClassNameThrowsException
‪makeInstanceWithNullClassNameThrowsException()
Definition: GeneralUtilityTest.php:3066
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\getFilesInDirDoesNotFindDotfiles
‪getFilesInDirDoesNotFindDotfiles()
Definition: GeneralUtilityTest.php:2921
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\setSingletonInstanceForClassThatIsNoSubclassOfProvidedClassThrowsException
‪setSingletonInstanceForClassThatIsNoSubclassOfProvidedClassThrowsException()
Definition: GeneralUtilityTest.php:3214
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\implodeArrayForUrlCanUrlEncodeKeyNames
‪implodeArrayForUrlCanUrlEncodeKeyNames()
Definition: GeneralUtilityTest.php:828
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\mkdirDeepFixesPermissionsOnNewParentDirectory
‪mkdirDeepFixesPermissionsOnNewParentDirectory()
Definition: GeneralUtilityTest.php:2525
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\$resetSingletonInstances
‪bool $resetSingletonInstances
Definition: GeneralUtilityTest.php:59
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\xml2ArrayProcessHandlesBigXmlContentDataProvider
‪array[] xml2ArrayProcessHandlesBigXmlContentDataProvider()
Definition: GeneralUtilityTest.php:3923
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\fixPermissionsSetsDefaultPermissionsToDirectory
‪fixPermissionsSetsDefaultPermissionsToDirectory()
Definition: GeneralUtilityTest.php:2290
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\cmpFqdnValidDataProvider
‪static array cmpFqdnValidDataProvider()
Definition: GeneralUtilityTest.php:441
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\getFilesInDirCanOrderByMtime
‪getFilesInDirCanOrderByMtime()
Definition: GeneralUtilityTest.php:2874
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\hostnameAndPortDataProvider
‪static array hostnameAndPortDataProvider()
Definition: GeneralUtilityTest.php:1237
‪TYPO3\CMS\Core\Core\Environment\getProjectPath
‪static string getProjectPath()
Definition: Environment.php:177
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest
Definition: GeneralUtilityTest.php:54
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\validURLReturnsTrueForValidResource
‪validURLReturnsTrueForValidResource($url)
Definition: GeneralUtilityTest.php:1385
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\getFileAbsFileNameDataProvider
‪array getFileAbsFileNameDataProvider()
Definition: GeneralUtilityTest.php:3394
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\tearDown
‪tearDown()
Definition: GeneralUtilityTest.php:79
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\fixPermissionsCorrectlySetsPermissionsRecursive
‪fixPermissionsCorrectlySetsPermissionsRecursive()
Definition: GeneralUtilityTest.php:2185
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\xml2ArrayProcessHandlesAttributeTypes
‪xml2ArrayProcessHandlesAttributeTypes(string $input, $expected)
Definition: GeneralUtilityTest.php:4050
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\fixPermissionsSetsPermissionsWithRelativeFileReference
‪fixPermissionsSetsPermissionsWithRelativeFileReference()
Definition: GeneralUtilityTest.php:2252
‪TYPO3\CMS\Core\Utility\GeneralUtility\fixPermissions
‪static mixed fixPermissions($path, $recursive=false)
Definition: GeneralUtility.php:1749
‪TYPO3\CMS\Core\Utility\ExtensionManagementUtility\setPackageManager
‪static setPackageManager(PackageManager $packageManager)
Definition: ExtensionManagementUtility.php:66
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\xml2arrayProcessHandlesTagNamespacesDataProvider
‪string[][] xml2arrayProcessHandlesTagNamespacesDataProvider()
Definition: GeneralUtilityTest.php:3809
‪TYPO3\CMS\Core\Utility\GeneralUtility\mkdir_deep
‪static mkdir_deep($directory)
Definition: GeneralUtility.php:1908
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\validIpReturnsFalseForInvalidIp
‪validIpReturnsFalseForInvalidIp($ip)
Definition: GeneralUtilityTest.php:428
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\getBytesFromSizeMeasurementCalculatesCorrectByteValue
‪getBytesFromSizeMeasurementCalculatesCorrectByteValue($expected, $byteString)
Definition: GeneralUtilityTest.php:1209
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\sanitizeLocalUrlDeniesEncodedInvalidUrls
‪sanitizeLocalUrlDeniesEncodedInvalidUrls($url)
Definition: GeneralUtilityTest.php:1678
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\trimExplodeReturnsCorrectResultDataProvider
‪array trimExplodeReturnsCorrectResultDataProvider()
Definition: GeneralUtilityTest.php:972
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\tempnamReturnsPathStartingWithGivenPrefix
‪tempnamReturnsPathStartingWithGivenPrefix()
Definition: GeneralUtilityTest.php:1750
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\underscoredToUpperCamelCaseDataProvider
‪array underscoredToUpperCamelCaseDataProvider()
Definition: GeneralUtilityTest.php:1279
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\makeInstanceWithNonEmptyArrayThrowsException
‪makeInstanceWithNonEmptyArrayThrowsException()
Definition: GeneralUtilityTest.php:3102
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\rmdirRemovesDeadLinkToDirectory
‪rmdirRemovesDeadLinkToDirectory()
Definition: GeneralUtilityTest.php:2697
‪TYPO3\CMS\Core\Package\Package
Definition: Package.php:28
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\validPathStrDetectsInvalidCharacters
‪validPathStrDetectsInvalidCharacters(string $path)
Definition: GeneralUtilityTest.php:3505
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\unlink_tempfileReturnsTrueIfFileWasRemoved
‪unlink_tempfileReturnsTrueIfFileWasRemoved()
Definition: GeneralUtilityTest.php:1716
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\removeDotsFromTypoScriptSucceedsWithDottedArray
‪removeDotsFromTypoScriptSucceedsWithDottedArray()
Definition: GeneralUtilityTest.php:1784
‪TYPO3\CMS\Core\Cache\CacheManager
Definition: CacheManager.php:36
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\sanitizeLocalUrlValidPathsDataProvider
‪array sanitizeLocalUrlValidPathsDataProvider()
Definition: GeneralUtilityTest.php:1473
‪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:111
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\inListForItemContainedReturnsTrueDataProvider
‪array inListForItemContainedReturnsTrueDataProvider()
Definition: GeneralUtilityTest.php:506
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\validIpDataProvider
‪static array validIpDataProvider()
Definition: GeneralUtilityTest.php:387
‪TYPO3\CMS\Core\Http\ServerRequest
Definition: ServerRequest.php:37
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\mkdirCreatesDirectoryWithTrailingSlash
‪mkdirCreatesDirectoryWithTrailingSlash()
Definition: GeneralUtilityTest.php:2335
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\tempnamReturnsAbsolutePathInVarPath
‪tempnamReturnsAbsolutePathInVarPath()
Definition: GeneralUtilityTest.php:1771
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\unlink_tempfileReturnsNullIfFileDoesNotExist
‪unlink_tempfileReturnsNullIfFileDoesNotExist()
Definition: GeneralUtilityTest.php:1728
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\quoteJsValueDataProvider
‪array quoteJsValueDataProvider()
Definition: GeneralUtilityTest.php:1967
‪TYPO3\CMS\Core\Core\Environment\getBackendPath
‪static string getBackendPath()
Definition: Environment.php:276
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\validEmailReturnsFalseForInvalidMailAddress
‪validEmailReturnsFalseForInvalidMailAddress($address)
Definition: GeneralUtilityTest.php:768
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\sanitizeLocalUrlAcceptsEncodedValidUrls
‪sanitizeLocalUrlAcceptsEncodedValidUrls(string $url, string $host, string $subDirectory)
Definition: GeneralUtilityTest.php:1591
‪TYPO3\CMS\Core\Utility\GeneralUtility\xml2arrayProcess
‪static mixed xml2arrayProcess($string, $NSprefix='', $reportDocTag=false)
Definition: GeneralUtility.php:1505
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\callUserFunctionCanCallFunction
‪callUserFunctionCanCallFunction()
Definition: GeneralUtilityTest.php:3633
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\makeInstanceInstanciatesConfiguredImplementation
‪makeInstanceInstanciatesConfiguredImplementation()
Definition: GeneralUtilityTest.php:3143
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\rmdirReturnTrueIfFileWasRemoved
‪rmdirReturnTrueIfFileWasRemoved()
Definition: GeneralUtilityTest.php:2612
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\canRetrieveValueWithGP
‪canRetrieveValueWithGP($key, $get, $post, $expected)
Definition: GeneralUtilityTest.php:127
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\mkdirSetsPermissionsOfCreatedDirectory
‪mkdirSetsPermissionsOfCreatedDirectory()
Definition: GeneralUtilityTest.php:2347
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\setSingletonInstanceReturnsFinalClassNameWithOverriddenClass
‪setSingletonInstanceReturnsFinalClassNameWithOverriddenClass()
Definition: GeneralUtilityTest.php:3266
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\formatSizeDataProvider
‪array formatSizeDataProvider()
Definition: GeneralUtilityTest.php:600
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\mkdirDeepCreatesDirectory
‪mkdirDeepCreatesDirectory()
Definition: GeneralUtilityTest.php:2463
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\underscoredToUpperCamelCase
‪underscoredToUpperCamelCase($expected, $inputString)
Definition: GeneralUtilityTest.php:1291
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\getFilesInDirCanPrependPath
‪getFilesInDirCanPrependPath()
Definition: GeneralUtilityTest.php:2850
‪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:1432
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\inListForItemContainedReturnsTrue
‪inListForItemContainedReturnsTrue(string $haystack)
Definition: GeneralUtilityTest.php:496
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\cmpIPv6DataProviderMatching
‪static array cmpIPv6DataProviderMatching()
Definition: GeneralUtilityTest.php:297
‪TYPO3\CMS\Core\Tests\Unit\Utility\Fixtures\OriginalClassFixture
Definition: OriginalClassFixture.php:23
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\mkdirDeepCreatesSubdirectoriesRecursive
‪mkdirDeepCreatesSubdirectoriesRecursive()
Definition: GeneralUtilityTest.php:2473
‪$output
‪$output
Definition: annotationChecker.php:121
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\jsonEncodeForJavaScriptTestDataProvider
‪static jsonEncodeForJavaScriptTestDataProvider()
Definition: GeneralUtilityTest.php:2056
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\purgeInstancesDropsAddedInstance
‪purgeInstancesDropsAddedInstance()
Definition: GeneralUtilityTest.php:3382
‪TYPO3\CMS\Core\Utility\GeneralUtility\isValidUrl
‪static bool isValidUrl($url)
Definition: GeneralUtility.php:883
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\xml2arrayProcessHandlesTagNamespaces
‪xml2arrayProcessHandlesTagNamespaces(string $input)
Definition: GeneralUtilityTest.php:3849
‪TYPO3\CMS\Core\Cache\Frontend\FrontendInterface
Definition: FrontendInterface.php:22
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\mkdirDeepThrowsExceptionIfDirectoryCreationFails
‪mkdirDeepThrowsExceptionIfDirectoryCreationFails()
Definition: GeneralUtilityTest.php:2574
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\cmpIPv4DataProviderNotMatching
‪static array cmpIPv4DataProviderNotMatching()
Definition: GeneralUtilityTest.php:268
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\getIndpEnvTypo3SitePathReturnNonEmptyString
‪getIndpEnvTypo3SitePathReturnNonEmptyString()
Definition: GeneralUtilityTest.php:1220
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\validPathStrWorksWithUnicodeFileNames
‪validPathStrWorksWithUnicodeFileNames($path)
Definition: GeneralUtilityTest.php:3529
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\validURLReturnsFalseForInvalidResource
‪validURLReturnsFalseForInvalidResource($url)
Definition: GeneralUtilityTest.php:1420
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\cmpFqdnReturnsFalse
‪cmpFqdnReturnsFalse($baseHost, $list)
Definition: GeneralUtilityTest.php:483
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\cmpIPv4ReturnsTrueForMatchingAddress
‪cmpIPv4ReturnsTrueForMatchingAddress($ip, $list)
Definition: GeneralUtilityTest.php:258
‪TYPO3\CMS\Core\Utility\StringUtility\getUniqueId
‪static string getUniqueId($prefix='')
Definition: StringUtility.php:128
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\hmacReturnsHashOfProperLength
‪hmacReturnsHashOfProperLength()
Definition: GeneralUtilityTest.php:1929
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\removeDotsFromTypoScriptOverridesWithScalar
‪removeDotsFromTypoScriptOverridesWithScalar()
Definition: GeneralUtilityTest.php:1878
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\getDirsReturnsArrayOfDirectoriesFromGivenDirectory
‪getDirsReturnsArrayOfDirectoriesFromGivenDirectory()
Definition: GeneralUtilityTest.php:1906
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\getAndPostDataProvider
‪array getAndPostDataProvider()
Definition: GeneralUtilityTest.php:201
‪TYPO3\CMS\Core\SingletonInterface
Definition: SingletonInterface.php:22
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:25
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\camelCaseToLowerCaseUnderscoredDataProvider
‪array camelCaseToLowerCaseUnderscoredDataProvider()
Definition: GeneralUtilityTest.php:1329
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\fixPermissionsSetsPermissionsToDirectory
‪fixPermissionsSetsPermissionsToDirectory()
Definition: GeneralUtilityTest.php:2123
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\getFilesInDirByExtensionFindsFiles
‪getFilesInDirByExtensionFindsFiles($fileExtensions)
Definition: GeneralUtilityTest.php:2814
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\revExplodeCorrectlyExplodesStringForGivenPartsCount
‪revExplodeCorrectlyExplodesStringForGivenPartsCount($delimiter, $testString, $count, $expectedArray)
Definition: GeneralUtilityTest.php:934
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\resolveBackPathDataProvider
‪array array[] resolveBackPathDataProvider()
Definition: GeneralUtilityTest.php:3005
‪TYPO3\CMS\Core\Core\Environment
Definition: Environment.php:43
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\cmpIPv6ReturnsFalseForNotMatchingAddress
‪cmpIPv6ReturnsFalseForNotMatchingAddress($ip, $list)
Definition: GeneralUtilityTest.php:345
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\validUrlValidResourceDataProvider
‪array validUrlValidResourceDataProvider()
Definition: GeneralUtilityTest.php:1356
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\sanitizeLocalUrlAcceptsEncodedValidPaths
‪sanitizeLocalUrlAcceptsEncodedValidPaths(string $path)
Definition: GeneralUtilityTest.php:1512
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\splitCalcDataProvider
‪array splitCalcDataProvider()
Definition: GeneralUtilityTest.php:647
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\getFilesInDirExcludesFilesMatchingPattern
‪getFilesInDirExcludesFilesMatchingPattern()
Definition: GeneralUtilityTest.php:2839
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\setSingletonInstanceCalledTwoTimesMakesMakeInstanceReturnLastSetInstance
‪setSingletonInstanceCalledTwoTimesMakesMakeInstanceReturnLastSetInstance()
Definition: GeneralUtilityTest.php:3240
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\resetSingletonInstancesResetsPreviouslySetInstance
‪resetSingletonInstancesResetsPreviouslySetInstance()
Definition: GeneralUtilityTest.php:3280
‪TYPO3\CMS\Core\Utility\GeneralUtility\intExplode
‪static int[] intExplode($delimiter, $string, $removeEmptyValues=false, $limit=0)
Definition: GeneralUtility.php:927
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\resetSingletonInstancesSetsGivenInstance
‪resetSingletonInstancesSetsGivenInstance()
Definition: GeneralUtilityTest.php:3293
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\isValidUrlInvalidResourceDataProvider
‪array isValidUrlInvalidResourceDataProvider()
Definition: GeneralUtilityTest.php:1395
‪TYPO3\CMS\Core\Utility\GeneralUtility\rmdir
‪static bool rmdir($path, $removeNonEmpty=false)
Definition: GeneralUtility.php:1961
‪TYPO3\CMS\Core\Core\Environment\getConfigPath
‪static string getConfigPath()
Definition: Environment.php:236
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\user_calledUserFunction
‪string user_calledUserFunction()
Definition: GeneralUtilityTest.php:3655
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\makeInstanceCalledTwoTimesAfterAddInstanceReturnTwoDifferentInstances
‪makeInstanceCalledTwoTimesAfterAddInstanceReturnTwoDifferentInstances()
Definition: GeneralUtilityTest.php:3357
‪TYPO3\CMS\Core\Tests\Unit\Utility\Fixtures\OtherReplacementClassFixture
Definition: OtherReplacementClassFixture.php:23
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\removeDotsFromTypoScriptOverridesSubArray
‪removeDotsFromTypoScriptOverridesSubArray()
Definition: GeneralUtilityTest.php:1851
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\$backupEnvironment
‪bool $backupEnvironment
Definition: GeneralUtilityTest.php:63
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\locationHeaderUrlDataProvider
‪locationHeaderUrlDataProvider()
Definition: GeneralUtilityTest.php:4056
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\tempnamReturnsPathWithoutBackslashes
‪tempnamReturnsPathWithoutBackslashes()
Definition: GeneralUtilityTest.php:1761
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\fixPermissionsSetsPermissionsToFile
‪fixPermissionsSetsPermissionsToFile()
Definition: GeneralUtilityTest.php:2083
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\implodeAttributesDataProvider
‪implodeAttributesDataProvider()
Definition: GeneralUtilityTest.php:1811
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\getVirtualTestDir
‪string getVirtualTestDir(string $prefix='root_')
Definition: GeneralUtilityTest.php:112
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\getMaxUploadFileSizeReturnsPositiveInt
‪getMaxUploadFileSizeReturnsPositiveInt()
Definition: GeneralUtilityTest.php:4174
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\addInstanceCalledTwoTimesMakesMakeInstanceReturnBothInstancesInAddingOrder
‪addInstanceCalledTwoTimesMakesMakeInstanceReturnBothInstancesInAddingOrder()
Definition: GeneralUtilityTest.php:3368
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\canRetrieveGlobalInputsThroughGet
‪canRetrieveGlobalInputsThroughGet($key, $get, $expected)
Definition: GeneralUtilityTest.php:215
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\getFilesInDirFindsHiddenFile
‪getFilesInDirFindsHiddenFile()
Definition: GeneralUtilityTest.php:2780
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\splitCalcCorrectlySplitsExpression
‪splitCalcCorrectlySplitsExpression(array $expected, string $expression)
Definition: GeneralUtilityTest.php:669
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\dirnameWithDataProvider
‪dirnameWithDataProvider(string $input, string $expectedValue)
Definition: GeneralUtilityTest.php:2993
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\cmpIPv4ReturnsFalseForNotMatchingAddress
‪cmpIPv4ReturnsFalseForNotMatchingAddress($ip, $list)
Definition: GeneralUtilityTest.php:284
‪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:65
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\fixPermissionsSetsPermissionsToDirectoryWithTrailingSlash
‪fixPermissionsSetsPermissionsToDirectoryWithTrailingSlash()
Definition: GeneralUtilityTest.php:2143
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\xml2arrayProcessHandlesWhitespaces
‪xml2arrayProcessHandlesWhitespaces(string $input)
Definition: GeneralUtilityTest.php:3794
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\makeInstanceCalledTwoTimesForNonSingletonClassReturnsDifferentInstances
‪makeInstanceCalledTwoTimesForNonSingletonClassReturnsDifferentInstances()
Definition: GeneralUtilityTest.php:3164
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:50
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\validFilePathForTypo3tempDirDataProvider
‪array validFilePathForTypo3tempDirDataProvider()
Definition: GeneralUtilityTest.php:2418
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\getIndpEnvTypo3SitePathReturnsStringEndingWithSlash
‪getIndpEnvTypo3SitePathReturnsStringEndingWithSlash()
Definition: GeneralUtilityTest.php:1228
‪TYPO3\CMS\Core\Utility\StringUtility
Definition: StringUtility.php:22
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\fileExtensionDataProvider
‪array fileExtensionDataProvider()
Definition: GeneralUtilityTest.php:2792
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\formatSizeTranslatesBytesToHigherOrderRepresentation
‪formatSizeTranslatesBytesToHigherOrderRepresentation($size, $labels, $base, $expected)
Definition: GeneralUtilityTest.php:590
‪TYPO3\CMS\Core\Core\SystemEnvironmentBuilder\REQUESTTYPE_FE
‪const REQUESTTYPE_FE
Definition: SystemEnvironmentBuilder.php:43
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\getBytesFromSizeMeasurementDataProvider
‪array getBytesFromSizeMeasurementDataProvider()
Definition: GeneralUtilityTest.php:1196
‪TYPO3\CMS\Core\Utility\GeneralUtility\mkdir
‪static bool mkdir($newFolder)
Definition: GeneralUtility.php:1891
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\getFilesInDirFindsRegularFile
‪getFilesInDirFindsRegularFile()
Definition: GeneralUtilityTest.php:2770
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\gpMergedDataProvider
‪array gpMergedDataProvider()
Definition: GeneralUtilityTest.php:177
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\rmdirRemovesLinkToDirectory
‪rmdirRemovesLinkToDirectory()
Definition: GeneralUtilityTest.php:2683
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\addInstanceWithSingletonInstanceThrowsException
‪addInstanceWithSingletonInstanceThrowsException()
Definition: GeneralUtilityTest.php:3334
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\makeInstanceReturnsClassInstance
‪makeInstanceReturnsClassInstance()
Definition: GeneralUtilityTest.php:3125
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\setSingletonInstanceForEmptyClassNameThrowsException
‪setSingletonInstanceForEmptyClassNameThrowsException()
Definition: GeneralUtilityTest.php:3202
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\cmpIPv6ReturnsTrueForMatchingAddress
‪cmpIPv6ReturnsTrueForMatchingAddress($ip, $list)
Definition: GeneralUtilityTest.php:317
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\rmdirRemovesDeadLinkToFile
‪rmdirRemovesDeadLinkToFile()
Definition: GeneralUtilityTest.php:2712
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\writeFileToTypo3tempDirFailsWithInvalidPath
‪writeFileToTypo3tempDirFailsWithInvalidPath(string $invalidFilePath, string $expectedResult)
Definition: GeneralUtilityTest.php:2409
‪TYPO3\CMS\Core\Utility\GeneralUtility\underscoredToUpperCamelCase
‪static string underscoredToUpperCamelCase($string)
Definition: GeneralUtility.php:829
‪TYPO3\CMS\Core\Core\Environment\getLegacyConfigPath
‪static string getLegacyConfigPath()
Definition: Environment.php:308
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\unlink_tempfileReturnsNullIfFileIsNowWithinTypo3temp
‪unlink_tempfileReturnsNullIfFileIsNowWithinTypo3temp()
Definition: GeneralUtilityTest.php:1737
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\splitFileRefReturnsFileTypeNotForFolders
‪splitFileRefReturnsFileTypeNotForFolders()
Definition: GeneralUtilityTest.php:2935
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\xml2ArrayProcessHandlesAttributeTypesDataProvider
‪array[] xml2ArrayProcessHandlesAttributeTypesDataProvider()
Definition: GeneralUtilityTest.php:3972
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\revExplodeRespectsLimitThreeWhenExploding
‪revExplodeRespectsLimitThreeWhenExploding()
Definition: GeneralUtilityTest.php:943
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\implodeAttributesEscapesProperly
‪implodeAttributesEscapesProperly(array $input, bool $xhtmlSafe, bool $keepEmptyValues, string $expected)
Definition: GeneralUtilityTest.php:1843
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\isOnCurrentHostWithNotCurrentHostReturnsFalse
‪static isOnCurrentHostWithNotCurrentHostReturnsFalse(string $hostCandidate)
Definition: GeneralUtilityTest.php:1460
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\expandListExpandsForTwoThousandElementsExpandsOnlyToThousandElementsMaximum
‪expandListExpandsForTwoThousandElementsExpandsOnlyToThousandElementsMaximum()
Definition: GeneralUtilityTest.php:577
‪TYPO3\CMS\Core\Core\Environment\getVarPath
‪static string getVarPath()
Definition: Environment.php:218
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\rmdirReturnFalseIfNoFileWasRemoved
‪rmdirReturnFalseIfNoFileWasRemoved()
Definition: GeneralUtilityTest.php:2622
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\revExplodeDataProvider
‪array revExplodeDataProvider()
Definition: GeneralUtilityTest.php:864
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\expandListExpandsIntegerRanges
‪expandListExpandsIntegerRanges(string $list, string $expectation)
Definition: GeneralUtilityTest.php:549
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\addInstanceForEmptyClassNameThrowsException
‪addInstanceForEmptyClassNameThrowsException()
Definition: GeneralUtilityTest.php:3308
‪TYPO3\CMS\Core\Utility\GeneralUtility\writeFileToTypo3tempDir
‪static string null writeFileToTypo3tempDir($filepath, $content)
Definition: GeneralUtility.php:1814
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\dirnameDataProvider
‪array array[] dirnameDataProvider()
Definition: GeneralUtilityTest.php:2974
‪TYPO3\CMS\Core\Tests\Unit\Utility\GeneralUtilityTest\gpMergedWillMergeArraysFromGetAndPost
‪gpMergedWillMergeArraysFromGetAndPost($get, $post, $expected)
Definition: GeneralUtilityTest.php:165