‪TYPO3CMS  11.5
AbstractActionTestCase.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 
21 
26 {
27  protected const ‪VALUE_PageId = 89;
28  protected const ‪VALUE_PageIdTarget = 90;
29  protected const ‪VALUE_ContentIdFirst = 297;
30  protected const ‪VALUE_ContentIdLast = 298;
31  protected const ‪VALUE_LanguageId = 1;
32  protected const ‪VALUE_LanguageIdSecond = 2;
33  protected const ‪VALUE_ElementIdFirst = 1;
34  protected const ‪VALUE_ElementIdSecond = 2;
35  protected const ‪VALUE_ElementIdThird = 3;
36 
37  protected const ‪TABLE_Content = 'tt_content';
38  protected const ‪TABLE_Element = 'tx_testdatahandler_element';
39 
40  protected const ‪FIELD_ContentElement = 'tx_testdatahandler_group';
41 
42  protected const ‪SCENARIO_DataSet = __DIR__ . '/DataSet/ImportDefault.csv';
43 
45  'typo3/sysext/core/Tests/Functional/Fixtures/Extensions/irre_tutorial',
46  'typo3/sysext/core/Tests/Functional/Fixtures/Extensions/test_datahandler',
47  ];
48 
49  protected function ‪setUp(): void
50  {
51  parent::setUp();
52  $this->importCSVDataSet(static::SCENARIO_DataSet);
53 
54  $this->‪setUpFrontendSite(1, $this->siteLanguageConfiguration);
55  $this->setUpFrontendRootPage(1, ['typo3/sysext/core/Tests/Functional/Fixtures/Frontend/JsonRenderer.typoscript']);
56  }
57 
58  public function ‪addElementRelation(): void
59  {
60  $this->actionService->modifyReferences(
61  self::TABLE_Content,
62  self::VALUE_ContentIdFirst,
63  self::FIELD_ContentElement,
64  [self::VALUE_ElementIdFirst, self::VALUE_ElementIdSecond, self::VALUE_ElementIdThird]
65  );
66  }
67 
68  public function ‪deleteElementRelation(): void
69  {
70  $this->actionService->modifyReferences(
71  self::TABLE_Content,
72  self::VALUE_ContentIdFirst,
73  self::FIELD_ContentElement,
74  [self::VALUE_ElementIdFirst]
75  );
76  }
77 
78  public function ‪changeElementSorting(): void
79  {
80  $this->actionService->moveRecord(self::TABLE_Element, self::VALUE_ElementIdFirst, -self::VALUE_ElementIdSecond);
81  }
82 
83  public function ‪changeElementRelationSorting(): void
84  {
85  $this->actionService->modifyReferences(
86  self::TABLE_Content,
87  self::VALUE_ContentIdFirst,
88  self::FIELD_ContentElement,
89  [self::VALUE_ElementIdSecond, self::VALUE_ElementIdFirst]
90  );
91  }
92 
93  public function ‪createContentAndAddElementRelation(): void
94  {
95  $newTableIds = $this->actionService->createNewRecord(
96  self::TABLE_Content,
97  self::VALUE_PageId,
98  ['header' => 'Testing #1', self::FIELD_ContentElement => self::VALUE_ElementIdFirst]
99  );
100  $this->recordIds['newContentId'] = $newTableIds[‪self::TABLE_Content][0];
101  }
102 
104  {
105  $newElementIds = $this->actionService->createNewRecord(self::TABLE_Element, self::VALUE_PageId, ['title' => 'Testing #1']);
106  $this->recordIds['newElementId'] = $newElementIds[‪self::TABLE_Element][0];
107  // It's not possible to use "NEW..." values for the TCA type 'group'
108  $newContentIds = $this->actionService->createNewRecord(self::TABLE_Content, self::VALUE_PageId, ['header' => 'Testing #1', self::FIELD_ContentElement => $this->recordIds['newElementId']]);
109  $this->recordIds['newContentId'] = $newContentIds[‪self::TABLE_Content][0];
110  }
111 
112  public function ‪modifyElementOfRelation(): void
113  {
114  $this->actionService->modifyRecord(self::TABLE_Element, self::VALUE_ElementIdFirst, ['title' => 'Testing #1']);
115  }
116 
117  public function ‪modifyContentOfRelation(): void
118  {
119  $this->actionService->modifyRecord(self::TABLE_Content, self::VALUE_ContentIdFirst, ['header' => 'Testing #1']);
120  }
121 
122  public function ‪modifyBothSidesOfRelation(): void
123  {
124  $this->actionService->modifyRecord(self::TABLE_Element, self::VALUE_ElementIdFirst, ['title' => 'Testing #1']);
125  $this->actionService->modifyRecord(self::TABLE_Content, self::VALUE_ContentIdFirst, ['header' => 'Testing #1']);
126  }
127 
128  public function ‪deleteContentOfRelation(): void
129  {
130  $this->actionService->deleteRecord(self::TABLE_Content, self::VALUE_ContentIdLast);
131  }
132 
133  public function ‪deleteElementOfRelation(): void
134  {
135  $this->actionService->deleteRecord(self::TABLE_Element, self::VALUE_ElementIdFirst);
136  }
137 
138  public function ‪copyContentOfRelation(): void
139  {
140  $newTableIds = $this->actionService->copyRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_PageId);
141  $this->recordIds['copiedContentId'] = $newTableIds[‪self::TABLE_Content][‪self::VALUE_ContentIdLast];
142  }
143 
144  public function ‪copyElementOfRelation(): void
145  {
146  $newTableIds = $this->actionService->copyRecord(self::TABLE_Element, self::VALUE_ElementIdFirst, self::VALUE_PageId);
147  $this->recordIds['copiedElementId'] = $newTableIds[‪self::TABLE_Element][‪self::VALUE_ElementIdFirst];
148  }
149 
153  public function ‪copyContentToLanguageOfRelation(): void
154  {
155  $newTableIds = $this->actionService->copyRecordToLanguage(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_LanguageId);
156  $this->recordIds['localizedContentId'] = $newTableIds[‪self::TABLE_Content][‪self::VALUE_ContentIdLast];
157  }
158 
162  public function ‪copyElementToLanguageOfRelation(): void
163  {
164  $newTableIds = $this->actionService->copyRecordToLanguage(self::TABLE_Element, self::VALUE_ElementIdFirst, self::VALUE_LanguageId);
165  $this->recordIds['localizedElementId'] = $newTableIds[‪self::TABLE_Element][‪self::VALUE_ElementIdFirst];
166  }
167 
168  public function ‪localizeContentOfRelation(): void
169  {
170  $newTableIds = $this->actionService->localizeRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_LanguageId);
171  $this->recordIds['localizedContentId'] = $newTableIds[‪self::TABLE_Content][‪self::VALUE_ContentIdLast];
172  }
173 
175  {
176  ‪$GLOBALS['TCA']['tt_content']['columns'][‪self::FIELD_ContentElement]['config']['behaviour']['allowLanguageSynchronization'] = true;
177  $newTableIds = $this->actionService->localizeRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_LanguageId);
178  $this->recordIds['localizedContentId'] = $newTableIds[‪self::TABLE_Content][‪self::VALUE_ContentIdLast];
179  $this->actionService->modifyReferences(
180  self::TABLE_Content,
181  self::VALUE_ContentIdLast,
182  self::FIELD_ContentElement,
183  [self::VALUE_ElementIdSecond, self::VALUE_ElementIdThird]
184  );
185  }
186 
188  {
189  ‪$GLOBALS['TCA']['tt_content']['columns'][‪self::FIELD_ContentElement]['config']['behaviour']['allowLanguageSynchronization'] = true;
190  $newTableIds = $this->actionService->localizeRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_LanguageId);
191  $this->recordIds['localizedContentIdFirst'] = $newTableIds[‪self::TABLE_Content][‪self::VALUE_ContentIdLast];
192  $newTableIds = $this->actionService->localizeRecord(self::TABLE_Content, $this->recordIds['localizedContentIdFirst'], self::VALUE_LanguageIdSecond);
193  $this->recordIds['localizedContentIdSecond'] = $newTableIds[‪self::TABLE_Content][$this->recordIds['localizedContentIdFirst']];
194  $this->actionService->modifyRecord(
195  self::TABLE_Content,
196  $this->recordIds['localizedContentIdSecond'],
197  ['l10n_state' => [self::FIELD_ContentElement => 'source']]
198  );
199  $this->actionService->modifyReferences(
200  self::TABLE_Content,
201  self::VALUE_ContentIdLast,
202  self::FIELD_ContentElement,
203  [self::VALUE_ElementIdSecond, self::VALUE_ElementIdThird]
204  );
205  }
206 
208  {
209  ‪$GLOBALS['TCA']['tt_content']['columns'][‪self::FIELD_ContentElement]['config']['localizeReferencesAtParentLocalization'] = true;
210  $newTableIds = $this->actionService->localizeRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_LanguageId);
211  $this->recordIds['localizedContentId'] = $newTableIds[‪self::TABLE_Content][‪self::VALUE_ContentIdLast];
212  }
213 
214  public function ‪localizeElementOfRelation(): void
215  {
216  $newTableIds = $this->actionService->localizeRecord(self::TABLE_Element, self::VALUE_ElementIdFirst, self::VALUE_LanguageId);
217  $this->recordIds['localizedElementId'] = $newTableIds[‪self::TABLE_Element][‪self::VALUE_ElementIdFirst];
218  }
219 
221  {
222  $newTableIds = $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_PageIdTarget);
223  // In workspaces new records are created and discard drops this one again, live creates no new record
224  if (isset($newTableIds[self::TABLE_Content][self::VALUE_ContentIdLast])) {
225  $this->recordIds['movedContentId'] = $newTableIds[‪self::TABLE_Content][‪self::VALUE_ContentIdLast];
226  }
227  }
228 }
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Group\AbstractActionTestCase\copyElementToLanguageOfRelation
‪copyElementToLanguageOfRelation()
Definition: AbstractActionTestCase.php:162
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Group\AbstractActionTestCase\localizeContentChainOfRelationWithLanguageSynchronizationSource
‪localizeContentChainOfRelationWithLanguageSynchronizationSource()
Definition: AbstractActionTestCase.php:187
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Group\AbstractActionTestCase\FIELD_ContentElement
‪const FIELD_ContentElement
Definition: AbstractActionTestCase.php:40
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Group\AbstractActionTestCase\moveContentOfRelationToDifferentPage
‪moveContentOfRelationToDifferentPage()
Definition: AbstractActionTestCase.php:220
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Group\AbstractActionTestCase\TABLE_Content
‪const TABLE_Content
Definition: AbstractActionTestCase.php:37
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Group
Definition: AbstractActionTestCase.php:18
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\AbstractDataHandlerActionTestCase\setUpFrontendSite
‪setUpFrontendSite(int $pageId, array $additionalLanguages=[])
Definition: AbstractDataHandlerActionTestCase.php:127
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Group\AbstractActionTestCase\SCENARIO_DataSet
‪const SCENARIO_DataSet
Definition: AbstractActionTestCase.php:42
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Group\AbstractActionTestCase\modifyBothSidesOfRelation
‪modifyBothSidesOfRelation()
Definition: AbstractActionTestCase.php:122
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Group\AbstractActionTestCase\changeElementSorting
‪changeElementSorting()
Definition: AbstractActionTestCase.php:78
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Group\AbstractActionTestCase\localizeContentOfRelationWithLanguageSynchronization
‪localizeContentOfRelationWithLanguageSynchronization()
Definition: AbstractActionTestCase.php:174
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Group\AbstractActionTestCase\TABLE_Element
‪const TABLE_Element
Definition: AbstractActionTestCase.php:38
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Group\AbstractActionTestCase\VALUE_ContentIdLast
‪const VALUE_ContentIdLast
Definition: AbstractActionTestCase.php:30
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Group\AbstractActionTestCase\VALUE_LanguageId
‪const VALUE_LanguageId
Definition: AbstractActionTestCase.php:31
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Group\AbstractActionTestCase\deleteElementOfRelation
‪deleteElementOfRelation()
Definition: AbstractActionTestCase.php:133
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Group\AbstractActionTestCase\VALUE_PageId
‪const VALUE_PageId
Definition: AbstractActionTestCase.php:27
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Group\AbstractActionTestCase\VALUE_ElementIdSecond
‪const VALUE_ElementIdSecond
Definition: AbstractActionTestCase.php:34
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Group\AbstractActionTestCase\VALUE_ElementIdThird
‪const VALUE_ElementIdThird
Definition: AbstractActionTestCase.php:35
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Group\AbstractActionTestCase\copyContentToLanguageOfRelation
‪copyContentToLanguageOfRelation()
Definition: AbstractActionTestCase.php:153
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Group\AbstractActionTestCase\copyElementOfRelation
‪copyElementOfRelation()
Definition: AbstractActionTestCase.php:144
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Group\AbstractActionTestCase\addElementRelation
‪addElementRelation()
Definition: AbstractActionTestCase.php:58
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Group\AbstractActionTestCase\deleteElementRelation
‪deleteElementRelation()
Definition: AbstractActionTestCase.php:68
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\AbstractDataHandlerActionTestCase
Definition: AbstractDataHandlerActionTestCase.php:41
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Group\AbstractActionTestCase\createContentAndAddElementRelation
‪createContentAndAddElementRelation()
Definition: AbstractActionTestCase.php:93
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Group\AbstractActionTestCase\localizeContentOfRelationWithLocalizeReferencesAtParentLocalization
‪localizeContentOfRelationWithLocalizeReferencesAtParentLocalization()
Definition: AbstractActionTestCase.php:207
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Group\AbstractActionTestCase\VALUE_ElementIdFirst
‪const VALUE_ElementIdFirst
Definition: AbstractActionTestCase.php:33
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Group\AbstractActionTestCase\modifyContentOfRelation
‪modifyContentOfRelation()
Definition: AbstractActionTestCase.php:117
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Group\AbstractActionTestCase\VALUE_ContentIdFirst
‪const VALUE_ContentIdFirst
Definition: AbstractActionTestCase.php:29
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Group\AbstractActionTestCase\$testExtensionsToLoad
‪$testExtensionsToLoad
Definition: AbstractActionTestCase.php:44
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Group\AbstractActionTestCase\localizeContentOfRelation
‪localizeContentOfRelation()
Definition: AbstractActionTestCase.php:168
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Group\AbstractActionTestCase\deleteContentOfRelation
‪deleteContentOfRelation()
Definition: AbstractActionTestCase.php:128
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Group\AbstractActionTestCase\modifyElementOfRelation
‪modifyElementOfRelation()
Definition: AbstractActionTestCase.php:112
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Group\AbstractActionTestCase
Definition: AbstractActionTestCase.php:26
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Group\AbstractActionTestCase\setUp
‪setUp()
Definition: AbstractActionTestCase.php:49
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Group\AbstractActionTestCase\copyContentOfRelation
‪copyContentOfRelation()
Definition: AbstractActionTestCase.php:138
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Group\AbstractActionTestCase\createContentAndCreateElementRelation
‪createContentAndCreateElementRelation()
Definition: AbstractActionTestCase.php:103
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:25
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Group\AbstractActionTestCase\VALUE_PageIdTarget
‪const VALUE_PageIdTarget
Definition: AbstractActionTestCase.php:28
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Group\AbstractActionTestCase\changeElementRelationSorting
‪changeElementRelationSorting()
Definition: AbstractActionTestCase.php:83
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Group\AbstractActionTestCase\VALUE_LanguageIdSecond
‪const VALUE_LanguageIdSecond
Definition: AbstractActionTestCase.php:32
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Group\AbstractActionTestCase\localizeElementOfRelation
‪localizeElementOfRelation()
Definition: AbstractActionTestCase.php:214