‪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_CategoryIdFirst = 28;
34  protected const ‪VALUE_CategoryIdSecond = 29;
35  protected const ‪VALUE_CategoryIdThird = 30;
36  protected const ‪VALUE_CategoryIdFourth = 31;
37 
38  protected const ‪TABLE_Page = 'pages';
39  protected const ‪TABLE_Content = 'tt_content';
40  protected const ‪TABLE_Category = 'sys_category';
41  protected const ‪TABLE_ContentCategory_ManyToMany = 'sys_category_record_mm';
42 
43  protected const ‪FIELD_Categories = 'categories';
44 
45  protected const ‪SCENARIO_DataSet = __DIR__ . '/DataSet/ImportDefault.csv';
46 
47  protected function ‪setUp(): void
48  {
49  parent::setUp();
50  // Show copied pages records in frontend request
51  ‪$GLOBALS['TCA']['pages']['ctrl']['hideAtCopy'] = false;
52  // Show copied tt_content records in frontend request
53  ‪$GLOBALS['TCA']['tt_content']['ctrl']['hideAtCopy'] = false;
54  // Prepend label for localized sys_category records
55  ‪$GLOBALS['TCA']['sys_category']['columns']['title']['l10n_mode'] = 'prefixLangTitle';
56  // Prepend label for copied sys_category records
57  ‪$GLOBALS['TCA']['sys_category']['ctrl']['prependAtCopy'] = 'LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.prependAtCopy';
58  $this->importCSVDataSet(static::SCENARIO_DataSet);
60  'test',
61  $this->‪buildSiteConfiguration(1, '/'),
62  [
63  $this->‪buildDefaultLanguageConfiguration('EN', '/'),
64  $this->‪buildLanguageConfiguration('DA', '/da/', ['EN']),
65  $this->‪buildLanguageConfiguration('DE', '/de/', ['DA', 'EN']),
66  ]
67  );
68  $this->setUpFrontendRootPage(1, ['EXT:core/Tests/Functional/Fixtures/Frontend/JsonRenderer.typoscript']);
69  }
70 
71  public function ‪addCategoryRelation(): void
72  {
73  $this->actionService->modifyReferences(
74  self::TABLE_Content,
75  self::VALUE_ContentIdFirst,
76  'categories',
77  [self::VALUE_CategoryIdFirst, self::VALUE_CategoryIdSecond, 31]
78  );
79  }
80 
81  public function ‪createCategoryAndAddRelation(): void
82  {
83  $newTableIds = $this->actionService->createNewRecord(
84  self::TABLE_Category,
85  0,
86  ['title' => 'Testing #1', 'items' => 'tt_content_' . self::VALUE_ContentIdFirst]
87  );
88  $this->recordIds['newCategoryId'] = $newTableIds[‪self::TABLE_Category][0];
89  }
90 
91  public function ‪deleteCategoryRelation(): void
92  {
93  $this->actionService->modifyReferences(
94  self::TABLE_Content,
95  self::VALUE_ContentIdFirst,
96  'categories',
97  [self::VALUE_CategoryIdFirst]
98  );
99  }
100 
101  public function ‪changeCategoryRelationSorting(): void
102  {
103  $this->actionService->modifyReferences(
104  self::TABLE_Content,
105  self::VALUE_ContentIdFirst,
106  'categories',
107  [self::VALUE_CategoryIdSecond, self::VALUE_CategoryIdFirst]
108  );
109  }
110 
111  public function ‪modifyCategoryOfRelation(): void
112  {
113  $this->actionService->modifyRecord(self::TABLE_Category, self::VALUE_CategoryIdFirst, ['title' => 'Testing #1']);
114  }
115 
116  public function ‪modifyContentOfRelation(): void
117  {
118  $this->actionService->modifyRecord(self::TABLE_Content, self::VALUE_ContentIdFirst, ['header' => 'Testing #1']);
119  }
120 
121  public function ‪modifyBothsOfRelation(): void
122  {
123  $this->actionService->modifyRecord(self::TABLE_Category, self::VALUE_CategoryIdFirst, ['title' => 'Testing #1']);
124  $this->actionService->modifyRecord(self::TABLE_Content, self::VALUE_ContentIdFirst, ['header' => 'Testing #1']);
125  }
126 
127  public function ‪deleteContentOfRelation(): void
128  {
129  $this->actionService->deleteRecord(self::TABLE_Content, self::VALUE_ContentIdLast);
130  }
131 
132  public function ‪deleteCategoryOfRelation(): void
133  {
134  $this->actionService->deleteRecord(self::TABLE_Category, self::VALUE_CategoryIdFirst);
135  }
136 
137  public function ‪copyContentOfRelation(): void
138  {
139  $newTableIds = $this->actionService->copyRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_PageId);
140  $this->recordIds['newContentId'] = $newTableIds[‪self::TABLE_Content][‪self::VALUE_ContentIdLast];
141  }
142 
143  public function ‪copyCategoryOfRelation(): void
144  {
145  $newTableIds = $this->actionService->copyRecord(self::TABLE_Category, self::VALUE_CategoryIdFirst, 0);
146  $this->recordIds['newCategoryId'] = $newTableIds[‪self::TABLE_Category][‪self::VALUE_CategoryIdFirst];
147  }
148 
152  public function ‪copyContentToLanguageOfRelation(): void
153  {
154  $newTableIds = $this->actionService->copyRecordToLanguage(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_LanguageId);
155  $this->recordIds['newContentId'] = $newTableIds[‪self::TABLE_Content][‪self::VALUE_ContentIdLast];
156  }
157 
162  public function ‪copyCategoryToLanguageOfRelation(): void
163  {
164  $newTableIds = $this->actionService->copyRecordToLanguage(self::TABLE_Category, self::VALUE_CategoryIdFirst, self::VALUE_LanguageId);
165  $this->recordIds['newCategoryId'] = $newTableIds[‪self::TABLE_Category][‪self::VALUE_CategoryIdFirst];
166  }
167 
168  public function ‪localizeContentOfRelation(): void
169  {
170  $localizedTableIds = $this->actionService->localizeRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_LanguageId);
171  $this->recordIds['localizedContentId'] = $localizedTableIds[‪self::TABLE_Content][‪self::VALUE_ContentIdLast];
172  }
173 
175  {
176  ‪$GLOBALS['TCA'][‪self::TABLE_Content]['columns'][‪self::FIELD_Categories]['config']['behaviour']['allowLanguageSynchronization'] = true;
177  $localizedTableIds = $this->actionService->localizeRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_LanguageId);
178  $this->recordIds['localizedContentId'] = $localizedTableIds[‪self::TABLE_Content][‪self::VALUE_ContentIdLast];
179  }
180 
182  {
183  ‪$GLOBALS['TCA'][‪self::TABLE_Content]['columns'][‪self::FIELD_Categories]['config']['l10n_mode'] = 'exclude';
184  $localizedTableIds = $this->actionService->localizeRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_LanguageId);
185  $this->recordIds['localizedContentId'] = $localizedTableIds[‪self::TABLE_Content][‪self::VALUE_ContentIdLast];
186  }
187 
189  {
190  ‪$GLOBALS['TCA'][‪self::TABLE_Content]['columns'][‪self::FIELD_Categories]['config']['behaviour']['allowLanguageSynchronization'] = true;
191  $localizedTableIds = $this->actionService->localizeRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_LanguageId);
192  $this->recordIds['localizedContentId'] = $localizedTableIds[‪self::TABLE_Content][‪self::VALUE_ContentIdLast];
193  $this->actionService->modifyReferences(
194  self::TABLE_Content,
195  self::VALUE_ContentIdLast,
196  self::FIELD_Categories,
197  [self::VALUE_CategoryIdSecond, self::VALUE_CategoryIdThird, self::VALUE_CategoryIdFourth]
198  );
199  }
200 
202  {
203  ‪$GLOBALS['TCA'][‪self::TABLE_Content]['columns'][‪self::FIELD_Categories]['config']['behaviour']['allowLanguageSynchronization'] = true;
204  $localizedTableIds = $this->actionService->localizeRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_LanguageId);
205  $this->recordIds['localizedContentId'] = $localizedTableIds[‪self::TABLE_Content][‪self::VALUE_ContentIdLast];
206  $localizedTableIds = $this->actionService->localizeRecord(self::TABLE_Content, $this->recordIds['localizedContentId'], self::VALUE_LanguageIdSecond);
207  $this->recordIds['localizedContentIdSecond'] = $localizedTableIds[‪self::TABLE_Content][$this->recordIds['localizedContentId']];
208  $this->actionService->modifyRecord(
209  self::TABLE_Content,
210  $this->recordIds['localizedContentIdSecond'],
211  ['l10n_state' => [self::FIELD_Categories => 'source']]
212  );
213  $this->actionService->modifyReferences(
214  self::TABLE_Content,
215  self::VALUE_ContentIdLast,
216  self::FIELD_Categories,
217  [self::VALUE_CategoryIdSecond, self::VALUE_CategoryIdThird, self::VALUE_CategoryIdFourth]
218  );
219  }
220 
221  public function ‪localizeCategoryOfRelation(): void
222  {
223  $localizedTableIds = $this->actionService->localizeRecord(self::TABLE_Category, self::VALUE_CategoryIdFirst, self::VALUE_LanguageId);
224  $this->recordIds['localizedCategoryId'] = $localizedTableIds[‪self::TABLE_Category][‪self::VALUE_CategoryIdFirst];
225  }
226 
227  public function ‪moveContentOfRelationToDifferentPage(): void
228  {
229  $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_PageIdTarget);
230  }
231 
232  public function ‪copyPage(): void
233  {
234  $newTableIds = $this->actionService->copyRecord(self::TABLE_Page, self::VALUE_PageId, self::VALUE_PageIdTarget);
235  $this->recordIds['newPageId'] = $newTableIds[‪self::TABLE_Page][‪self::VALUE_PageId];
236  $this->recordIds['newContentIdFirst'] = $newTableIds[‪self::TABLE_Content][‪self::VALUE_ContentIdFirst];
237  $this->recordIds['newContentIdLast'] = $newTableIds[‪self::TABLE_Content][‪self::VALUE_ContentIdLast];
238  }
239 }
‪TYPO3\CMS\Core\Tests\Functional\DataScenarios\ManyToMany\AbstractActionTestCase\modifyContentOfRelation
‪modifyContentOfRelation()
Definition: AbstractActionTestCase.php:115
‪TYPO3\CMS\Core\Tests\Functional\DataScenarios\ManyToMany\AbstractActionTestCase\VALUE_PageId
‪const VALUE_PageId
Definition: AbstractActionTestCase.php:26
‪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\ManyToMany\AbstractActionTestCase\VALUE_CategoryIdFourth
‪const VALUE_CategoryIdFourth
Definition: AbstractActionTestCase.php:35
‪TYPO3\CMS\Core\Tests\Functional\DataScenarios\ManyToMany\AbstractActionTestCase\modifyBothsOfRelation
‪modifyBothsOfRelation()
Definition: AbstractActionTestCase.php:120
‪TYPO3\CMS\Core\Tests\Functional\DataScenarios\ManyToMany\AbstractActionTestCase\VALUE_LanguageIdSecond
‪const VALUE_LanguageIdSecond
Definition: AbstractActionTestCase.php:31
‪TYPO3\CMS\Core\Tests\Functional\DataScenarios\ManyToMany\AbstractActionTestCase\SCENARIO_DataSet
‪const SCENARIO_DataSet
Definition: AbstractActionTestCase.php:44
‪TYPO3\CMS\Core\Tests\Functional\DataScenarios\ManyToMany\AbstractActionTestCase\TABLE_Page
‪const TABLE_Page
Definition: AbstractActionTestCase.php:37
‪TYPO3\CMS\Core\Tests\Functional\DataScenarios\ManyToMany\AbstractActionTestCase\modifyCategoryOfRelation
‪modifyCategoryOfRelation()
Definition: AbstractActionTestCase.php:110
‪TYPO3\CMS\Core\Tests\Functional\SiteHandling\SiteBasedTestTrait
Definition: SiteBasedTestTrait.php:37
‪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\ManyToMany\AbstractActionTestCase\localizeContentOfRelation
‪localizeContentOfRelation()
Definition: AbstractActionTestCase.php:167
‪TYPO3\CMS\Core\Tests\Functional\DataScenarios\ManyToMany\AbstractActionTestCase\deleteCategoryOfRelation
‪deleteCategoryOfRelation()
Definition: AbstractActionTestCase.php:131
‪TYPO3\CMS\Core\Tests\Functional\DataScenarios\ManyToMany\AbstractActionTestCase\TABLE_Category
‪const TABLE_Category
Definition: AbstractActionTestCase.php:39
‪TYPO3\CMS\Core\Tests\Functional\SiteHandling\SiteBasedTestTrait\buildSiteConfiguration
‪buildSiteConfiguration(int $rootPageId, string $base='')
Definition: SiteBasedTestTrait.php:88
‪TYPO3\CMS\Core\Tests\Functional\DataScenarios\ManyToMany\AbstractActionTestCase\localizeCategoryOfRelation
‪localizeCategoryOfRelation()
Definition: AbstractActionTestCase.php:220
‪TYPO3\CMS\Core\Tests\Functional\DataScenarios\ManyToMany\AbstractActionTestCase\createCategoryAndAddRelation
‪createCategoryAndAddRelation()
Definition: AbstractActionTestCase.php:80
‪TYPO3\CMS\Core\Tests\Functional\DataScenarios\ManyToMany\AbstractActionTestCase\VALUE_ContentIdLast
‪const VALUE_ContentIdLast
Definition: AbstractActionTestCase.php:29
‪TYPO3\CMS\Core\Tests\Functional\DataScenarios\ManyToMany\AbstractActionTestCase\TABLE_Content
‪const TABLE_Content
Definition: AbstractActionTestCase.php:38
‪TYPO3\CMS\Core\Tests\Functional\DataScenarios\ManyToMany\AbstractActionTestCase\VALUE_CategoryIdFirst
‪const VALUE_CategoryIdFirst
Definition: AbstractActionTestCase.php:32
‪TYPO3\CMS\Core\Tests\Functional\DataScenarios\AbstractDataHandlerActionTestCase
Definition: AbstractDataHandlerActionTestCase.php:37
‪TYPO3\CMS\Core\Tests\Functional\DataScenarios\ManyToMany
Definition: AbstractActionTestCase.php:18
‪TYPO3\CMS\Core\Tests\Functional\DataScenarios\ManyToMany\AbstractActionTestCase\moveContentOfRelationToDifferentPage
‪moveContentOfRelationToDifferentPage()
Definition: AbstractActionTestCase.php:226
‪TYPO3\CMS\Core\Tests\Functional\DataScenarios\ManyToMany\AbstractActionTestCase
Definition: AbstractActionTestCase.php:24
‪TYPO3\CMS\Core\Tests\Functional\DataScenarios\ManyToMany\AbstractActionTestCase\localizeContentChainOfRelationAndAddCategoryWithLanguageSynchronization
‪localizeContentChainOfRelationAndAddCategoryWithLanguageSynchronization()
Definition: AbstractActionTestCase.php:200
‪TYPO3\CMS\Core\Tests\Functional\DataScenarios\ManyToMany\AbstractActionTestCase\VALUE_CategoryIdThird
‪const VALUE_CategoryIdThird
Definition: AbstractActionTestCase.php:34
‪TYPO3\CMS\Core\Tests\Functional\DataScenarios\ManyToMany\AbstractActionTestCase\localizeContentOfRelationAndAddCategoryWithLanguageSynchronization
‪localizeContentOfRelationAndAddCategoryWithLanguageSynchronization()
Definition: AbstractActionTestCase.php:187
‪TYPO3\CMS\Core\Tests\Functional\DataScenarios\ManyToMany\AbstractActionTestCase\localizeContentOfRelationWithLanguageSynchronization
‪localizeContentOfRelationWithLanguageSynchronization()
Definition: AbstractActionTestCase.php:173
‪TYPO3\CMS\Core\Tests\Functional\DataScenarios\ManyToMany\AbstractActionTestCase\TABLE_ContentCategory_ManyToMany
‪const TABLE_ContentCategory_ManyToMany
Definition: AbstractActionTestCase.php:40
‪TYPO3\CMS\Core\Tests\Functional\DataScenarios\ManyToMany\AbstractActionTestCase\deleteCategoryRelation
‪deleteCategoryRelation()
Definition: AbstractActionTestCase.php:90
‪TYPO3\CMS\Core\Tests\Functional\DataScenarios\ManyToMany\AbstractActionTestCase\copyPage
‪copyPage()
Definition: AbstractActionTestCase.php:231
‪TYPO3\CMS\Core\Tests\Functional\DataScenarios\ManyToMany\AbstractActionTestCase\VALUE_PageIdTarget
‪const VALUE_PageIdTarget
Definition: AbstractActionTestCase.php:27
‪TYPO3\CMS\Core\Tests\Functional\DataScenarios\ManyToMany\AbstractActionTestCase\VALUE_ContentIdFirst
‪const VALUE_ContentIdFirst
Definition: AbstractActionTestCase.php:28
‪TYPO3\CMS\Core\Tests\Functional\DataScenarios\ManyToMany\AbstractActionTestCase\localizeContentOfRelationWithLanguageExclude
‪localizeContentOfRelationWithLanguageExclude()
Definition: AbstractActionTestCase.php:180
‪TYPO3\CMS\Core\Tests\Functional\DataScenarios\ManyToMany\AbstractActionTestCase\copyCategoryToLanguageOfRelation
‪copyCategoryToLanguageOfRelation()
Definition: AbstractActionTestCase.php:161
‪TYPO3\CMS\Core\Tests\Functional\DataScenarios\ManyToMany\AbstractActionTestCase\addCategoryRelation
‪addCategoryRelation()
Definition: AbstractActionTestCase.php:70
‪TYPO3\CMS\Core\Tests\Functional\SiteHandling\SiteBasedTestTrait\buildDefaultLanguageConfiguration
‪buildDefaultLanguageConfiguration(string $identifier, string $base)
Definition: SiteBasedTestTrait.php:98
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:25
‪TYPO3\CMS\Core\Tests\Functional\DataScenarios\ManyToMany\AbstractActionTestCase\copyContentToLanguageOfRelation
‪copyContentToLanguageOfRelation()
Definition: AbstractActionTestCase.php:151
‪TYPO3\CMS\Core\Tests\Functional\DataScenarios\ManyToMany\AbstractActionTestCase\VALUE_CategoryIdSecond
‪const VALUE_CategoryIdSecond
Definition: AbstractActionTestCase.php:33
‪TYPO3\CMS\Core\Tests\Functional\DataScenarios\ManyToMany\AbstractActionTestCase\setUp
‪setUp()
Definition: AbstractActionTestCase.php:46
‪TYPO3\CMS\Core\Tests\Functional\DataScenarios\ManyToMany\AbstractActionTestCase\copyCategoryOfRelation
‪copyCategoryOfRelation()
Definition: AbstractActionTestCase.php:142
‪TYPO3\CMS\Core\Tests\Functional\DataScenarios\ManyToMany\AbstractActionTestCase\FIELD_Categories
‪const FIELD_Categories
Definition: AbstractActionTestCase.php:42
‪TYPO3\CMS\Core\Tests\Functional\DataScenarios\ManyToMany\AbstractActionTestCase\deleteContentOfRelation
‪deleteContentOfRelation()
Definition: AbstractActionTestCase.php:126
‪TYPO3\CMS\Core\Tests\Functional\DataScenarios\ManyToMany\AbstractActionTestCase\changeCategoryRelationSorting
‪changeCategoryRelationSorting()
Definition: AbstractActionTestCase.php:100
‪TYPO3\CMS\Core\Tests\Functional\DataScenarios\ManyToMany\AbstractActionTestCase\VALUE_LanguageId
‪const VALUE_LanguageId
Definition: AbstractActionTestCase.php:30
‪TYPO3\CMS\Core\Tests\Functional\DataScenarios\ManyToMany\AbstractActionTestCase\copyContentOfRelation
‪copyContentOfRelation()
Definition: AbstractActionTestCase.php:136