‪TYPO3CMS  ‪main
AbstractActionWorkspacesTestCase.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 {
22  protected const ‪VALUE_WorkspaceId = 1;
23 
24  protected const ‪SCENARIO_DataSet = __DIR__ . '/DataSet/ImportDefaultWorkspaces.csv';
25 
26  protected array ‪$coreExtensionsToLoad = ['workspaces'];
27 
28  public function ‪localizeLiveModifyWsDefaultLang(): void
29  {
30  // Localize page and tt_content in live, so we have a localized parent tt_content plus it's children in live.
31  $this->‪setWorkspaceId(0);
32  $this->actionService->copyRecordToLanguage(self::TABLE_Page, self::VALUE_PageId, self::VALUE_LanguageId);
33  $this->actionService->localizeRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_LanguageId);
34  // Change the default language element in workspaces, which will create overlays and inline children for localized element, too.
35  $this->‪setWorkspaceId(static::VALUE_WorkspaceId);
36  $this->actionService->modifyRecord(self::TABLE_Content, self::VALUE_ContentIdLast, ['header' => 'Testing #1']);
37  }
38 
39  public function ‪localizeLiveModifyWsLocalization(): void
40  {
41  // Localize page and tt_content in live, so we have a localized parent tt_content plus it's children in live.
42  $this->‪setWorkspaceId(0);
43  $this->actionService->copyRecordToLanguage(self::TABLE_Page, self::VALUE_PageId, self::VALUE_LanguageId);
44  ‪$recordIds = $this->actionService->localizeRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_LanguageId);
45  $this->recordIds['localizedLiveContentId'] = ‪$recordIds['tt_content'][‪self::VALUE_ContentIdLast];
46  // Change the localized element in workspaces.
47  $this->‪setWorkspaceId(static::VALUE_WorkspaceId);
48  $this->actionService->modifyRecord(self::TABLE_Content, $this->recordIds['localizedLiveContentId'], ['header' => 'Testing #1']);
49  }
50 
52  {
53  // Localize page and tt_content in live, so we have a localized parent tt_content plus it's children in live.
54  $this->‪setWorkspaceId(0);
55  $this->actionService->copyRecordToLanguage(self::TABLE_Page, self::VALUE_PageId, self::VALUE_LanguageId);
56  ‪$recordIds = $this->actionService->localizeRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_LanguageId);
57  $this->recordIds['localizedLiveContentId'] = ‪$recordIds['tt_content'][‪self::VALUE_ContentIdLast];
58  // Change the localized element in workspaces.
59  $this->‪setWorkspaceId(static::VALUE_WorkspaceId);
60  $this->actionService->modifyRecord(self::TABLE_Content, $this->recordIds['localizedLiveContentId'], ['header' => 'Testing #1']);
61  // In addition to localizeLiveModifyWsLocalization(), add another image to Live default language record.
62  $this->‪setWorkspaceId(0);
63  // @todo: It would be better to not re-use sys_file 1 here, but to have a third image in the import pool that can be attached here.
64  $this->actionService->modifyRecords(
65  self::VALUE_PageId,
66  [
67  self::TABLE_Content => ['uid' => self::VALUE_ContentIdLast, self::FIELD_ContentImage => self::VALUE_FileReferenceContentLastFileLast . ',' . self::VALUE_FileReferenceContentLastFileFirst . ',__nextUid'],
68  self::TABLE_FileReference => ['uid' => '__NEW', 'title' => 'Image #3', self::FIELD_FileReferenceImage => self::VALUE_FileIdFirst],
69  ]
70  );
71  $this->‪setWorkspaceId(static::VALUE_WorkspaceId);
72  }
73 
75  {
76  // Localize page and tt_content in live, so we have a localized parent tt_content plus it's children in live.
77  $this->‪setWorkspaceId(0);
78  $this->actionService->copyRecordToLanguage(self::TABLE_Page, self::VALUE_PageId, self::VALUE_LanguageId);
79  ‪$recordIds = $this->actionService->localizeRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_LanguageId);
80  $this->recordIds['localizedLiveContentId'] = ‪$recordIds['tt_content'][‪self::VALUE_ContentIdLast];
81  // Change the localized element in workspaces.
82  $this->‪setWorkspaceId(static::VALUE_WorkspaceId);
83  $this->actionService->modifyRecord(self::TABLE_Content, $this->recordIds['localizedLiveContentId'], ['header' => 'Testing #1']);
84  // In addition to localizeLiveModifyWsLocalization(), add another image to Live default language record.
85  $this->‪setWorkspaceId(0);
86  // @todo: It would be better to not re-use sys_file 1 here, but to have a third image in the import pool that can be attached here.
87  $this->actionService->modifyRecords(
88  self::VALUE_PageId,
89  [
90  self::TABLE_Content => ['uid' => self::VALUE_ContentIdLast, self::FIELD_ContentImage => self::VALUE_FileReferenceContentLastFileLast . ',' . self::VALUE_FileReferenceContentLastFileFirst . ',__nextUid'],
91  self::TABLE_FileReference => ['uid' => '__NEW', 'title' => 'Image #3', self::FIELD_FileReferenceImage => self::VALUE_FileIdFirst],
92  ]
93  );
94  // In addition to localizeLiveModifyWsLocalizationAddLive(), "synchronize" the new live default language image to the localized content element in workspaces.
95  $this->‪setWorkspaceId(static::VALUE_WorkspaceId);
96  $this->actionService->invoke(
97  [],
98  [
99  'tt_content' => [
100  $this->recordIds['localizedLiveContentId'] => [
101  'inlineLocalizeSynchronize' => [
102  'field' => 'image',
103  'language' => 1,
104  'ids' => [
105  // Hardcoded source uid here since above modifyRecords() does not return the uid of the new attached image.
106  134,
107  ],
108  ],
109  ],
110  ],
111  ]
112  );
113  }
114 
115  public function ‪modifyContentLocalize(): void
116  {
117  // Localize page so we can localize content elements later.
118  $this->‪setWorkspaceId(0);
119  $this->actionService->copyRecordToLanguage(self::TABLE_Page, self::VALUE_PageId, self::VALUE_LanguageId);
120  // Modify the content element in workspaces to create a workspace overlay of this one, including overlays of attached images
121  $this->‪setWorkspaceId(static::VALUE_WorkspaceId);
122  $this->actionService->modifyRecord(self::TABLE_Content, self::VALUE_ContentIdLast, ['header' => 'Testing #1']);
123  // Now localize that default language content element in workspace
124  // Note we're using the live uid as source here, which is what page module translation wizard and list module submit to DH as well
125  ‪$recordIds = $this->actionService->localizeRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_LanguageId);
126  $this->recordIds['localizedWsContentId'] = ‪$recordIds['tt_content'][‪self::VALUE_ContentIdLast];
127  }
128 
130  {
131  // Localize page so we can localize content elements later.
132  $this->‪setWorkspaceId(0);
133  $this->actionService->copyRecordToLanguage(self::TABLE_Page, self::VALUE_PageId, self::VALUE_LanguageId);
134  // Modify the content element in workspaces to create a workspace overlay of this one, including overlays of attached images
135  $this->‪setWorkspaceId(static::VALUE_WorkspaceId);
136  $this->actionService->modifyRecord(self::TABLE_Content, self::VALUE_ContentIdLast, ['header' => 'Testing #1']);
137  // Now localize that default language content element in workspace
138  // Note we're using the live uid as source here, which is what page module translation wizard and list module submit to DH as well
139  ‪$recordIds = $this->actionService->localizeRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_LanguageId);
140  $this->recordIds['localizedWsContentId'] = ‪$recordIds['tt_content'][‪self::VALUE_ContentIdLast];
141  // In addition to modifyContentLocalize(), add an image to the default language content element in workspaces.
142  // @todo: It would be better to not re-use sys_file 1 here, but to have a third image in the import pool that can be attached here.
143  $this->actionService->modifyRecords(
144  self::VALUE_PageId,
145  [
146  self::TABLE_Content => ['uid' => self::VALUE_ContentIdLast, self::FIELD_ContentImage => self::VALUE_FileReferenceContentLastFileLast . ',' . self::VALUE_FileReferenceContentLastFileFirst . ',__nextUid'],
147  self::TABLE_FileReference => ['uid' => '__NEW', 'title' => 'Image #3', self::FIELD_FileReferenceImage => self::VALUE_FileIdFirst],
148  ]
149  );
150  }
151 
153  {
154  // Localize page so we can localize content elements later.
155  $this->‪setWorkspaceId(0);
156  $this->actionService->copyRecordToLanguage(self::TABLE_Page, self::VALUE_PageId, self::VALUE_LanguageId);
157  // Modify the content element in workspaces to create a workspace overlay of this one, including overlays of attached images
158  $this->‪setWorkspaceId(static::VALUE_WorkspaceId);
159  $this->actionService->modifyRecord(self::TABLE_Content, self::VALUE_ContentIdLast, ['header' => 'Testing #1']);
160  // Now localize that default language content element in workspace
161  // Note we're using the live uid as source here, which is what page module translation wizard and list module submit to DH as well
162  ‪$recordIds = $this->actionService->localizeRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_LanguageId);
163  $this->recordIds['localizedWsContentId'] = ‪$recordIds['tt_content'][‪self::VALUE_ContentIdLast];
164  // In addition to modifyContentLocalize(), add an image to the default language content element in workspaces.
165  // @todo: It would be better to not re-use sys_file 1 here, but to have a third image in the import pool that can be attached here.
166  $this->actionService->modifyRecords(
167  self::VALUE_PageId,
168  [
169  self::TABLE_Content => ['uid' => self::VALUE_ContentIdLast, self::FIELD_ContentImage => self::VALUE_FileReferenceContentLastFileLast . ',' . self::VALUE_FileReferenceContentLastFileFirst . ',__nextUid'],
170  self::TABLE_FileReference => ['uid' => '__NEW', 'title' => 'Image #3', self::FIELD_FileReferenceImage => self::VALUE_FileIdFirst],
171  ]
172  );
173  // In addition to modifyContentLocalizeAddDefaultLangRelation(), "synchronize" the new default language image to the localized content element in workspaces.
174  $this->actionService->invoke(
175  [],
176  [
177  'tt_content' => [
178  $this->recordIds['localizedWsContentId'] => [
179  'inlineLocalizeSynchronize' => [
180  'field' => 'image',
181  'language' => 1,
182  'ids' => [
183  // Hardcoded source uid here since above modifyRecords() does not return the uid of the new attached image.
184  134,
185  ],
186  ],
187  ],
188  ],
189  ]
190  );
191  }
192 }
‪TYPO3\CMS\Core\Tests\Functional\DataScenarios\FAL\AbstractActionWorkspacesTestCase\localizeLiveModifyWsLocalizationAddLive
‪localizeLiveModifyWsLocalizationAddLive()
Definition: AbstractActionWorkspacesTestCase.php:51
‪TYPO3\CMS\Core\Tests\Functional\DataScenarios\FAL\AbstractActionWorkspacesTestCase\$coreExtensionsToLoad
‪array $coreExtensionsToLoad
Definition: AbstractActionWorkspacesTestCase.php:26
‪TYPO3\CMS\Core\Tests\Functional\DataScenarios\FAL\AbstractActionWorkspacesTestCase\localizeLiveModifyWsLocalizationAddLiveWsSync
‪localizeLiveModifyWsLocalizationAddLiveWsSync()
Definition: AbstractActionWorkspacesTestCase.php:74
‪TYPO3\CMS\Core\Tests\Functional\DataScenarios\AbstractDataHandlerActionTestCase\$recordIds
‪array $recordIds
Definition: AbstractDataHandlerActionTestCase.php:44
‪TYPO3\CMS\Core\Tests\Functional\DataScenarios\FAL\AbstractActionWorkspacesTestCase
Definition: AbstractActionWorkspacesTestCase.php:21
‪TYPO3\CMS\Core\Tests\Functional\DataScenarios\FAL\AbstractActionWorkspacesTestCase\modifyContentLocalizeAddDefaultLangRelation
‪modifyContentLocalizeAddDefaultLangRelation()
Definition: AbstractActionWorkspacesTestCase.php:129
‪TYPO3\CMS\Core\Tests\Functional\DataScenarios\FAL\AbstractActionTestCase\VALUE_ContentIdLast
‪const VALUE_ContentIdLast
Definition: AbstractActionTestCase.php:30
‪TYPO3\CMS\Core\Tests\Functional\DataScenarios\FAL\AbstractActionWorkspacesTestCase\localizeLiveModifyWsDefaultLang
‪localizeLiveModifyWsDefaultLang()
Definition: AbstractActionWorkspacesTestCase.php:28
‪TYPO3\CMS\Core\Tests\Functional\DataScenarios\AbstractDataHandlerActionTestCase\setWorkspaceId
‪setWorkspaceId(int $workspaceId)
Definition: AbstractDataHandlerActionTestCase.php:76
‪TYPO3\CMS\Core\Tests\Functional\DataScenarios\FAL\AbstractActionTestCase
Definition: AbstractActionTestCase.php:24
‪TYPO3\CMS\Core\Tests\Functional\DataScenarios\FAL\AbstractActionWorkspacesTestCase\localizeLiveModifyWsLocalization
‪localizeLiveModifyWsLocalization()
Definition: AbstractActionWorkspacesTestCase.php:39
‪TYPO3\CMS\Core\Tests\Functional\DataScenarios\FAL
Definition: AbstractActionTestCase.php:18
‪TYPO3\CMS\Core\Tests\Functional\DataScenarios\FAL\AbstractActionWorkspacesTestCase\modifyContentLocalize
‪modifyContentLocalize()
Definition: AbstractActionWorkspacesTestCase.php:115
‪TYPO3\CMS\Core\Tests\Functional\DataScenarios\FAL\AbstractActionWorkspacesTestCase\VALUE_WorkspaceId
‪const VALUE_WorkspaceId
Definition: AbstractActionWorkspacesTestCase.php:22
‪TYPO3\CMS\Core\Tests\Functional\DataScenarios\FAL\AbstractActionWorkspacesTestCase\SCENARIO_DataSet
‪const SCENARIO_DataSet
Definition: AbstractActionWorkspacesTestCase.php:24
‪TYPO3\CMS\Core\Tests\Functional\DataScenarios\FAL\AbstractActionWorkspacesTestCase\modifyContentLocalizeAddDefaultLangRelationSynchronize
‪modifyContentLocalizeAddDefaultLangRelationSynchronize()
Definition: AbstractActionWorkspacesTestCase.php:152