‪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_ElementIdFirst = 1;
33  protected const ‪VALUE_ElementIdSecond = 2;
34  protected const ‪VALUE_ElementIdThird = 3;
35 
36  protected const ‪TABLE_Content = 'tt_content';
37  protected const ‪TABLE_Element = 'tx_testdatahandler_element';
38 
39  protected const ‪FIELD_ContentElement = 'tx_testdatahandler_select';
40 
41  protected const ‪SCENARIO_DataSet = __DIR__ . '/DataSet/ImportDefault.csv';
42 
43  protected array ‪$testExtensionsToLoad = [
44  'typo3/sysext/core/Tests/Functional/Fixtures/Extensions/test_datahandler',
45  ];
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  $this->importCSVDataSet(static::SCENARIO_DataSet);
56  'test',
57  $this->‪buildSiteConfiguration(1, '/'),
58  [
59  $this->‪buildDefaultLanguageConfiguration('EN', '/'),
60  $this->‪buildLanguageConfiguration('DA', '/da/', ['EN']),
61  $this->‪buildLanguageConfiguration('DE', '/de/', ['DA', 'EN']),
62  ]
63  );
64  $this->setUpFrontendRootPage(1, ['EXT:core/Tests/Functional/Fixtures/Frontend/JsonRenderer.typoscript']);
65  }
66 
67  public function ‪addElementRelation(): void
68  {
69  $this->actionService->modifyReferences(
70  self::TABLE_Content,
71  self::VALUE_ContentIdFirst,
72  self::FIELD_ContentElement,
73  [self::VALUE_ElementIdFirst, self::VALUE_ElementIdSecond, self::VALUE_ElementIdThird]
74  );
75  }
76 
77  public function ‪deleteElementRelation(): void
78  {
79  $this->actionService->modifyReferences(
80  self::TABLE_Content,
81  self::VALUE_ContentIdFirst,
82  self::FIELD_ContentElement,
83  [self::VALUE_ElementIdFirst]
84  );
85  }
86 
87  public function ‪changeElementSorting(): void
88  {
89  $this->actionService->moveRecord(self::TABLE_Element, self::VALUE_ElementIdFirst, -self::VALUE_ElementIdSecond);
90  }
91 
92  public function ‪changeElementRelationSorting(): void
93  {
94  $this->actionService->modifyReferences(
95  self::TABLE_Content,
96  self::VALUE_ContentIdFirst,
97  self::FIELD_ContentElement,
98  [self::VALUE_ElementIdSecond, self::VALUE_ElementIdFirst]
99  );
100  }
101 
102  public function ‪createContentAndAddElementRelation(): void
103  {
104  $newTableIds = $this->actionService->createNewRecord(
105  self::TABLE_Content,
106  self::VALUE_PageId,
107  ['header' => 'Testing #1', self::FIELD_ContentElement => self::VALUE_ElementIdFirst]
108  );
109  $this->recordIds['newContentId'] = $newTableIds[‪self::TABLE_Content][0];
110  }
111 
112  public function ‪createContentAndCreateElementRelation(): void
113  {
114  $newElementIds = $this->actionService->createNewRecord(self::TABLE_Element, self::VALUE_PageId, ['title' => 'Testing #1']);
115  $this->recordIds['newElementId'] = $newElementIds[‪self::TABLE_Element][0];
116  // It's not possible to use "NEW..." values for the TCA type 'select' in a workspace, in live it would have been fine
117  $newContentIds = $this->actionService->createNewRecord(self::TABLE_Content, self::VALUE_PageId, ['header' => 'Testing #1', self::FIELD_ContentElement => $this->recordIds['newElementId']]);
118  $this->recordIds['newContentId'] = $newContentIds[‪self::TABLE_Content][0];
119  }
120 
121  public function ‪modifyElementOfRelation(): void
122  {
123  $this->actionService->modifyRecord(self::TABLE_Element, self::VALUE_ElementIdFirst, ['title' => 'Testing #1']);
124  }
125 
126  public function ‪modifyContentOfRelation(): void
127  {
128  $this->actionService->modifyRecord(self::TABLE_Content, self::VALUE_ContentIdFirst, ['header' => 'Testing #1']);
129  }
130 
131  public function ‪modifyBothSidesOfRelation(): void
132  {
133  $this->actionService->modifyRecord(self::TABLE_Element, self::VALUE_ElementIdFirst, ['title' => 'Testing #1']);
134  $this->actionService->modifyRecord(self::TABLE_Content, self::VALUE_ContentIdFirst, ['header' => 'Testing #1']);
135  }
136 
137  public function ‪deleteContentOfRelation(): void
138  {
139  $this->actionService->deleteRecord(self::TABLE_Content, self::VALUE_ContentIdLast);
140  }
141 
142  public function ‪deleteElementOfRelation(): void
143  {
144  $this->actionService->deleteRecord(self::TABLE_Element, self::VALUE_ElementIdFirst);
145  }
146 
147  public function ‪copyContentOfRelation(): void
148  {
149  $newTableIds = $this->actionService->copyRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_PageId);
150  $this->recordIds['copiedContentId'] = $newTableIds[‪self::TABLE_Content][‪self::VALUE_ContentIdLast];
151  }
152 
153  public function ‪copyElementOfRelation(): void
154  {
155  $newTableIds = $this->actionService->copyRecord(self::TABLE_Element, self::VALUE_ElementIdFirst, self::VALUE_PageId);
156  $this->recordIds['copiedElementId'] = $newTableIds[‪self::TABLE_Element][‪self::VALUE_ElementIdFirst];
157  }
158 
162  public function ‪copyContentToLanguageOfRelation(): void
163  {
164  $newTableIds = $this->actionService->copyRecordToLanguage(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_LanguageId);
165  $this->recordIds['localizedContentId'] = $newTableIds[‪self::TABLE_Content][‪self::VALUE_ContentIdLast];
166  }
167 
171  public function ‪copyElementToLanguageOfRelation(): void
172  {
173  $newTableIds = $this->actionService->copyRecordToLanguage(self::TABLE_Element, self::VALUE_ElementIdFirst, self::VALUE_LanguageId);
174  $this->recordIds['localizedElementId'] = $newTableIds[‪self::TABLE_Element][‪self::VALUE_ElementIdFirst];
175  }
176 
177  public function ‪localizeContentOfRelation(): void
178  {
179  $newTableIds = $this->actionService->localizeRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_LanguageId);
180  $this->recordIds['localizedContentId'] = $newTableIds[‪self::TABLE_Content][‪self::VALUE_ContentIdLast];
181  }
182 
183  public function ‪localizeElementOfRelation(): void
184  {
185  $newTableIds = $this->actionService->localizeRecord(self::TABLE_Element, self::VALUE_ElementIdFirst, self::VALUE_LanguageId);
186  $this->recordIds['localizedElementId'] = $newTableIds[‪self::TABLE_Element][‪self::VALUE_ElementIdFirst];
187  }
188 
190  {
191  ‪$GLOBALS['TCA']['tt_content']['columns'][‪self::FIELD_ContentElement]['config']['localizeReferencesAtParentLocalization'] = true;
192  $newTableIds = $this->actionService->localizeRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_LanguageId);
193  $this->recordIds['localizedContentId'] = $newTableIds[‪self::TABLE_Content][‪self::VALUE_ContentIdLast];
194  }
195 
196  public function ‪moveContentOfRelationToDifferentPage(): void
197  {
198  $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_PageIdTarget);
199  }
200 }
‪TYPO3\CMS\Core\Tests\Functional\DataScenarios\Select\AbstractActionTestCase\modifyContentOfRelation
‪modifyContentOfRelation()
Definition: AbstractActionTestCase.php:125
‪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\Select\AbstractActionTestCase\TABLE_Content
‪const TABLE_Content
Definition: AbstractActionTestCase.php:35
‪TYPO3\CMS\Core\Tests\Functional\DataScenarios\Select\AbstractActionTestCase\changeElementRelationSorting
‪changeElementRelationSorting()
Definition: AbstractActionTestCase.php:91
‪TYPO3\CMS\Core\Tests\Functional\DataScenarios\Select\AbstractActionTestCase\deleteElementOfRelation
‪deleteElementOfRelation()
Definition: AbstractActionTestCase.php:141
‪TYPO3\CMS\Core\Tests\Functional\DataScenarios\Select\AbstractActionTestCase\setUp
‪setUp()
Definition: AbstractActionTestCase.php:46
‪TYPO3\CMS\Core\Tests\Functional\SiteHandling\SiteBasedTestTrait
Definition: SiteBasedTestTrait.php:37
‪TYPO3\CMS\Core\Tests\Functional\DataScenarios\Select\AbstractActionTestCase\VALUE_ElementIdThird
‪const VALUE_ElementIdThird
Definition: AbstractActionTestCase.php:33
‪TYPO3\CMS\Core\Tests\Functional\DataScenarios\Select\AbstractActionTestCase\createContentAndCreateElementRelation
‪createContentAndCreateElementRelation()
Definition: AbstractActionTestCase.php:111
‪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\Select\AbstractActionTestCase\changeElementSorting
‪changeElementSorting()
Definition: AbstractActionTestCase.php:86
‪TYPO3\CMS\Core\Tests\Functional\DataScenarios\Select\AbstractActionTestCase\VALUE_ContentIdFirst
‪const VALUE_ContentIdFirst
Definition: AbstractActionTestCase.php:28
‪TYPO3\CMS\Core\Tests\Functional\DataScenarios\Select\AbstractActionTestCase\VALUE_PageId
‪const VALUE_PageId
Definition: AbstractActionTestCase.php:26
‪TYPO3\CMS\Core\Tests\Functional\SiteHandling\SiteBasedTestTrait\buildSiteConfiguration
‪buildSiteConfiguration(int $rootPageId, string $base='')
Definition: SiteBasedTestTrait.php:88
‪TYPO3\CMS\Core\Tests\Functional\DataScenarios\Select\AbstractActionTestCase\localizeContentOfRelation
‪localizeContentOfRelation()
Definition: AbstractActionTestCase.php:176
‪TYPO3\CMS\Core\Tests\Functional\DataScenarios\Select\AbstractActionTestCase\createContentAndAddElementRelation
‪createContentAndAddElementRelation()
Definition: AbstractActionTestCase.php:101
‪TYPO3\CMS\Core\Tests\Functional\DataScenarios\Select\AbstractActionTestCase\modifyBothSidesOfRelation
‪modifyBothSidesOfRelation()
Definition: AbstractActionTestCase.php:130
‪TYPO3\CMS\Core\Tests\Functional\DataScenarios\AbstractDataHandlerActionTestCase
Definition: AbstractDataHandlerActionTestCase.php:37
‪TYPO3\CMS\Core\Tests\Functional\DataScenarios\Select\AbstractActionTestCase\localizeElementOfRelation
‪localizeElementOfRelation()
Definition: AbstractActionTestCase.php:182
‪TYPO3\CMS\Core\Tests\Functional\DataScenarios\Select\AbstractActionTestCase\copyElementToLanguageOfRelation
‪copyElementToLanguageOfRelation()
Definition: AbstractActionTestCase.php:170
‪TYPO3\CMS\Core\Tests\Functional\DataScenarios\Select\AbstractActionTestCase\localizeContentOfRelationWithLocalizeReferencesAtParentLocalization
‪localizeContentOfRelationWithLocalizeReferencesAtParentLocalization()
Definition: AbstractActionTestCase.php:188
‪TYPO3\CMS\Core\Tests\Functional\DataScenarios\Select\AbstractActionTestCase\$testExtensionsToLoad
‪array $testExtensionsToLoad
Definition: AbstractActionTestCase.php:42
‪TYPO3\CMS\Core\Tests\Functional\DataScenarios\Select\AbstractActionTestCase\TABLE_Element
‪const TABLE_Element
Definition: AbstractActionTestCase.php:36
‪TYPO3\CMS\Core\Tests\Functional\DataScenarios\Select
Definition: AbstractActionTestCase.php:18
‪TYPO3\CMS\Core\Tests\Functional\DataScenarios\Select\AbstractActionTestCase\modifyElementOfRelation
‪modifyElementOfRelation()
Definition: AbstractActionTestCase.php:120
‪TYPO3\CMS\Core\Tests\Functional\DataScenarios\Select\AbstractActionTestCase\copyElementOfRelation
‪copyElementOfRelation()
Definition: AbstractActionTestCase.php:152
‪TYPO3\CMS\Core\Tests\Functional\DataScenarios\Select\AbstractActionTestCase\VALUE_ElementIdSecond
‪const VALUE_ElementIdSecond
Definition: AbstractActionTestCase.php:32
‪TYPO3\CMS\Core\Tests\Functional\DataScenarios\Select\AbstractActionTestCase\copyContentToLanguageOfRelation
‪copyContentToLanguageOfRelation()
Definition: AbstractActionTestCase.php:161
‪TYPO3\CMS\Core\Tests\Functional\DataScenarios\Select\AbstractActionTestCase\SCENARIO_DataSet
‪const SCENARIO_DataSet
Definition: AbstractActionTestCase.php:40
‪TYPO3\CMS\Core\Tests\Functional\DataScenarios\Select\AbstractActionTestCase\deleteContentOfRelation
‪deleteContentOfRelation()
Definition: AbstractActionTestCase.php:136
‪TYPO3\CMS\Core\Tests\Functional\DataScenarios\Select\AbstractActionTestCase\VALUE_ContentIdLast
‪const VALUE_ContentIdLast
Definition: AbstractActionTestCase.php:29
‪TYPO3\CMS\Core\Tests\Functional\DataScenarios\Select\AbstractActionTestCase\addElementRelation
‪addElementRelation()
Definition: AbstractActionTestCase.php:66
‪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\Select\AbstractActionTestCase
Definition: AbstractActionTestCase.php:24
‪TYPO3\CMS\Core\Tests\Functional\DataScenarios\Select\AbstractActionTestCase\copyContentOfRelation
‪copyContentOfRelation()
Definition: AbstractActionTestCase.php:146
‪TYPO3\CMS\Core\Tests\Functional\DataScenarios\Select\AbstractActionTestCase\moveContentOfRelationToDifferentPage
‪moveContentOfRelationToDifferentPage()
Definition: AbstractActionTestCase.php:195
‪TYPO3\CMS\Core\Tests\Functional\DataScenarios\Select\AbstractActionTestCase\VALUE_PageIdTarget
‪const VALUE_PageIdTarget
Definition: AbstractActionTestCase.php:27
‪TYPO3\CMS\Core\Tests\Functional\DataScenarios\Select\AbstractActionTestCase\FIELD_ContentElement
‪const FIELD_ContentElement
Definition: AbstractActionTestCase.php:38
‪TYPO3\CMS\Core\Tests\Functional\DataScenarios\Select\AbstractActionTestCase\VALUE_LanguageId
‪const VALUE_LanguageId
Definition: AbstractActionTestCase.php:30
‪TYPO3\CMS\Core\Tests\Functional\DataScenarios\Select\AbstractActionTestCase\deleteElementRelation
‪deleteElementRelation()
Definition: AbstractActionTestCase.php:76
‪TYPO3\CMS\Core\Tests\Functional\DataScenarios\Select\AbstractActionTestCase\VALUE_ElementIdFirst
‪const VALUE_ElementIdFirst
Definition: AbstractActionTestCase.php:31