‪TYPO3CMS  9.5
DefaultValuesTest.php
Go to the documentation of this file.
1 <?php
2 declare(strict_types = 1);
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 
18 
22 
27 {
31  const ‪PAGE_DATAHANDLER = 88;
32 
36  protected ‪$scenarioDataSetDirectory = 'typo3/sysext/core/Tests/Functional/DataHandling/DataHandler/DataSet/';
37 
38  protected function ‪setUp(): void
39  {
40  parent::setUp();
41  $this->‪importScenarioDataSet('LiveDefaultPages');
42  $this->‪importScenarioDataSet('LiveDefaultElements');
43  $this->backendUser->workspace = 0;
44  }
45 
50  {
51  ‪$GLOBALS['TCA']['pages']['columns']['keywords']['config']['default'] = 'a few,random,keywords';
52  $map = $this->actionService->createNewRecord('pages', self::PAGE_DATAHANDLER, [
53  'title' => 'A new age'
54  ]);
55  $newPageId = reset($map['pages']);
56  $newPageRecord = ‪BackendUtility::getRecord('pages', $newPageId);
57  self::assertEquals($newPageRecord['keywords'], ‪$GLOBALS['TCA']['pages']['columns']['keywords']['config']['default']);
58 
59  ‪$GLOBALS['TCA']['tt_content']['columns']['header']['config']['default'] = 'Pre-set header';
60  $map = $this->actionService->createNewRecord('tt_content', $newPageId, [
61  'header' => '',
62  'bodytext' => 'Random bodytext'
63  ]);
64  $newContentId = reset($map['tt_content']);
65  $newContentRecord = ‪BackendUtility::getRecord('tt_content', $newContentId);
66  // Empty header is used, because it was handed in
67  self::assertEquals($newContentRecord['header'], '');
68 
69  $map = $this->actionService->createNewRecord('tt_content', $newPageId, [
70  'bodytext' => 'Random bodytext'
71  ]);
72  $newContentId = reset($map['tt_content']);
73  $newContentRecord = ‪BackendUtility::getRecord('tt_content', $newContentId);
74  self::assertEquals($newContentRecord['header'], ‪$GLOBALS['TCA']['tt_content']['columns']['header']['config']['default']);
75  }
76 
81  {
83 TCAdefaults.pages.keywords = from pagets, with love
84 TCAdefaults.tt_content.header = global space');
85  $map = $this->actionService->createNewRecord('pages', self::PAGE_DATAHANDLER, [
86  'title' => 'A new age'
87  ]);
88  $newPageId = reset($map['pages']);
89  $newPageRecord = ‪BackendUtility::getRecord('pages', $newPageId);
90  self::assertEquals($newPageRecord['keywords'], 'from pagets, with love');
91 
92  $map = $this->actionService->createNewRecord('tt_content', $newPageId, [
93  'header' => '',
94  'bodytext' => 'Random bodytext'
95  ]);
96  $newContentId = reset($map['tt_content']);
97  $newContentRecord = ‪BackendUtility::getRecord('tt_content', $newContentId);
98  // Empty header is used, because it was handed in
99  self::assertEquals($newContentRecord['header'], '');
100 
101  $map = $this->actionService->createNewRecord('tt_content', $newPageId, [
102  'bodytext' => 'Random bodytext'
103  ]);
104  $newContentId = reset($map['tt_content']);
105  $newContentRecord = ‪BackendUtility::getRecord('tt_content', $newContentId);
106  self::assertEquals($newContentRecord['header'], 'global space');
107  }
108 
113  {
115 TCAdefaults.pages.keywords = from pagets, with love
116 TCAdefaults.tt_content.header = global space');
117  $this->actionService->modifyRecord('pages', self::PAGE_DATAHANDLER, [
118  'TSconfig' => '
119 
120 TCAdefaults.pages.keywords = I am specific, not generic
121 TCAdefaults.tt_content.header = local space
122 
123 ']);
124  $map = $this->actionService->createNewRecord('pages', self::PAGE_DATAHANDLER, [
125  'title' => 'A new age'
126  ]);
127  $newPageId = reset($map['pages']);
128  $newPageRecord = ‪BackendUtility::getRecord('pages', $newPageId);
129  self::assertEquals($newPageRecord['keywords'], 'I am specific, not generic');
130 
131  $map = $this->actionService->createNewRecord('tt_content', $newPageId, [
132  'header' => '',
133  'bodytext' => 'Random bodytext'
134  ]);
135  $newContentId = reset($map['tt_content']);
136  $newContentRecord = ‪BackendUtility::getRecord('tt_content', $newContentId);
137  // Empty header is used, because it was handed in
138  self::assertEquals($newContentRecord['header'], '');
139 
140  $map = $this->actionService->createNewRecord('tt_content', $newPageId, [
141  'bodytext' => 'Random bodytext'
142  ]);
143  $newContentId = reset($map['tt_content']);
144  $newContentRecord = ‪BackendUtility::getRecord('tt_content', $newContentId);
145  self::assertEquals($newContentRecord['header'], 'local space');
146  }
147 }
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\DataHandler
Definition: DefaultValuesTest.php:17
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\DataHandler\DefaultValuesTest\defaultValuesFromTCAForNewRecordsIsRespected
‪defaultValuesFromTCAForNewRecordsIsRespected()
Definition: DefaultValuesTest.php:48
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\DataHandler\DefaultValuesTest\setUp
‪setUp()
Definition: DefaultValuesTest.php:37
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\DataHandler\DefaultValuesTest
Definition: DefaultValuesTest.php:27
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\DataHandler\DefaultValuesTest\defaultValuesFromPageSpecificTSconfigForNewRecordsIsRespected
‪defaultValuesFromPageSpecificTSconfigForNewRecordsIsRespected()
Definition: DefaultValuesTest.php:111
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\AbstractDataHandlerActionTestCase
Definition: AbstractDataHandlerActionTestCase.php:33
‪TYPO3\CMS\Core\Utility\ExtensionManagementUtility
Definition: ExtensionManagementUtility.php:36
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\DataHandler\DefaultValuesTest\$scenarioDataSetDirectory
‪string $scenarioDataSetDirectory
Definition: DefaultValuesTest.php:35
‪TYPO3\CMS\Backend\Utility\BackendUtility
Definition: BackendUtility.php:72
‪TYPO3\CMS\Backend\Utility\BackendUtility\getRecord
‪static array null getRecord($table, $uid, $fields=' *', $where='', $useDeleteClause=true)
Definition: BackendUtility.php:130
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\DataHandler\DefaultValuesTest\defaultValuesFromGlobalTSconfigForNewRecordsIsRespected
‪defaultValuesFromGlobalTSconfigForNewRecordsIsRespected()
Definition: DefaultValuesTest.php:79
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Core\Utility\ExtensionManagementUtility\addPageTSConfig
‪static addPageTSConfig($content)
Definition: ExtensionManagementUtility.php:978
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\DataHandler\DefaultValuesTest\PAGE_DATAHANDLER
‪const PAGE_DATAHANDLER
Definition: DefaultValuesTest.php:31
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\AbstractDataHandlerActionTestCase\importScenarioDataSet
‪importScenarioDataSet($dataSetName)
Definition: AbstractDataHandlerActionTestCase.php:117