[!!!][TASK] Extract testing framework for TYPO3
[Packages/TYPO3.CMS.git] / typo3 / sysext / backend / Tests / Unit / Form / FormDataProvider / TcaColumnsProcessRecordTitleTest.php
1 <?php
2 namespace TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider;
3
4 /*
5 * This file is part of the TYPO3 CMS project.
6 *
7 * It is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License, either version 2
9 * of the License, or any later version.
10 *
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
13 *
14 * The TYPO3 project - inspiring people to share!
15 */
16
17 use TYPO3\CMS\Backend\Form\FormDataProvider\TcaColumnsProcessRecordTitle;
18
19 /**
20 * Test case
21 */
22 class TcaColumnsProcessRecordTitleTest extends \TYPO3\CMS\Components\TestingFramework\Core\UnitTestCase
23 {
24 /**
25 * @var TcaColumnsProcessRecordTitle
26 */
27 protected $subject;
28
29 protected function setUp()
30 {
31 $this->subject = new TcaColumnsProcessRecordTitle();
32 }
33
34 /**
35 * @test
36 */
37 public function addDataRegistersLabelColumn()
38 {
39 $input = [
40 'columnsToProcess' => [],
41 'processedTca' => [
42 'ctrl' => [
43 'label' => 'uid'
44 ],
45 'columns' => [],
46 ]
47 ];
48
49 $expected = $input;
50 $expected['columnsToProcess'] = ['uid'];
51 $this->assertSame($expected, $this->subject->addData($input));
52 }
53
54 /**
55 * @test
56 */
57 public function addDataRegistersAlternativeLabelColumnn()
58 {
59 $input = [
60 'columnsToProcess' => [],
61 'processedTca' => [
62 'ctrl' => [
63 'label' => 'uid',
64 'label_alt' => 'aField,anotherField',
65 ],
66 'columns' => [],
67 ]
68 ];
69
70 $expected = $input;
71 $expected['columnsToProcess'] = ['uid', 'aField', 'anotherField'];
72 $this->assertSame($expected, $this->subject->addData($input));
73 }
74
75 /**
76 * @test
77 */
78 public function addDataRegistersForeignLabelInInlineContext()
79 {
80 $input = [
81 'columnsToProcess' => [],
82 'inlineParentConfig' => [
83 'foreign_label' => 'aForeignLabelField',
84 ],
85 'isInlineChild' => true,
86 ];
87
88 $expected = $input;
89 $expected['columnsToProcess'] = [ 'aForeignLabelField' ];
90 $this->assertSame($expected, $this->subject->addData($input));
91 }
92
93 /**
94 * @test
95 */
96 public function addDataRegistersSymmetricLabelInInlineContext()
97 {
98 $input = [
99 'columnsToProcess' => [],
100 'inlineParentConfig' => [
101 'symmetric_label' => 'aSymmetricLabelField',
102 ],
103 'isInlineChild' => true,
104 ];
105
106 $expected = $input;
107 $expected['columnsToProcess'] = [ 'aSymmetricLabelField' ];
108 $this->assertSame($expected, $this->subject->addData($input));
109 }
110 }