‪TYPO3CMS  ‪main
DatabaseRecordOverrideValuesTest.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\Test;
22 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
23 
24 final class ‪DatabaseRecordOverrideValuesTest extends UnitTestCase
25 {
27 
28  protected function ‪setUp(): void
29  {
30  parent::setUp();
31  $this->subject = new ‪DatabaseRecordOverrideValues();
32  }
33 
34  #[Test]
36  {
37  $input = [
38  'tableName' => 'aTable',
39  'processedTca' => [
40  'columns' => [
41  'aField' => [
42  'config' => [
43  'type' => 'input',
44  ],
45  ],
46  ],
47  ],
48  'databaseRow' => [
49  'uid' => 42,
50  ],
51  'overrideValues' => [
52  'anotherField' => 13,
53  ],
54  ];
55 
56  self::assertSame($input, $this->subject->addData($input));
57  }
58 
59  #[Test]
60  public function ‪addDataSetsDatabaseRowAndTcaType(): void
61  {
62  $input = [
63  'tableName' => 'aTable',
64  'processedTca' => [
65  'columns' => [
66  'aField' => [
67  'config' => [
68  'type' => 'input',
69  ],
70  ],
71  'anotherField' => [
72  'config' => [
73  'type' => 'input',
74  ],
75  ],
76  ],
77  ],
78  'databaseRow' => [
79  'uid' => 42,
80  ],
81  'overrideValues' => [
82  'aField' => 256,
83  'anotherField' => 13,
84  ],
85  ];
86 
87  $expected = $input;
88  $expected['databaseRow']['aField'] = 256;
89  $expected['databaseRow']['anotherField'] = 13;
90  $expected['processedTca']['columns']['aField']['config'] = [
91  'type' => 'hidden',
92  'renderType' => 'hidden',
93  ];
94  $expected['processedTca']['columns']['anotherField']['config'] = [
95  'type' => 'hidden',
96  'renderType' => 'hidden',
97  ];
98 
99  self::assertSame($expected, $this->subject->addData($input));
100  }
101 }
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\DatabaseRecordOverrideValuesTest\addDataSetsDatabaseRowAndTcaType
‪addDataSetsDatabaseRowAndTcaType()
Definition: DatabaseRecordOverrideValuesTest.php:60
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\DatabaseRecordOverrideValuesTest\setUp
‪setUp()
Definition: DatabaseRecordOverrideValuesTest.php:28
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\DatabaseRecordOverrideValuesTest\addDataReturnSameDataIfNoOverrideValuesSet
‪addDataReturnSameDataIfNoOverrideValuesSet()
Definition: DatabaseRecordOverrideValuesTest.php:35
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\DatabaseRecordOverrideValuesTest\$subject
‪DatabaseRecordOverrideValues $subject
Definition: DatabaseRecordOverrideValuesTest.php:26
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider
Definition: DatabaseDefaultLanguagePageRowTest.php:18
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\DatabaseRecordOverrideValuesTest
Definition: DatabaseRecordOverrideValuesTest.php:25
‪TYPO3\CMS\Backend\Form\FormDataProvider\DatabaseRecordOverrideValues
Definition: DatabaseRecordOverrideValues.php:24