‪TYPO3CMS  ‪main
DataHandlerTest.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 PHPUnit\Framework\MockObject\MockObject;
21 use Psr\EventDispatcher\EventDispatcherInterface;
22 use Symfony\Component\Uid\Uuid;
38 use TYPO3\TestingFramework\Core\AccessibleObjectInterface;
39 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
40 
41 final class ‪DataHandlerTest extends UnitTestCase
42 {
43  protected bool ‪$resetSingletonInstances = true;
44  protected ‪DataHandler&MockObject&AccessibleObjectInterface ‪$subject;
46 
47  protected function ‪setUp(): void
48  {
49  parent::setUp();
50  ‪$GLOBALS['TCA'] = [];
51  $cacheManager = new ‪CacheManager();
52  $cacheManager->registerCache(new ‪NullFrontend('runtime'));
53  GeneralUtility::setSingletonInstance(CacheManager::class, $cacheManager);
54  $this->backendUserMock = $this->createMock(BackendUserAuthentication::class);
55  $this->subject = $this->getAccessibleMock(DataHandler::class, null);
56  $this->subject->start([], [], $this->backendUserMock);
57  }
58 
62  public function ‪fixtureCanBeCreated(): void
63  {
64  self::assertInstanceOf(DataHandler::class, $this->subject);
65  }
66 
68  // Test concerning checkModifyAccessList
70 
74  {
75  $this->subject->admin = true;
76  self::assertTrue($this->subject->checkModifyAccessList('tt_content'));
77  }
78 
83  {
84  $this->subject->admin = false;
85  self::assertFalse($this->subject->checkModifyAccessList('tt_content'));
86  }
87 
92  {
93  $this->subject->admin = false;
94  $this->backendUserMock->groupData['tables_modify'] = 'tt_content';
95  self::assertTrue($this->subject->checkModifyAccessList('tt_content'));
96  }
97 
101  public function ‪adminIsAllowedToModifyAdminTable(): void
102  {
103  $this->subject->admin = true;
104  self::assertTrue($this->subject->checkModifyAccessList('be_users'));
105  }
106 
111  {
112  $this->subject->admin = false;
113  self::assertFalse($this->subject->checkModifyAccessList('be_users'));
114  }
115 
120  {
121  $tableName = ‪StringUtility::getUniqueId('aTable');
122  ‪$GLOBALS['TCA'] = [
123  $tableName => [
124  'ctrl' => [
125  'adminOnly' => true,
126  ],
127  ],
128  ];
129  $this->subject->admin = false;
130  $this->backendUserMock->groupData['tables_modify'] = $tableName;
131  self::assertFalse($this->subject->checkModifyAccessList($tableName));
132  }
133 
134  public static function ‪checkValueForDatetimeDataProvider(): array
135  {
136  // Three elements: input, timezone of input, expected output (UTC)
137  return [
138  'timestamp is passed through, as it is UTC' => [
139  1457103519, 'Europe/Berlin', 1457103519,
140  ],
141  'ISO date is interpreted as local date and is output as correct timestamp' => [
142  '2017-06-07T00:10:00Z', 'Europe/Berlin', 1496787000,
143  ],
144  ];
145  }
146 
151  public function ‪checkValueForDatetime($input, $serverTimezone, $expectedOutput): void
152  {
153  $oldTimezone = date_default_timezone_get();
154  date_default_timezone_set($serverTimezone);
155 
156  ‪$output = $this->subject->_call('checkValueForDatetime', $input, ['type' => 'datetime']);
157 
158  // set before the assertion is performed, so it is restored even for failing tests
159  date_default_timezone_set($oldTimezone);
160 
161  self::assertEquals($expectedOutput, ‪$output['value']);
162  }
163 
164  public static function ‪checkValueForColorDataProvider(): array
165  {
166  // Three elements: input, timezone of input, expected output (UTC)
167  return [
168  'trim is applied' => [
169  ' #FF8700 ', '#FF8700',
170  ],
171  'max string length is respected' => [
172  '#FF8700123', '#FF8700',
173  ],
174  'required is checked' => [
175  '', null, ['required' => true],
176  ],
177  ];
178  }
179 
184  public function ‪checkValueForColor(string $input, mixed $expected, array $additionalFieldConfig = []): void
185  {
186  ‪$output = $this->subject->_call(
187  'checkValueForColor',
188  $input,
189  array_replace_recursive(['type' => 'datetime'], $additionalFieldConfig)
190  );
191 
192  self::assertEquals($expected, ‪$output['value'] ?? null);
193  }
194 
199  {
200  // Note the involved salted passwords are NOT mocked since the factory is static
201  $inputValue = '$1$GNu9HdMt$RwkPb28pce4nXZfnplVZY/';
202  $result = $this->subject->_call('checkValueForPassword', $inputValue, [], 'be_users', 0, 0);
203  self::assertSame($inputValue, $result['value']);
204  }
205 
210  {
212  $eventDispatcher = $this->createMock(EventDispatcherInterface::class);
213  $eventDispatcher->expects(self::once())->method('dispatch')->willReturn($event);
214  GeneralUtility::addInstance(EventDispatcherInterface::class, $eventDispatcher);
215 
216  // Note the involved salted passwords are NOT mocked since the factory is static
217  $inputValue = 'myPassword';
218  $result = $this->subject->_call('checkValueForPassword', $inputValue, [], 'be_users', 0, 0);
219  self::assertNotSame($inputValue, $result['value']);
220  }
221 
223  {
224  return [
225  'Empty string returns zero as integer' => [
226  '',
227  0,
228  ],
229  '"0" returns zero as integer' => [
230  '0',
231  0,
232  ],
233  '"-2000001" is interpreted correctly as -2000001 but is lower than -2000000 and set to -2000000' => [
234  '-2000001',
235  -2000000,
236  ],
237  '"-2000000" is interpreted correctly as -2000000 and is equal to -2000000' => [
238  '-2000000',
239  -2000000,
240  ],
241  '"2000000" is interpreted correctly as 2000000 and is equal to 2000000' => [
242  '2000000',
243  2000000,
244  ],
245  '"2000001" is interpreted correctly as 2000001 but is greater then 2000000 and set to 2000000' => [
246  '2000001',
247  2000000,
248  ],
249  ];
250  }
251 
256  public function ‪numberValueCheckRecognizesStringValuesAsIntegerValuesCorrectly(string $value, int $expectedReturnValue): void
257  {
258  $tcaFieldConf = [
259  'type' => 'number',
260  'range' => [
261  'lower' => '-2000000',
262  'upper' => '2000000',
263  ],
264  ];
265  $returnValue = $this->subject->_call('checkValueForNumber', $value, $tcaFieldConf, '', 0, 0, '');
266  self::assertSame($expectedReturnValue, $returnValue['value']);
267  }
268 
270  {
271  yield 'simple negative decimal value with comma and one position' => [
272  'input' => '-0,5',
273  'expected' => '-0.50',
274  ];
275 
276  yield 'simple integer' => [
277  'input' => '1000',
278  'expected' => '1000.00',
279  ];
280 
281  yield 'positive decimal value with one position' => [
282  'input' => '1000,0',
283  'expected' => '1000.00',
284  ];
285 
286  yield 'positive decimal value with 2 positions and trailing zero' => [
287  'input' => '1000,10',
288  'expected' => '1000.10',
289  ];
290 
291  yield 'positive decimal value with 2 positions without trailing zero' => [
292  'input' => '1000,11',
293  'expected' => '1000.11',
294  ];
295 
296  yield 'number separated with dots' => [
297  'input' => '600.000.000,00',
298  'expected' => '600000000.00',
299  ];
300 
301  yield 'invalid input with characters between the number' => [
302  'input' => '60aaa00',
303  'expected' => '6000.00',
304  ];
305  }
306 
311  public function ‪numberValueCheckRecognizesDecimalStringValuesAsFloatValuesCorrectly(string $value, string $expectedReturnValue): void
312  {
313  $tcaFieldConf = [
314  'type' => 'number',
315  'format' => 'decimal',
316  ];
317  $returnValue = $this->subject->_call('checkValueForNumber', $value, $tcaFieldConf);
318  self::assertSame($expectedReturnValue, $returnValue['value']);
319  }
320 
324  public static function ‪inputValuesRangeDoubleDataProvider(): array
325  {
326  return [
327  'Empty string returns zero as string' => [
328  '',
329  '0.00',
330  ],
331  '"0" returns zero as string' => [
332  '0',
333  '0.00',
334  ],
335  '"-0.5" is interpreted correctly as -0.5 but is lower than 0 and set to 0' => [
336  '-0.5',
337  0,
338  ],
339  '"0.5" is interpreted correctly as 0.5 and is equal to 0.5' => [
340  '0.5',
341  '0.50',
342  ],
343  '"39.9" is interpreted correctly as 39.9 and is equal to 39.9' => [
344  '39.9',
345  '39.90',
346  ],
347  '"42.3" is interpreted correctly as 42.3 but is greater then 42 and set to 42' => [
348  '42.3',
349  42,
350  ],
351  ];
352  }
353 
358  public function ‪inputValueCheckRespectsRightLowerAndUpperLimitForDouble(string $value, string|int $expectedReturnValue): void
359  {
360  $tcaFieldConf = [
361  'type' => 'number',
362  'format' => 'decimal',
363  'range' => [
364  'lower' => '0',
365  'upper' => '42',
366  ],
367  ];
368  $returnValue = $this->subject->_call('checkValueForNumber', $value, $tcaFieldConf);
369  self::assertSame($expectedReturnValue, $returnValue['value']);
370  }
371 
376  public function ‪inputValueCheckRespectsRightLowerAndUpperLimitWithDefaultValueForDouble(string $value, string|int $expectedReturnValue): void
377  {
378  $tcaFieldConf = [
379  'type' => 'number',
380  'format' => 'decimal',
381  'range' => [
382  'lower' => '0',
383  'upper' => '42',
384  ],
385  'default' => 0,
386  ];
387  $returnValue = $this->subject->_call('checkValueForNumber', $value, $tcaFieldConf, '', 0, 0, '');
388  self::assertSame($expectedReturnValue, $returnValue['value']);
389  }
390 
391  public static function ‪datetimeValuesDataProvider(): array
392  {
393  return [
394  'undershot date adjusted' => [
395  '2018-02-28T00:00:00Z',
396  1519862400,
397  ],
398  'exact lower date accepted' => [
399  '2018-03-01T00:00:00Z',
400  1519862400,
401  ],
402  'exact upper date accepted' => [
403  '2018-03-31T23:59:59Z',
404  1522540799,
405  ],
406  'exceeded date adjusted' => [
407  '2018-04-01T00:00:00Z',
408  1522540799,
409  ],
410  ];
411  }
412 
417  public function ‪valueCheckRecognizesDatetimeValuesAsIntegerValuesCorrectly(string $value, int $expected): void
418  {
419  $tcaFieldConf = [
420  'type' => 'datetime',
421  'range' => [
422  // unix timestamp: 1519862400
423  'lower' => gmmktime(0, 0, 0, 3, 1, 2018),
424  // unix timestamp: 1522540799
425  'upper' => gmmktime(23, 59, 59, 3, 31, 2018),
426  ],
427  ];
428 
429  // @todo Switch to UTC since otherwise DataHandler removes timezone offset
430  $previousTimezone = date_default_timezone_get();
431  date_default_timezone_set('UTC');
432 
433  $returnValue = $this->subject->_call('checkValueForDatetime', $value, $tcaFieldConf);
434 
435  date_default_timezone_set($previousTimezone);
436 
437  self::assertSame($expected, $returnValue['value']);
438  }
439 
441  {
442  return [
443  'Empty string returns the number zero' => [
444  '',
445  0,
446  ],
447  'Zero returns zero' => [
448  0,
449  0,
450  ],
451  'Zero as a string returns zero' => [
452  '0',
453  0,
454  ],
455  ];
456  }
457 
463  string|int $inputValue,
464  int $expected,
465  ): void {
466  $tcaFieldConf = [
467  'type' => 'datetime',
468  'default' => 0,
469  'range' => [
470  'lower' => 1627077600,
471  ],
472  ];
473 
474  $returnValue = $this->subject->_call('checkValueForDatetime', $inputValue, $tcaFieldConf);
475  self::assertSame($expected, $returnValue['value']);
476  }
477 
479  {
480  return [
481  // Values of this kind are passed in from the DateTime control
482  'time from DateTime' => [
483  '1970-01-01T18:54:00Z',
484  'time',
485  '18:54:00',
486  ],
487  'date from DateTime' => [
488  '2020-11-25T00:00:00Z',
489  'date',
490  '2020-11-25',
491  ],
492  'datetime from DateTime' => [
493  '2020-11-25T18:54:00Z',
494  'datetime',
495  '2020-11-25 18:54:00',
496  ],
497  // Values of this kind are passed in when a data record is copied
498  'time from copying a record' => [
499  '18:54:00',
500  'time',
501  '18:54:00',
502  ],
503  'date from copying a record' => [
504  '2020-11-25',
505  'date',
506  '2020-11-25',
507  ],
508  'datetime from copying a record' => [
509  '2020-11-25 18:54:00',
510  'datetime',
511  '2020-11-25 18:54:00',
512  ],
513  ];
514  }
515 
521  public function ‪datetimeValueCheckDbtypeIsIndependentFromTimezone(string $value, string $dbtype, string $expectedOutput): void
522  {
523  $tcaFieldConf = [
524  'type' => 'datetime',
525  'dbType' => $dbtype,
526  ];
527 
528  $oldTimezone = date_default_timezone_get();
529  date_default_timezone_set('Europe/Berlin');
530 
531  $returnValue = $this->subject->_call('checkValueForDatetime', $value, $tcaFieldConf);
532 
533  // set before the assertion is performed, so it is restored even for failing tests
534  date_default_timezone_set($oldTimezone);
535 
536  self::assertEquals($expectedOutput, $returnValue['value']);
537  }
538 
539  public static function ‪inputValueCheckNativeDbTypeDataProvider(): array
540  {
541  return [
542  'Datetime at unix epoch' => [
543  '1970-01-01T00:00:00Z',
544  'datetime',
545  'datetime',
546  false,
547  '1970-01-01 00:00:00',
548  ],
549  'Default datetime' => [
550  '0000-00-00 00:00:00',
551  'datetime',
552  'datetime',
553  false,
554  null,
555  ],
556  'Default date' => [
557  '0000-00-00',
558  'date',
559  'date',
560  false,
561  null,
562  ],
563  'Default time' => [
564  '00:00:00',
565  'time',
566  'time',
567  false,
568  '00:00:00',
569  ],
570  'Null on nullable time' => [
571  null,
572  'time',
573  'time',
574  true,
575  null,
576  ],
577  'Null on not nullable time' => [
578  null,
579  'time',
580  'time',
581  false,
582  '00:00:00',
583  ],
584  'Minimum mysql datetime' => [
585  '1000-01-01 00:00:00',
586  'datetime',
587  'datetime',
588  false,
589  '1000-01-01 00:00:00',
590  ],
591  'Maximum mysql datetime' => [
592  '9999-12-31 23:59:59',
593  'datetime',
594  'datetime',
595  false,
596  '9999-12-31 23:59:59',
597  ],
598  ];
599  }
600 
610  public function ‪inputValueCheckNativeDbType(string|null $value, string $dbType, string $format, bool $nullable, $expectedOutput): void
611  {
612  $tcaFieldConf = [
613  'input' => [],
614  'dbType' => $dbType,
615  'format' => $dbType,
616  'nullable' => $nullable,
617  ];
618 
619  $returnValue = $this->subject->_call('checkValueForDatetime', $value, $tcaFieldConf);
620 
621  self::assertEquals($expectedOutput, $returnValue['value']);
622  }
623 
625  // Tests concerning checkModifyAccessList
627  //
633  {
634  $this->expectException(\UnexpectedValueException::class);
635  $this->expectExceptionCode(1251892472);
636 
637  ‪$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['checkModifyAccessList'][] = InvalidHookFixture::class;
638  $this->subject->checkModifyAccessList('tt_content');
639  }
640 
647  {
648  $hookClass = ‪StringUtility::getUniqueId('tx_coretest');
649  $hookMock = $this->getMockBuilder(DataHandlerCheckModifyAccessListHookInterface::class)
650  ->onlyMethods(['checkModifyAccessList'])
651  ->setMockClassName($hookClass)
652  ->getMock();
653  $hookMock->expects(self::once())->method('checkModifyAccessList');
654  ‪$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['checkModifyAccessList'][] = $hookClass;
655  GeneralUtility::addInstance($hookClass, $hookMock);
656  $this->subject->checkModifyAccessList('tt_content');
657  }
658 
665  {
666  ‪$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['checkModifyAccessList'][] = AllowAccessHookFixture::class;
667  self::assertTrue($this->subject->checkModifyAccessList('tt_content'));
668  }
669 
671  // Tests concerning process_datamap
673 
677  {
678  ‪$subject = $this->getMockBuilder(DataHandler::class)
679  ->onlyMethods(['log'])
680  ->getMock();
681  $this->backendUserMock->workspace = 1;
682  $this->backendUserMock->workspaceRec = ['freeze' => true];
684  self::assertFalse(‪$subject->‪process_datamap());
685  }
686 
687  public static function ‪checkValue_flex_procInData_travDSDataProvider(): iterable
688  {
689  yield 'Flat structure' => [
690  'dataValues' => [
691  'field1' => [
692  'vDEF' => 'wrong input',
693  ],
694  ],
695  'DSelements' => [
696  'field1' => [
697  'label' => 'A field',
698  'config' => [
699  'type' => 'number',
700  'required' => true,
701  ],
702  ],
703  ],
704  'expected' => [
705  'field1' => [
706  'vDEF' => 0,
707  ],
708  ],
709  ];
710 
711  yield 'Array structure' => [
712  'dataValues' => [
713  'section' => [
714  'el' => [
715  '1' => [
716  'container1' => [
717  'el' => [
718  'field1' => [
719  'vDEF' => 'wrong input',
720  ],
721  ],
722  ],
723  ],
724  ],
725  ],
726  ],
727  'DSelements' => [
728  'section' => [
729  'type' => 'array',
730  'section' => true,
731  'el' => [
732  'container1' => [
733  'type' => 'array',
734  'el' => [
735  'field1' => [
736  'label' => 'A field',
737  'config' => [
738  'type' => 'number',
739  'required' => true,
740  ],
741  ],
742  ],
743  ],
744  ],
745  ],
746  ],
747  'expected' => [
748  'section' => [
749  'el' => [
750  '1' => [
751  'container1' => [
752  'el' => [
753  'field1' => [
754  'vDEF' => 0,
755  ],
756  ],
757  ],
758  ],
759  ],
760  ],
761  ],
762  ];
763  }
764 
772  public function ‪checkValue_flex_procInData_travDS(array $dataValues, array $DSelements, array $expected): void
773  {
774  $pParams = [
775  'tt_content',
776  777,
777  '<?xml ... ?>',
778  'update',
779  1,
780  'tt_content:777:pi_flexform',
781  0,
782  ];
783 
784  ‪$GLOBALS['LANG'] = $this->createMock(LanguageService::class);
785  $this->subject->checkValue_flex_procInData_travDS($dataValues, [], $DSelements, $pParams, '', '');
786  self::assertSame($expected, $dataValues);
787  }
788 
790  // Tests concerning log
792 
796  {
797  $backendUser = $this->createMock(BackendUserAuthentication::class);
798  $backendUser->expects(self::once())->method('writelog');
799  $this->subject->enableLogging = true;
800  $this->subject->BE_USER = $backendUser;
801  $this->subject->log('', 23, SysLog\‪Action::UNDEFINED, 42, SysLog\‪Error::MESSAGE, 'details');
802  }
803 
808  {
809  $backendUser = $this->createMock(BackendUserAuthentication::class);
810  $backendUser->expects(self::never())->method('writelog');
811  $this->subject->enableLogging = false;
812  $this->subject->BE_USER = $backendUser;
813  $this->subject->log('', 23, SysLog\‪Action::UNDEFINED, 42, SysLog\‪Error::MESSAGE, 'details');
814  }
815 
819  public function ‪logAddsEntryToLocalErrorLogArray(): void
820  {
821  $backendUser = $this->createMock(BackendUserAuthentication::class);
822  $this->subject->BE_USER = $backendUser;
823  $this->subject->enableLogging = true;
824  $this->subject->errorLog = [];
825  $logDetailsUnique = ‪StringUtility::getUniqueId('details');
826  $this->subject->log('', 23, SysLog\‪Action::UNDEFINED, 42, SysLog\‪Error::USER_ERROR, $logDetailsUnique);
827  self::assertArrayHasKey(0, $this->subject->errorLog);
828  self::assertStringEndsWith($logDetailsUnique, $this->subject->errorLog[0]);
829  }
830 
835  {
836  $backendUser = $this->createMock(BackendUserAuthentication::class);
837  $this->subject->BE_USER = $backendUser;
838  $this->subject->enableLogging = true;
839  $this->subject->errorLog = [];
840  $logDetails = ‪StringUtility::getUniqueId('details');
841  $this->subject->log('', 23, SysLog\‪Action::UNDEFINED, 42, SysLog\‪Error::USER_ERROR, '%1$s' . $logDetails . '%2$s', -1, ['foo', 'bar']);
842  $expected = 'foo' . $logDetails . 'bar';
843  self::assertStringEndsWith($expected, $this->subject->errorLog[0]);
844  }
845 
850  {
851  $backendUser = $this->createMock(BackendUserAuthentication::class);
852  $this->subject->BE_USER = $backendUser;
853  $this->subject->enableLogging = true;
854  $this->subject->errorLog = [];
855  $logDetails = 'An error occurred on {table}:{uid} when localizing';
856  $this->subject->log('', 23, SysLog\‪Action::UNDEFINED, 42, SysLog\‪Error::USER_ERROR, $logDetails, -1, ['table' => 'tx_sometable', 0 => 'some random value']);
857  // UID is kept as non-replaced, and other properties are not replaced.
858  $expected = 'An error occurred on tx_sometable:{uid} when localizing';
859  self::assertStringEndsWith($expected, $this->subject->errorLog[0]);
860  }
861 
866  public function ‪equalSubmittedAndStoredValuesAreDetermined(bool $expected, string|int|null $submittedValue, string|int|null $storedValue, string $storedType, bool $allowNull): void
867  {
868  $result = \Closure::bind(function () use ($submittedValue, $storedValue, $storedType, $allowNull) {
869  return $this->isSubmittedValueEqualToStoredValue($submittedValue, $storedValue, $storedType, $allowNull);
870  }, ‪$this->subject, DataHandler::class)();
871  self::assertEquals($expected, $result);
872  }
873 
875  {
876  return [
877  // String
878  'string value "" vs. ""' => [
879  true,
880  '', '', 'string', false,
881  ],
882  'string value 0 vs. "0"' => [
883  true,
884  0, '0', 'string', false,
885  ],
886  'string value 1 vs. "1"' => [
887  true,
888  1, '1', 'string', false,
889  ],
890  'string value "0" vs. ""' => [
891  false,
892  '0', '', 'string', false,
893  ],
894  'string value 0 vs. ""' => [
895  false,
896  0, '', 'string', false,
897  ],
898  'string value null vs. ""' => [
899  true,
900  null, '', 'string', false,
901  ],
902  // Integer
903  'integer value 0 vs. 0' => [
904  true,
905  0, 0, 'int', false,
906  ],
907  'integer value "0" vs. "0"' => [
908  true,
909  '0', '0', 'int', false,
910  ],
911  'integer value 0 vs. "0"' => [
912  true,
913  0, '0', 'int', false,
914  ],
915  'integer value "" vs. "0"' => [
916  true,
917  '', '0', 'int', false,
918  ],
919  'integer value "" vs. 0' => [
920  true,
921  '', 0, 'int', false,
922  ],
923  'integer value "0" vs. 0' => [
924  true,
925  '0', 0, 'int', false,
926  ],
927  'integer value 1 vs. 1' => [
928  true,
929  1, 1, 'int', false,
930  ],
931  'integer value 1 vs. "1"' => [
932  true,
933  1, '1', 'int', false,
934  ],
935  'integer value "1" vs. "1"' => [
936  true,
937  '1', '1', 'int', false,
938  ],
939  'integer value "1" vs. 1' => [
940  true,
941  '1', 1, 'int', false,
942  ],
943  'integer value "0" vs. "1"' => [
944  false,
945  '0', '1', 'int', false,
946  ],
947  // String with allowed NULL values
948  'string with allowed null value "" vs. ""' => [
949  true,
950  '', '', 'string', true,
951  ],
952  'string with allowed null value 0 vs. "0"' => [
953  true,
954  0, '0', 'string', true,
955  ],
956  'string with allowed null value 1 vs. "1"' => [
957  true,
958  1, '1', 'string', true,
959  ],
960  'string with allowed null value "0" vs. ""' => [
961  false,
962  '0', '', 'string', true,
963  ],
964  'string with allowed null value 0 vs. ""' => [
965  false,
966  0, '', 'string', true,
967  ],
968  'string with allowed null value null vs. ""' => [
969  false,
970  null, '', 'string', true,
971  ],
972  'string with allowed null value "" vs. null' => [
973  false,
974  '', null, 'string', true,
975  ],
976  'string with allowed null value null vs. null' => [
977  true,
978  null, null, 'string', true,
979  ],
980  // Integer with allowed NULL values
981  'integer with allowed null value 0 vs. 0' => [
982  true,
983  0, 0, 'int', true,
984  ],
985  'integer with allowed null value "0" vs. "0"' => [
986  true,
987  '0', '0', 'int', true,
988  ],
989  'integer with allowed null value 0 vs. "0"' => [
990  true,
991  0, '0', 'int', true,
992  ],
993  'integer with allowed null value "" vs. "0"' => [
994  true,
995  '', '0', 'int', true,
996  ],
997  'integer with allowed null value "" vs. 0' => [
998  true,
999  '', 0, 'int', true,
1000  ],
1001  'integer with allowed null value "0" vs. 0' => [
1002  true,
1003  '0', 0, 'int', true,
1004  ],
1005  'integer with allowed null value 1 vs. 1' => [
1006  true,
1007  1, 1, 'int', true,
1008  ],
1009  'integer with allowed null value "1" vs. "1"' => [
1010  true,
1011  '1', '1', 'int', true,
1012  ],
1013  'integer with allowed null value "1" vs. 1' => [
1014  true,
1015  '1', 1, 'int', true,
1016  ],
1017  'integer with allowed null value 1 vs. "1"' => [
1018  true,
1019  1, '1', 'int', true,
1020  ],
1021  'integer with allowed null value "0" vs. "1"' => [
1022  false,
1023  '0', '1', 'int', true,
1024  ],
1025  'integer with allowed null value null vs. ""' => [
1026  false,
1027  null, '', 'int', true,
1028  ],
1029  'integer with allowed null value "" vs. null' => [
1030  false,
1031  '', null, 'int', true,
1032  ],
1033  'integer with allowed null value null vs. null' => [
1034  true,
1035  null, null, 'int', true,
1036  ],
1037  'integer with allowed null value null vs. "0"' => [
1038  false,
1039  null, '0', 'int', true,
1040  ],
1041  'integer with allowed null value null vs. 0' => [
1042  false,
1043  null, 0, 'int', true,
1044  ],
1045  'integer with allowed null value "0" vs. null' => [
1046  false,
1047  '0', null, 'int', true,
1048  ],
1049  ];
1050  }
1051 
1055  public function ‪deletePagesOnRootLevelIsDenied(): void
1056  {
1057  $dataHandlerMock = $this->getMockBuilder(DataHandler::class)
1058  ->onlyMethods(['canDeletePage', 'log'])
1059  ->getMock();
1060  $dataHandlerMock
1061  ->expects(self::never())
1062  ->method('canDeletePage');
1063  $dataHandlerMock
1064  ->expects(self::once())
1065  ->method('log')
1066  ->with('pages', 0, 3, 0, 2, 'Deleting all pages starting from the root-page is disabled', -1, [], 0);
1067 
1068  $dataHandlerMock->deletePages(0);
1069  }
1070 
1075  {
1076  $table = ‪StringUtility::getUniqueId('foo_');
1077  $conf = [
1078  'type' => 'inline',
1079  'foreign_table' => ‪StringUtility::getUniqueId('foreign_foo_'),
1080  'behaviour' => [
1081  'enableCascadingDelete' => 0,
1082  ],
1083  ];
1084 
1085  $mockRelationHandler = $this->createMock(RelationHandler::class);
1086  $mockRelationHandler->itemArray = [
1087  '1' => ['table' => ‪StringUtility::getUniqueId('bar_'), 'id' => 67],
1088  ];
1089 
1090  $mockDataHandler = $this->getAccessibleMock(DataHandler::class, ['getRelationFieldType', 'deleteAction', 'createRelationHandlerInstance'], [], '', false);
1091  $mockDataHandler->expects(self::once())->method('getRelationFieldType')->willReturn('field');
1092  $mockDataHandler->expects(self::once())->method('createRelationHandlerInstance')->willReturn($mockRelationHandler);
1093  $mockDataHandler->expects(self::never())->method('deleteAction');
1094  $mockDataHandler->deleteRecord_procBasedOnFieldType($table, 42, 'bar', $conf);
1095  }
1096 
1098  {
1099  return [
1100  'None item selected' => [
1101  0,
1102  0,
1103  ],
1104  'All items selected' => [
1105  7,
1106  7,
1107  ],
1108  'Item 1 and 2 are selected' => [
1109  3,
1110  3,
1111  ],
1112  'Value is higher than allowed (all checkboxes checked)' => [
1113  15,
1114  7,
1115  ],
1116  'Value is higher than allowed (some checkboxes checked)' => [
1117  11,
1118  3,
1119  ],
1120  'Negative value' => [
1121  -5,
1122  0,
1123  ],
1124  ];
1125  }
1126 
1131  public function ‪checkValue_checkReturnsExpectedValues(string|int $value, string|int $expectedValue): void
1132  {
1133  $expectedResult = [
1134  'value' => $expectedValue,
1135  ];
1136  $result = [];
1137  $tcaFieldConfiguration = [
1138  'items' => [
1139  ['Item 1', 0],
1140  ['Item 2', 0],
1141  ['Item 3', 0],
1142  ],
1143  ];
1144  self::assertSame($expectedResult, $this->subject->_call('checkValueForCheck', $result, $value, $tcaFieldConfiguration, '', 0, 0, ''));
1145  }
1146 
1151  {
1152  $expectedResult = ['value' => ''];
1153  self::assertSame($expectedResult, $this->subject->_call('checkValueForInput', null, ['type' => 'input', 'max' => 40], 'tt_content', 'NEW55c0e67f8f4d32.04974534', 89, 'table_caption'));
1154  }
1155 
1156  public static function ‪checkValueForJsonDataProvider(): \Generator
1157  {
1158  yield 'Converts empty string to array' => [
1159  '',
1160  ['value' => []],
1161  ];
1162  yield 'Handles invalid JSON' => [
1163  '_-invalid-_',
1164  [],
1165  ];
1166  yield 'Decodes JSON' => [
1167  '{"foo":"bar"}',
1168  ['value' => ['foo' => 'bar']],
1169  ];
1170  yield 'Array is not decoded' => [
1171  ['foo' => 'bar'],
1172  ['value' => ['foo' => 'bar']],
1173  ];
1174  }
1175 
1180  public function ‪checkValueForJson(string|array $input, array $expected): void
1181  {
1182  self::assertSame(
1183  $expected,
1184  $this->subject->_call(
1185  'checkValueForJson',
1186  $input,
1187  ['type' => 'json']
1188  )
1189  );
1190  }
1191 
1196  {
1197  self::assertEquals(
1198  'b3190536-1431-453e-afbb-25b8c5022513',
1199  Uuid::isValid($this->subject->_call('checkValueForUuid', 'b3190536-1431-453e-afbb-25b8c5022513', [])['value'])
1200  );
1201  }
1202 
1207  {
1208  self::assertTrue(Uuid::isValid($this->subject->_call('checkValueForUuid', '', [])['value']));
1209  self::assertTrue(Uuid::isValid($this->subject->_call('checkValueForUuid', '-_invalid_-', [])['value']));
1210  }
1211 
1216  {
1217  self::assertEmpty($this->subject->_call('checkValueForUuid', '', ['required' => false]));
1218  self::assertEmpty($this->subject->_call('checkValueForUuid', '-_invalid_-', ['required' => false]));
1219  }
1220 
1225  {
1226  self::assertEquals(6, (int)$this->subject->_call('checkValueForUuid', '', ['version' => 6])['value'][14]);
1227  self::assertEquals(7, (int)$this->subject->_call('checkValueForUuid', '', ['version' => 7])['value'][14]);
1228  self::assertEquals(4, (int)$this->subject->_call('checkValueForUuid', '', ['version' => 4])['value'][14]);
1229  // Defaults to 4
1230  self::assertEquals(4, (int)$this->subject->_call('checkValueForUuid', '', ['version' => 123456678])['value'][14]);
1231  // Defaults to 4
1232  self::assertEquals(4, (int)$this->subject->_call('checkValueForUuid', '', [])['value'][14]);
1233  }
1234 
1239  public function ‪referenceValuesAreCasted(string $value, array $configuration, bool $isNew, int|string $expected): void
1240  {
1241  self::assertEquals(
1242  $expected,
1243  $this->subject->_call('castReferenceValue', $value, $configuration, $isNew)
1244  );
1245  }
1246 
1247  public static function ‪referenceValuesAreCastedDataProvider(): array
1248  {
1249  return [
1250  'all empty' => [
1251  '', [], true, '',
1252  ],
1253  'cast zero with MM table' => [
1254  '', ['MM' => 'table'], true, 0,
1255  ],
1256  'cast zero with MM table with default value' => [
1257  '', ['MM' => 'table', 'default' => 13], true, 0,
1258  ],
1259  'cast zero with foreign field' => [
1260  '', ['foreign_field' => 'table', 'default' => 13], true, 0,
1261  ],
1262  'cast zero with foreign field with default value' => [
1263  '', ['foreign_field' => 'table'], true, 0,
1264  ],
1265  'pass zero' => [
1266  '0', [], true, '0',
1267  ],
1268  'pass value' => [
1269  '1', ['default' => 13], true, '1',
1270  ],
1271  'use default value' => [
1272  '', ['default' => 13], true, 13,
1273  ],
1274  ];
1275  }
1276 
1278  {
1279  return [
1280  'normal case' => ['Test (copy 42)', 'Test'],
1281  // all cases below look fishy and indicate bugs
1282  'with double spaces before' => ['Test (copy 42)', 'Test '],
1283  'with three spaces before' => ['Test (copy 42)', 'Test '],
1284  'with space after' => ['Test (copy 42) ', 'Test (copy 42) '],
1285  'with double spaces after' => ['Test (copy 42) ', 'Test (copy 42) '],
1286  'with three spaces after' => ['Test (copy 42) ', 'Test (copy 42) '],
1287  'with double tab before' => ['Test' . "\t" . '(copy 42)', 'Test'],
1288  'with double tab after' => ['Test (copy 42)' . "\t", 'Test (copy 42)' . "\t"],
1289  ];
1290  }
1291 
1296  public function ‪clearPrefixFromValueRemovesPrefix(string $input, string $expected): void
1297  {
1298  $languageServiceMock = $this->createMock(LanguageService::class);
1299  $languageServiceMock->method('sL')->with('testLabel')->willReturn('(copy %s)');
1300  ‪$GLOBALS['LANG'] = $languageServiceMock;
1301  ‪$GLOBALS['TCA']['testTable']['ctrl']['prependAtCopy'] = 'testLabel';
1302  self::assertEquals($expected, (new ‪DataHandler())->clearPrefixFromValue('testTable', $input));
1303  }
1304 
1305  public static function ‪applyFiltersToValuesFiltersValuesDataProvider(): iterable
1306  {
1307  yield 'values are filtered by provided user function' => [
1308  'tcaFieldConfiguration' => [
1309  'filter' => [
1310  [
1311  'userFunc' => UserOddNumberFilter::class . '->filter',
1312  ],
1313  ],
1314  ],
1315  'values' => [1, 2, 3, 4, 5],
1316  'expected' => [1, 3, 5],
1317  ];
1318 
1319  yield 'parameters are passed to the user function' => [
1320  'tcaFieldConfiguration' => [
1321  'filter' => [
1322  [
1323  'userFunc' => UserOddNumberFilter::class . '->filter',
1324  'parameters' => [
1325  'exclude' => 1,
1326  ],
1327  ],
1328  ],
1329  ],
1330  'values' => [1, 2, 3, 4, 5],
1331  'expected' => [3, 5],
1332  ];
1333 
1334  yield 'no filters return value as is' => [
1335  'tcaFieldConfiguration' => [],
1336  'values' => [1, 2, 3, 4, 5],
1337  'expected' => [1, 2, 3, 4, 5],
1338  ];
1339  }
1340 
1345  public function ‪applyFiltersToValuesFiltersValues(array $tcaFieldConfiguration, array $values, array $expected): void
1346  {
1347  self::assertEqualsCanonicalizing($expected, $this->subject->_call('applyFiltersToValues', $tcaFieldConfiguration, $values));
1348  }
1349 
1353  public function ‪applyFiltersToValuesExpectsArray(): void
1354  {
1355  $tcaFieldConfiguration = [
1356  'filter' => [
1357  [
1358  'userFunc' => UserOddNumberFilter::class . '->filter',
1359  'parameters' => [
1360  'break' => true,
1361  ],
1362  ],
1363  ],
1364  ];
1365 
1366  $values = [1, 2, 3, 4, 5];
1367  $this->expectException(\RuntimeException::class);
1368  $this->expectExceptionCode(1336051942);
1369  $this->expectExceptionMessage('Expected userFunc filter "TYPO3\CMS\Core\Tests\Unit\DataHandling\Fixtures\UserOddNumberFilter->filter" to return an array. Got NULL.');
1370  $this->subject->_call('applyFiltersToValues', $tcaFieldConfiguration, $values);
1371  }
1372 
1374  {
1375  yield 'no required flag set with empty string' => [
1376  [],
1377  '',
1378  true,
1379  ];
1380 
1381  yield 'no required flag set with (string)0' => [
1382  [],
1383  '0',
1384  true,
1385  ];
1386 
1387  yield 'required flag set with empty string' => [
1388  ['required' => true],
1389  '',
1390  false,
1391  ];
1392 
1393  yield 'required flag set with null value' => [
1394  ['required' => true],
1395  null,
1396  false,
1397  ];
1398 
1399  yield 'required flag set with (string)0' => [
1400  ['required' => true],
1401  '0',
1402  true,
1403  ];
1404 
1405  yield 'required flag set with non-empty string' => [
1406  ['required' => true],
1407  'foobar',
1408  true,
1409  ];
1410  }
1411 
1416  public function ‪validateValueForRequiredReturnsExpectedValue(array $tcaFieldConfig, $input, bool $expectation): void
1417  {
1418  self::assertSame($expectation, $this->subject->_call('validateValueForRequired', $tcaFieldConfig, $input));
1419  }
1420 }
‪TYPO3\CMS\Core\DataHandling\DataHandler
Definition: DataHandler.php:95
‪TYPO3\CMS\Core\Tests\Unit\DataHandling\DataHandlerTest\numberValueCheckRecognizesDecimalStringValuesAsFloatValuesCorrectlyDataProvider
‪static numberValueCheckRecognizesDecimalStringValuesAsFloatValuesCorrectlyDataProvider()
Definition: DataHandlerTest.php:269
‪TYPO3\CMS\Core\Tests\Unit\DataHandling\DataHandlerTest\logFormatsDetailMessageWithAdditionalDataInLocalErrorArray
‪logFormatsDetailMessageWithAdditionalDataInLocalErrorArray()
Definition: DataHandlerTest.php:834
‪TYPO3\CMS\Core\SysLog\Action\UNDEFINED
‪const UNDEFINED
Definition: Action.php:25
‪TYPO3\CMS\Core\Tests\Unit\DataHandling\DataHandlerTest\clearPrefixFromValueRemovesPrefixDataProvider
‪static clearPrefixFromValueRemovesPrefixDataProvider()
Definition: DataHandlerTest.php:1277
‪TYPO3\CMS\Core\Tests\Unit\DataHandling\DataHandlerTest\doesCheckModifyAccessListHookGetsCalled
‪doesCheckModifyAccessListHookGetsCalled()
Definition: DataHandlerTest.php:646
‪TYPO3\CMS\Core\Tests\Unit\DataHandling\DataHandlerTest\nonAdminWithTableModifyAccessIsAllowedToModifyNonAdminTable
‪nonAdminWithTableModifyAccessIsAllowedToModifyNonAdminTable()
Definition: DataHandlerTest.php:91
‪TYPO3\CMS\Core\Tests\Unit\DataHandling\DataHandlerTest\checkValueForJsonDataProvider
‪static checkValueForJsonDataProvider()
Definition: DataHandlerTest.php:1156
‪TYPO3\CMS\Core\Tests\Unit\DataHandling\DataHandlerTest\numberValueCheckRecognizesStringValuesAsIntegerValuesCorrectlyDataProvider
‪static numberValueCheckRecognizesStringValuesAsIntegerValuesCorrectlyDataProvider()
Definition: DataHandlerTest.php:222
‪TYPO3\CMS\Core\Tests\Unit\DataHandling\DataHandlerTest\checkValueForColorDataProvider
‪static checkValueForColorDataProvider()
Definition: DataHandlerTest.php:164
‪TYPO3\CMS\Core\Tests\Unit\DataHandling\DataHandlerTest\processDatamapForFrozenNonZeroWorkspaceReturnsFalse
‪processDatamapForFrozenNonZeroWorkspaceReturnsFalse()
Definition: DataHandlerTest.php:676
‪TYPO3\CMS\Core\Database\RelationHandler
Definition: RelationHandler.php:36
‪TYPO3\CMS\Core\Tests\Unit\DataHandling\DataHandlerTest\checkValue_checkReturnsExpectedValues
‪checkValue_checkReturnsExpectedValues(string|int $value, string|int $expectedValue)
Definition: DataHandlerTest.php:1131
‪TYPO3\CMS\Core\Tests\Unit\DataHandling\DataHandlerTest\inputValueCheckRespectsRightLowerAndUpperLimitWithDefaultValueForDouble
‪inputValueCheckRespectsRightLowerAndUpperLimitWithDefaultValueForDouble(string $value, string|int $expectedReturnValue)
Definition: DataHandlerTest.php:376
‪TYPO3\CMS\Core\Tests\Unit\DataHandling\DataHandlerTest\inputValuesRangeDoubleDataProvider
‪static inputValuesRangeDoubleDataProvider()
Definition: DataHandlerTest.php:324
‪TYPO3\CMS\Core\Tests\Unit\DataHandling\Fixtures\UserOddNumberFilter
Definition: UserOddNumberFilter.php:23
‪TYPO3\CMS\Core\Tests\Unit\DataHandling\DataHandlerTest\doesCheckModifyAccessListThrowExceptionOnWrongHookInterface
‪doesCheckModifyAccessListThrowExceptionOnWrongHookInterface()
Definition: DataHandlerTest.php:632
‪TYPO3\CMS\Core\Tests\Unit\DataHandling\DataHandlerTest\nonAdminWithTableModifyAccessIsNotAllowedToModifyAdminTable
‪nonAdminWithTableModifyAccessIsNotAllowedToModifyAdminTable()
Definition: DataHandlerTest.php:119
‪TYPO3\CMS\Core\Tests\Unit\DataHandling\DataHandlerTest\inputValueRangeCheckIsIgnoredWhenDefaultIsZeroAndInputValueIsEmptyDataProvider
‪static inputValueRangeCheckIsIgnoredWhenDefaultIsZeroAndInputValueIsEmptyDataProvider()
Definition: DataHandlerTest.php:440
‪TYPO3\CMS\Core\Tests\Unit\DataHandling\DataHandlerTest\logDoesNotCallWriteLogOfBackendUserIfLoggingIsDisabled
‪logDoesNotCallWriteLogOfBackendUserIfLoggingIsDisabled()
Definition: DataHandlerTest.php:807
‪TYPO3\CMS\Core\Tests\Unit\DataHandling\DataHandlerTest\datetimeValueCheckDbtypeIsIndependentFromTimezone
‪datetimeValueCheckDbtypeIsIndependentFromTimezone(string $value, string $dbtype, string $expectedOutput)
Definition: DataHandlerTest.php:521
‪TYPO3\CMS\Core\Tests\Unit\DataHandling\DataHandlerTest\numberValueCheckRecognizesStringValuesAsIntegerValuesCorrectly
‪numberValueCheckRecognizesStringValuesAsIntegerValuesCorrectly(string $value, int $expectedReturnValue)
Definition: DataHandlerTest.php:256
‪TYPO3\CMS\Core\Tests\Unit\DataHandling\DataHandlerTest\datetimeValuesDataProvider
‪static datetimeValuesDataProvider()
Definition: DataHandlerTest.php:391
‪TYPO3\CMS\Core\Cache\Frontend\NullFrontend
Definition: NullFrontend.php:30
‪TYPO3\CMS\Core\Tests\Unit\DataHandling\DataHandlerTest\checkValue_flex_procInData_travDS
‪checkValue_flex_procInData_travDS(array $dataValues, array $DSelements, array $expected)
Definition: DataHandlerTest.php:772
‪TYPO3\CMS\Core\Tests\Unit\DataHandling\DataHandlerTest\checkValueForInputConvertsNullToEmptyString
‪checkValueForInputConvertsNullToEmptyString()
Definition: DataHandlerTest.php:1150
‪TYPO3\CMS\Core\Tests\Unit\DataHandling\Fixtures\AllowAccessHookFixture
Definition: AllowAccessHookFixture.php:27
‪TYPO3\CMS\Core\Tests\Unit\DataHandling\DataHandlerTest\doesCheckModifyAccessListHookModifyAccessAllowed
‪doesCheckModifyAccessListHookModifyAccessAllowed()
Definition: DataHandlerTest.php:664
‪TYPO3\CMS\Core\Tests\Unit\DataHandling\DataHandlerTest\fixtureCanBeCreated
‪fixtureCanBeCreated()
Definition: DataHandlerTest.php:62
‪TYPO3\CMS\Core\Tests\Unit\DataHandling\DataHandlerTest\adminIsAllowedToModifyAdminTable
‪adminIsAllowedToModifyAdminTable()
Definition: DataHandlerTest.php:101
‪TYPO3\CMS\Core\Tests\Unit\DataHandling\DataHandlerTest\applyFiltersToValuesFiltersValues
‪applyFiltersToValuesFiltersValues(array $tcaFieldConfiguration, array $values, array $expected)
Definition: DataHandlerTest.php:1345
‪TYPO3\CMS\Core\Tests\Unit\DataHandling\DataHandlerTest\validateValueForRequiredReturnsExpectedValueDataHandler
‪static validateValueForRequiredReturnsExpectedValueDataHandler()
Definition: DataHandlerTest.php:1373
‪TYPO3\CMS\Core\Tests\Unit\DataHandling\DataHandlerTest\checkValueForUuidReturnsValidUuidUnmodified
‪checkValueForUuidReturnsValidUuidUnmodified()
Definition: DataHandlerTest.php:1195
‪TYPO3\CMS\Core\Tests\Unit\DataHandling\DataHandlerTest\checkValue_checkReturnsExpectedValuesDataProvider
‪static checkValue_checkReturnsExpectedValuesDataProvider()
Definition: DataHandlerTest.php:1097
‪TYPO3\CMS\Core\Tests\Unit\DataHandling\DataHandlerTest\checkValueForUuidDiscardsInvalidUuidIfFieldIsNotRequired
‪checkValueForUuidDiscardsInvalidUuidIfFieldIsNotRequired()
Definition: DataHandlerTest.php:1215
‪TYPO3\CMS\Core\Tests\Unit\DataHandling\DataHandlerTest\logFormatsDetailMessageWithPlaceholders
‪logFormatsDetailMessageWithPlaceholders()
Definition: DataHandlerTest.php:849
‪TYPO3\CMS\Core\Tests\Unit\DataHandling\DataHandlerTest\inputValueRangeCheckIsIgnoredWhenDefaultIsZeroAndInputValueIsEmpty
‪inputValueRangeCheckIsIgnoredWhenDefaultIsZeroAndInputValueIsEmpty(string|int $inputValue, int $expected,)
Definition: DataHandlerTest.php:462
‪TYPO3\CMS\Core\Tests\Unit\DataHandling\DataHandlerTest\applyFiltersToValuesExpectsArray
‪applyFiltersToValuesExpectsArray()
Definition: DataHandlerTest.php:1353
‪TYPO3\CMS\Core\Tests\Unit\DataHandling\DataHandlerTest\checkValueForUuidCreatesValidUuidValueForReqiredFieldsWithInvalidUuidGiven
‪checkValueForUuidCreatesValidUuidValueForReqiredFieldsWithInvalidUuidGiven()
Definition: DataHandlerTest.php:1206
‪TYPO3\CMS\Core\Tests\Unit\DataHandling\DataHandlerTest\clearPrefixFromValueRemovesPrefix
‪clearPrefixFromValueRemovesPrefix(string $input, string $expected)
Definition: DataHandlerTest.php:1296
‪TYPO3\CMS\Core\Tests\Unit\DataHandling\DataHandlerTest\nonAdminIsNorAllowedToModifyNonAdminTable
‪nonAdminIsNorAllowedToModifyNonAdminTable()
Definition: DataHandlerTest.php:82
‪TYPO3\CMS\Core\Tests\Unit\DataHandling\DataHandlerTest\applyFiltersToValuesFiltersValuesDataProvider
‪static applyFiltersToValuesFiltersValuesDataProvider()
Definition: DataHandlerTest.php:1305
‪TYPO3\CMS\Core\DataHandling\DataHandler\BE_USER
‪array< string, $autoVersionIdMap=array();public array $substNEWwithIDs=array();public array $substNEWwithIDs_table=array();public array $newRelatedIDs=array();public array $copyMappingArray_merged=array();protected array $deletedRecords=array();public array $errorLog=array();public array $pagetreeRefreshFieldsFromPages=array('pid', 'sorting', 'deleted', 'hidden', 'title', 'doktype', 'is_siteroot', 'fe_group', 'nav_hide', 'nav_title', 'module', 'starttime', 'endtime', 'content_from_pid', 'extendToSubpages');public bool $pagetreeNeedsRefresh=false;public BackendUserAuthentication $BE_USER;public int $userid;public bool $admin;protected PagePermissionAssembler $pagePermissionAssembler;protected array $excludedTablesAndFields=array();protected array $control=array();public array< int|string, $datamap=array();public array< string, $cmdmap=array();protected array $mmHistoryRecords=array();protected array $historyRecords=array();public int $sortIntervals=256;protected array $recInsertAccessCache=array();protected array $isRecordInWebMount_Cache=array();protected array $isInWebMount_Cache=array();protected array< int, $pageCache=array();public array $dbAnalysisStore=array();public array< string, $registerDBList=array();public array $registerDBPids=array();public array< string, $copyMappingArray=array();public array $remapStack=array();public array $remapStackRecords=array();protected array $remapStackChildIds=array();protected array $remapStackActions=array();protected ReferenceIndexUpdater $referenceIndexUpdater;public array $checkValue_currentRecord=array();protected bool $disableDeleteClause=false;protected array|null $checkModifyAccessListHookObjects;protected \TYPO3\CMS\Core\DataHandling\DataHandler|null $outerMostInstance;protected static array $recordsToClearCacheFor=array();protected static array $recordPidsForDeletedRecords=array();protected FrontendInterface $runtimeCache;protected string $cachePrefixNestedElementCalls='core-datahandler-nestedElementCalls-';public function __construct(ReferenceIndexUpdater $referenceIndexUpdater=null) { $this->runtimeCache=$this->getRuntimeCache();$this->pagePermissionAssembler=GeneralUtility::makeInstance(PagePermissionAssembler::class, $GLOBALS[ 'TYPO3_CONF_VARS'][ 'BE'][ 'defaultPermissions']);if( $referenceIndexUpdater===null) { $referenceIndexUpdater=GeneralUtility::makeInstance(ReferenceIndexUpdater::class);} $this->referenceIndexUpdater=$referenceIndexUpdater;} public function setControl(array $control) { $this->control=$control;} public function start( $data, $cmd, $altUserObject=null) { $this-> BE_USER
Definition: DataHandler.php:562
‪TYPO3\CMS\Core\Tests\Unit\DataHandling\DataHandlerTest\inputValueCheckNativeDbType
‪inputValueCheckNativeDbType(string|null $value, string $dbType, string $format, bool $nullable, $expectedOutput)
Definition: DataHandlerTest.php:610
‪TYPO3\CMS\Core\Tests\Unit\DataHandling\DataHandlerTest\logCallsWriteLogOfBackendUserIfLoggingIsEnabled
‪logCallsWriteLogOfBackendUserIfLoggingIsEnabled()
Definition: DataHandlerTest.php:795
‪TYPO3\CMS\Core\Tests\Unit\DataHandling\DataHandlerTest\inputValueCheckNativeDbTypeDataProvider
‪static inputValueCheckNativeDbTypeDataProvider()
Definition: DataHandlerTest.php:539
‪TYPO3\CMS\Core\SysLog
‪TYPO3\CMS\Core\SysLog\Error\USER_ERROR
‪const USER_ERROR
Definition: Error.php:26
‪TYPO3\CMS\Core\Cache\CacheManager
Definition: CacheManager.php:36
‪TYPO3\CMS\Core\Tests\Unit\DataHandling\DataHandlerTest\checkValueForDatetimeDataProvider
‪static checkValueForDatetimeDataProvider()
Definition: DataHandlerTest.php:134
‪TYPO3\CMS\Core\Tests\Unit\DataHandling\Fixtures\InvalidHookFixture
Definition: InvalidHookFixture.php:23
‪TYPO3\CMS\Core\Tests\Unit\DataHandling\DataHandlerTest\$resetSingletonInstances
‪bool $resetSingletonInstances
Definition: DataHandlerTest.php:43
‪TYPO3\CMS\Core\Authentication\BackendUserAuthentication
Definition: BackendUserAuthentication.php:60
‪TYPO3\CMS\Core\Tests\Unit\DataHandling\DataHandlerTest\adminIsAllowedToModifyNonAdminTable
‪adminIsAllowedToModifyNonAdminTable()
Definition: DataHandlerTest.php:73
‪TYPO3\CMS\Core\Tests\Unit\DataHandling
Definition: DataHandlerTest.php:18
‪TYPO3\CMS\Core\Tests\Unit\DataHandling\DataHandlerTest\validateValueForRequiredReturnsExpectedValue
‪validateValueForRequiredReturnsExpectedValue(array $tcaFieldConfig, $input, bool $expectation)
Definition: DataHandlerTest.php:1416
‪TYPO3\CMS\Core\Tests\Unit\DataHandling\DataHandlerTest\datetimeValueCheckDbtypeIsIndependentFromTimezoneDataProvider
‪static datetimeValueCheckDbtypeIsIndependentFromTimezoneDataProvider()
Definition: DataHandlerTest.php:478
‪TYPO3\CMS\Core\Tests\Unit\DataHandling\DataHandlerTest\setUp
‪setUp()
Definition: DataHandlerTest.php:47
‪TYPO3\CMS\Core\Tests\Unit\DataHandling\DataHandlerTest\checkValueForUuidCreatesValidUuidValueWithDefinedVersion
‪checkValueForUuidCreatesValidUuidValueWithDefinedVersion()
Definition: DataHandlerTest.php:1224
‪$output
‪$output
Definition: annotationChecker.php:119
‪TYPO3\CMS\Core\Tests\Unit\DataHandling\DataHandlerTest\equalSubmittedAndStoredValuesAreDeterminedDataProvider
‪static equalSubmittedAndStoredValuesAreDeterminedDataProvider()
Definition: DataHandlerTest.php:874
‪TYPO3\CMS\Core\Tests\Unit\DataHandling\DataHandlerTest\inputValueCheckRespectsRightLowerAndUpperLimitForDouble
‪inputValueCheckRespectsRightLowerAndUpperLimitForDouble(string $value, string|int $expectedReturnValue)
Definition: DataHandlerTest.php:358
‪TYPO3\CMS\Core\Tests\Unit\DataHandling\DataHandlerTest\checkValueForJson
‪checkValueForJson(string|array $input, array $expected)
Definition: DataHandlerTest.php:1180
‪TYPO3\CMS\Core\Tests\Unit\DataHandling\DataHandlerTest\checkValueForDatetime
‪checkValueForDatetime($input, $serverTimezone, $expectedOutput)
Definition: DataHandlerTest.php:151
‪TYPO3\CMS\Core\Tests\Unit\DataHandling\DataHandlerTest\checkValueForColor
‪checkValueForColor(string $input, mixed $expected, array $additionalFieldConfig=[])
Definition: DataHandlerTest.php:184
‪TYPO3\CMS\Core\Tests\Unit\DataHandling\DataHandlerTest\equalSubmittedAndStoredValuesAreDetermined
‪equalSubmittedAndStoredValuesAreDetermined(bool $expected, string|int|null $submittedValue, string|int|null $storedValue, string $storedType, bool $allowNull)
Definition: DataHandlerTest.php:866
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:25
‪TYPO3\CMS\Core\PasswordPolicy\Event\EnrichPasswordValidationContextDataEvent
Definition: EnrichPasswordValidationContextDataEvent.php:30
‪TYPO3\CMS\Core\Tests\Unit\DataHandling\DataHandlerTest\referenceValuesAreCasted
‪referenceValuesAreCasted(string $value, array $configuration, bool $isNew, int|string $expected)
Definition: DataHandlerTest.php:1239
‪TYPO3\CMS\Core\Tests\Unit\DataHandling\DataHandlerTest\valueCheckRecognizesDatetimeValuesAsIntegerValuesCorrectly
‪valueCheckRecognizesDatetimeValuesAsIntegerValuesCorrectly(string $value, int $expected)
Definition: DataHandlerTest.php:417
‪TYPO3\CMS\Core\Localization\LanguageService
Definition: LanguageService.php:46
‪TYPO3\CMS\Core\Tests\Unit\DataHandling\DataHandlerTest\$backendUserMock
‪BackendUserAuthentication &MockObject $backendUserMock
Definition: DataHandlerTest.php:45
‪TYPO3\CMS\Core\SysLog\Error\MESSAGE
‪const MESSAGE
Definition: Error.php:25
‪TYPO3\CMS\Core\DataHandling\DataHandlerCheckModifyAccessListHookInterface
Definition: DataHandlerCheckModifyAccessListHookInterface.php:22
‪TYPO3\CMS\Core\Tests\Unit\DataHandling\DataHandlerTest\checkValuePasswordWithSaltedPasswordReturnsHashForSaltedPassword
‪checkValuePasswordWithSaltedPasswordReturnsHashForSaltedPassword()
Definition: DataHandlerTest.php:209
‪TYPO3\CMS\Core\DataHandling\DataHandler\process_datamap
‪bool void process_datamap()
Definition: DataHandler.php:747
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:51
‪TYPO3\CMS\Core\Tests\Unit\DataHandling\DataHandlerTest\logAddsEntryToLocalErrorLogArray
‪logAddsEntryToLocalErrorLogArray()
Definition: DataHandlerTest.php:819
‪TYPO3\CMS\Core\Utility\StringUtility
Definition: StringUtility.php:24
‪TYPO3\CMS\Core\Tests\Unit\DataHandling\DataHandlerTest\nonAdminIsNotAllowedToModifyAdminTable
‪nonAdminIsNotAllowedToModifyAdminTable()
Definition: DataHandlerTest.php:110
‪TYPO3\CMS\Core\Tests\Unit\DataHandling\DataHandlerTest\checkValuePasswordWithSaltedPasswordKeepsExistingHash
‪checkValuePasswordWithSaltedPasswordKeepsExistingHash()
Definition: DataHandlerTest.php:198
‪TYPO3\CMS\Core\Utility\StringUtility\getUniqueId
‪static getUniqueId(string $prefix='')
Definition: StringUtility.php:57
‪TYPO3\CMS\Core\Tests\Unit\DataHandling\DataHandlerTest
Definition: DataHandlerTest.php:42
‪TYPO3\CMS\Core\Tests\Unit\DataHandling\DataHandlerTest\deleteRecord_procBasedOnFieldTypeRespectsEnableCascadingDelete
‪deleteRecord_procBasedOnFieldTypeRespectsEnableCascadingDelete()
Definition: DataHandlerTest.php:1074
‪TYPO3\CMS\Core\Tests\Unit\DataHandling\DataHandlerTest\checkValue_flex_procInData_travDSDataProvider
‪static checkValue_flex_procInData_travDSDataProvider()
Definition: DataHandlerTest.php:687
‪TYPO3\CMS\Core\Tests\Unit\DataHandling\DataHandlerTest\deletePagesOnRootLevelIsDenied
‪deletePagesOnRootLevelIsDenied()
Definition: DataHandlerTest.php:1055
‪TYPO3\CMS\Core\Tests\Unit\DataHandling\DataHandlerTest\$subject
‪DataHandler &MockObject &AccessibleObjectInterface $subject
Definition: DataHandlerTest.php:44
‪TYPO3\CMS\Core\PasswordPolicy\Validator\Dto\ContextData
Definition: ContextData.php:28
‪TYPO3\CMS\Core\Tests\Unit\DataHandling\DataHandlerTest\numberValueCheckRecognizesDecimalStringValuesAsFloatValuesCorrectly
‪numberValueCheckRecognizesDecimalStringValuesAsFloatValuesCorrectly(string $value, string $expectedReturnValue)
Definition: DataHandlerTest.php:311
‪TYPO3\CMS\Core\Tests\Unit\DataHandling\DataHandlerTest\referenceValuesAreCastedDataProvider
‪static referenceValuesAreCastedDataProvider()
Definition: DataHandlerTest.php:1247