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