‪TYPO3CMS  10.4
AbstractActionTestCase.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the TYPO3 CMS project.
5  *
6  * It is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU General Public License, either version 2
8  * of the License, or any later version.
9  *
10  * For the full copyright and license information, please read the
11  * LICENSE.txt file that was distributed with this source code.
12  *
13  * The TYPO3 project - inspiring people to share!
14  */
15 
17 
19 
24 {
25  const ‪VALUE_PageId = 89;
31  const ‪VALUE_FileIdLast = 21;
33 
38 
39  const ‪TABLE_Page = 'pages';
40  const ‪TABLE_Content = 'tt_content';
41  const ‪TABLE_File = 'sys_file';
42  const ‪TABLE_FileMetadata = 'sys_file_metadata';
43  const ‪TABLE_FileReference = 'sys_file_reference';
44 
45  const ‪FIELD_ContentImage = 'image';
46  const ‪FIELD_FileReferenceImage = 'uid_local';
47 
51  protected ‪$scenarioDataSetDirectory = 'typo3/sysext/core/Tests/Functional/DataHandling/FAL/DataSet/';
52 
53  protected function ‪setUp(): void
54  {
55  parent::setUp();
56  $this->‪importScenarioDataSet('LiveDefaultPages');
57  $this->‪importScenarioDataSet('LiveDefaultElements');
58  $this->importDataSet('PACKAGE:typo3/testing-framework/Resources/Core/Functional/Fixtures/sys_file_storage.xml');
59 
60  $this->‪setUpFrontendSite(1, $this->siteLanguageConfiguration);
61  $this->setUpFrontendRootPage(1, ['typo3/sysext/core/Tests/Functional/Fixtures/Frontend/JsonRenderer.typoscript']);
62  }
63 
71  public function ‪modifyContent()
72  {
73  $this->actionService->modifyRecord(self::TABLE_Content, self::VALUE_ContentIdLast, ['header' => 'Testing #1']);
74  }
75 
76  public function ‪deleteContent()
77  {
78  $this->actionService->deleteRecord(self::TABLE_Content, self::VALUE_ContentIdLast);
79  }
80 
81  public function ‪copyContent()
82  {
83  $newTableIds = $this->actionService->copyRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_PageId);
84  $this->recordIds['copiedContentId'] = $newTableIds[‪self::TABLE_Content][‪self::VALUE_ContentIdLast];
85  }
86 
90  public function ‪copyContentToLanguage()
91  {
92  $newTableIds = $this->actionService->copyRecordToLanguage(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_LanguageId);
93  $this->recordIds['localizedContentId'] = $newTableIds[‪self::TABLE_Content][‪self::VALUE_ContentIdLast];
94  }
95 
96  public function ‪localizeContent()
97  {
98  $newTableIds = $this->actionService->localizeRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_LanguageId);
99  $this->recordIds['localizedContentId'] = $newTableIds[‪self::TABLE_Content][‪self::VALUE_ContentIdLast];
100  }
101 
102  public function ‪changeContentSorting()
103  {
104  $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdFirst, -self::VALUE_ContentIdLast);
105  }
106 
107  public function ‪moveContentToDifferentPage()
108  {
109  return $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_PageIdTarget);
110  }
111 
113  {
114  $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_PageIdTarget);
115  $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdFirst, -self::VALUE_ContentIdLast);
116  }
117 
118  public function ‪createContentWithFileReference()
119  {
120  $newTableIds = $this->actionService->createNewRecords(
121  self::VALUE_PageId,
122  [
123  self::TABLE_Content => ['header' => 'Testing #1', self::FIELD_ContentImage => '__nextUid'],
124  self::TABLE_FileReference => ['title' => 'Image #1', self::FIELD_FileReferenceImage => self::VALUE_FileIdFirst],
125  ]
126  );
127  $this->recordIds['newContentId'] = $newTableIds[‪self::TABLE_Content][0];
128  }
129 
130  public function ‪modifyContentWithFileReference()
131  {
132  $this->actionService->modifyRecords(
133  self::VALUE_PageId,
134  [
135  self::TABLE_Content => ['uid' => self::VALUE_ContentIdLast, 'header' => 'Testing #1', self::FIELD_ContentImage => self::VALUE_FileReferenceContentLastFileLast . ',' . self::VALUE_FileReferenceContentLastFileFirst],
136  self::TABLE_FileReference => ['uid' => self::VALUE_FileReferenceContentLastFileFirst, 'title' => 'Image #1'],
137  ]
138  );
139  }
140 
141  public function ‪modifyContentAndAddFileReference()
142  {
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  $this->actionService->modifyRecord(
155  self::TABLE_Content,
156  self::VALUE_ContentIdLast,
157  [self::FIELD_ContentImage => self::VALUE_FileReferenceContentLastFileFirst],
158  [self::TABLE_FileReference => [self::VALUE_FileReferenceContentLastFileLast]]
159  );
160  }
161 
163  {
164  $this->actionService->modifyRecord(
165  self::TABLE_Content,
166  self::VALUE_ContentIdLast,
167  [self::FIELD_ContentImage => ''],
168  [self::TABLE_FileReference => [self::VALUE_FileReferenceContentLastFileFirst, self::VALUE_FileReferenceContentLastFileLast]]
169  );
170  }
171 
173  {
174  // Create content element with a file reference
175  $newTableIds = $this->actionService->createNewRecords(
176  self::VALUE_PageId,
177  [
178  self::TABLE_Content => ['header' => 'Testing #1', self::FIELD_ContentImage => '__nextUid'],
179  self::TABLE_FileReference => ['title' => 'Image #1', self::FIELD_FileReferenceImage => self::VALUE_FileIdFirst],
180  ]
181  );
182  $this->recordIds['newContentId'] = $newTableIds[‪self::TABLE_Content][0];
183  $this->recordIds['newSysFileReference'] = $newTableIds[‪self::TABLE_FileReference][0];
184  // Delete the file reference again, but keep the content element
185  $this->actionService->modifyRecord(
186  self::TABLE_Content,
187  $this->recordIds['newContentId'],
188  [self::FIELD_ContentImage => ''],
189  [self::TABLE_FileReference => [$this->recordIds['newSysFileReference']]]
190  );
191  }
192 }
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\FAL\AbstractActionTestCase
Definition: AbstractActionTestCase.php:24
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\FAL\AbstractActionTestCase\moveContentToDifferentPageAndChangeSorting
‪moveContentToDifferentPageAndChangeSorting()
Definition: AbstractActionTestCase.php:111
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\FAL\AbstractActionTestCase\FIELD_ContentImage
‪const FIELD_ContentImage
Definition: AbstractActionTestCase.php:45
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\FAL\AbstractActionTestCase\VALUE_FileReferenceContentFirstFileLast
‪const VALUE_FileReferenceContentFirstFileLast
Definition: AbstractActionTestCase.php:35
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\FAL\AbstractActionTestCase\VALUE_FileReferenceContentLastFileLast
‪const VALUE_FileReferenceContentLastFileLast
Definition: AbstractActionTestCase.php:36
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\FAL\AbstractActionTestCase\createContentWithFileReferenceAndDeleteFileReference
‪createContentWithFileReferenceAndDeleteFileReference()
Definition: AbstractActionTestCase.php:171
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\FAL\AbstractActionTestCase\copyContentToLanguage
‪copyContentToLanguage()
Definition: AbstractActionTestCase.php:89
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\AbstractDataHandlerActionTestCase\setUpFrontendSite
‪setUpFrontendSite(int $pageId, array $additionalLanguages=[])
Definition: AbstractDataHandlerActionTestCase.php:143
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\FAL\AbstractActionTestCase\copyContent
‪copyContent()
Definition: AbstractActionTestCase.php:80
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\FAL
Definition: AbstractActionTestCase.php:16
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\FAL\AbstractActionTestCase\VALUE_ContentIdLast
‪const VALUE_ContentIdLast
Definition: AbstractActionTestCase.php:29
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\FAL\AbstractActionTestCase\VALUE_ContentIdFirst
‪const VALUE_ContentIdFirst
Definition: AbstractActionTestCase.php:28
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\FAL\AbstractActionTestCase\TABLE_File
‪const TABLE_File
Definition: AbstractActionTestCase.php:41
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\FAL\AbstractActionTestCase\$scenarioDataSetDirectory
‪string $scenarioDataSetDirectory
Definition: AbstractActionTestCase.php:50
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\FAL\AbstractActionTestCase\modifyContent
‪modifyContent()
Definition: AbstractActionTestCase.php:70
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\FAL\AbstractActionTestCase\VALUE_FileReferenceContentFirstFileFirst
‪const VALUE_FileReferenceContentFirstFileFirst
Definition: AbstractActionTestCase.php:34
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\FAL\AbstractActionTestCase\VALUE_LanguageId
‪const VALUE_LanguageId
Definition: AbstractActionTestCase.php:32
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\FAL\AbstractActionTestCase\VALUE_FileIdLast
‪const VALUE_FileIdLast
Definition: AbstractActionTestCase.php:31
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\FAL\AbstractActionTestCase\moveContentToDifferentPage
‪moveContentToDifferentPage()
Definition: AbstractActionTestCase.php:106
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\AbstractDataHandlerActionTestCase
Definition: AbstractDataHandlerActionTestCase.php:37
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\FAL\AbstractActionTestCase\modifyContentAndDeleteFileReference
‪modifyContentAndDeleteFileReference()
Definition: AbstractActionTestCase.php:151
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\FAL\AbstractActionTestCase\VALUE_PageIdWebsite
‪const VALUE_PageIdWebsite
Definition: AbstractActionTestCase.php:27
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\FAL\AbstractActionTestCase\deleteContent
‪deleteContent()
Definition: AbstractActionTestCase.php:75
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\FAL\AbstractActionTestCase\localizeContent
‪localizeContent()
Definition: AbstractActionTestCase.php:95
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\FAL\AbstractActionTestCase\VALUE_FileIdFirst
‪const VALUE_FileIdFirst
Definition: AbstractActionTestCase.php:30
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\FAL\AbstractActionTestCase\modifyContentAndDeleteAllFileReference
‪modifyContentAndDeleteAllFileReference()
Definition: AbstractActionTestCase.php:161
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\FAL\AbstractActionTestCase\createContentWithFileReference
‪createContentWithFileReference()
Definition: AbstractActionTestCase.php:117
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\FAL\AbstractActionTestCase\TABLE_Page
‪const TABLE_Page
Definition: AbstractActionTestCase.php:39
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\FAL\AbstractActionTestCase\modifyContentAndAddFileReference
‪modifyContentAndAddFileReference()
Definition: AbstractActionTestCase.php:140
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\FAL\AbstractActionTestCase\FIELD_FileReferenceImage
‪const FIELD_FileReferenceImage
Definition: AbstractActionTestCase.php:46
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\FAL\AbstractActionTestCase\modifyContentWithFileReference
‪modifyContentWithFileReference()
Definition: AbstractActionTestCase.php:129
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\FAL\AbstractActionTestCase\changeContentSorting
‪changeContentSorting()
Definition: AbstractActionTestCase.php:101
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\FAL\AbstractActionTestCase\TABLE_Content
‪const TABLE_Content
Definition: AbstractActionTestCase.php:40
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\FAL\AbstractActionTestCase\TABLE_FileReference
‪const TABLE_FileReference
Definition: AbstractActionTestCase.php:43
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\FAL\AbstractActionTestCase\TABLE_FileMetadata
‪const TABLE_FileMetadata
Definition: AbstractActionTestCase.php:42
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\FAL\AbstractActionTestCase\VALUE_PageId
‪const VALUE_PageId
Definition: AbstractActionTestCase.php:25
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\FAL\AbstractActionTestCase\VALUE_FileReferenceContentLastFileFirst
‪const VALUE_FileReferenceContentLastFileFirst
Definition: AbstractActionTestCase.php:37
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\FAL\AbstractActionTestCase\VALUE_PageIdTarget
‪const VALUE_PageIdTarget
Definition: AbstractActionTestCase.php:26
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\AbstractDataHandlerActionTestCase\importScenarioDataSet
‪importScenarioDataSet($dataSetName)
Definition: AbstractDataHandlerActionTestCase.php:201
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\FAL\AbstractActionTestCase\setUp
‪setUp()
Definition: AbstractActionTestCase.php:52