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