‪TYPO3CMS  11.5
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 
21 
26 {
27  protected const ‪VALUE_PageId = 89;
28  protected const ‪VALUE_PageIdTarget = 90;
29  protected const ‪VALUE_PageIdWebsite = 1;
30  protected const ‪VALUE_ContentIdFirst = 330;
31  protected const ‪VALUE_ContentIdLast = 331;
32  protected const ‪VALUE_FileIdFirst = 1;
33  protected const ‪VALUE_FileIdLast = 21;
34  protected const ‪VALUE_LanguageId = 1;
35 
40 
41  protected const ‪TABLE_Page = 'pages';
42  protected const ‪TABLE_Content = 'tt_content';
43  protected const ‪TABLE_File = 'sys_file';
44  protected const ‪TABLE_FileMetadata = 'sys_file_metadata';
45  protected const ‪TABLE_FileReference = 'sys_file_reference';
46 
47  protected const ‪FIELD_ContentImage = 'image';
48  protected const ‪FIELD_FileReferenceImage = 'uid_local';
49 
50  protected const ‪SCENARIO_DataSet = __DIR__ . '/DataSet/ImportDefault.csv';
51 
53  'typo3/sysext/core/Tests/Functional/Fixtures/Extensions/irre_tutorial',
54  ];
55 
56  protected function ‪setUp(): void
57  {
58  parent::setUp();
59  $this->importCSVDataSet(static::SCENARIO_DataSet);
60  $this->importDataSet('PACKAGE:typo3/testing-framework/Resources/Core/Functional/Fixtures/sys_file_storage.xml');
61 
62  $this->‪setUpFrontendSite(1, $this->siteLanguageConfiguration);
63  $this->setUpFrontendRootPage(1, ['typo3/sysext/core/Tests/Functional/Fixtures/Frontend/JsonRenderer.typoscript']);
64  }
65 
73  public function ‪modifyContent(): void
74  {
75  $this->actionService->modifyRecord(self::TABLE_Content, self::VALUE_ContentIdLast, ['header' => 'Testing #1']);
76  }
77 
78  public function ‪deleteContent(): void
79  {
80  $this->actionService->deleteRecord(self::TABLE_Content, self::VALUE_ContentIdLast);
81  }
82 
83  public function ‪copyContent(): void
84  {
85  $newTableIds = $this->actionService->copyRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_PageId);
86  $this->recordIds['copiedContentId'] = $newTableIds[‪self::TABLE_Content][‪self::VALUE_ContentIdLast];
87  }
88 
92  public function ‪copyContentToLanguage(): void
93  {
94  $newTableIds = $this->actionService->copyRecordToLanguage(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_LanguageId);
95  $this->recordIds['localizedContentId'] = $newTableIds[‪self::TABLE_Content][‪self::VALUE_ContentIdLast];
96  }
97 
98  public function ‪localizeContent(): void
99  {
100  // Create translated page first
101  $newTableIds = $this->actionService->copyRecordToLanguage(self::TABLE_Page, self::VALUE_PageId, self::VALUE_LanguageId);
102  $this->recordIds['localizedPageId'] = $newTableIds[‪self::TABLE_Page][‪self::VALUE_PageId];
103  $newTableIds = $this->actionService->localizeRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_LanguageId);
104  $this->recordIds['localizedContentId'] = $newTableIds[‪self::TABLE_Content][‪self::VALUE_ContentIdLast];
105  }
106 
107  public function ‪changeContentSorting(): void
108  {
109  $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdFirst, -self::VALUE_ContentIdLast);
110  }
111 
118  {
119  return $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_PageIdTarget);
120  }
121 
123  {
124  $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_PageIdTarget);
125  $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdFirst, -self::VALUE_ContentIdLast);
126  }
127 
128  public function ‪createContentWithFileReference(): void
129  {
130  $newTableIds = $this->actionService->createNewRecords(
131  self::VALUE_PageId,
132  [
133  self::TABLE_Content => ['header' => 'Testing #1', self::FIELD_ContentImage => '__nextUid'],
134  self::TABLE_FileReference => ['title' => 'Image #1', self::FIELD_FileReferenceImage => self::VALUE_FileIdFirst],
135  ]
136  );
137  $this->recordIds['newContentId'] = $newTableIds[‪self::TABLE_Content][0];
138  }
139 
140  public function ‪modifyContentWithFileReference(): void
141  {
142  $this->actionService->modifyRecords(
143  self::VALUE_PageId,
144  [
145  self::TABLE_Content => ['uid' => self::VALUE_ContentIdLast, 'header' => 'Testing #1', self::FIELD_ContentImage => self::VALUE_FileReferenceContentLastFileLast . ',' . self::VALUE_FileReferenceContentLastFileFirst],
146  self::TABLE_FileReference => ['uid' => self::VALUE_FileReferenceContentLastFileFirst, 'title' => 'Image #1'],
147  ]
148  );
149  }
150 
151  public function ‪modifyContentAndAddFileReference(): void
152  {
153  $this->actionService->modifyRecords(
154  self::VALUE_PageId,
155  [
156  self::TABLE_Content => ['uid' => self::VALUE_ContentIdLast, self::FIELD_ContentImage => self::VALUE_FileReferenceContentLastFileLast . ',' . self::VALUE_FileReferenceContentLastFileFirst . ',__nextUid'],
157  self::TABLE_FileReference => ['uid' => '__NEW', 'title' => 'Image #3', self::FIELD_FileReferenceImage => self::VALUE_FileIdFirst],
158  ]
159  );
160  }
161 
163  {
164  $this->actionService->modifyRecord(
165  self::TABLE_Content,
166  self::VALUE_ContentIdLast,
167  [self::FIELD_ContentImage => self::VALUE_FileReferenceContentLastFileFirst],
168  [self::TABLE_FileReference => [self::VALUE_FileReferenceContentLastFileLast]]
169  );
170  }
171 
173  {
174  $this->actionService->modifyRecord(
175  self::TABLE_Content,
176  self::VALUE_ContentIdLast,
177  [self::FIELD_ContentImage => ''],
178  [self::TABLE_FileReference => [self::VALUE_FileReferenceContentLastFileFirst, self::VALUE_FileReferenceContentLastFileLast]]
179  );
180  }
181 
183  {
184  // Create content element with a file reference
185  $newTableIds = $this->actionService->createNewRecords(
186  self::VALUE_PageId,
187  [
188  self::TABLE_Content => ['header' => 'Testing #1', self::FIELD_ContentImage => '__nextUid'],
189  self::TABLE_FileReference => ['title' => 'Image #1', self::FIELD_FileReferenceImage => self::VALUE_FileIdFirst],
190  ]
191  );
192  $this->recordIds['newContentId'] = $newTableIds[‪self::TABLE_Content][0];
193  $this->recordIds['newSysFileReference'] = $newTableIds[‪self::TABLE_FileReference][0];
194  // Delete the file reference again, but keep the content element
195  $this->actionService->modifyRecord(
196  self::TABLE_Content,
197  $this->recordIds['newContentId'],
198  [self::FIELD_ContentImage => ''],
199  [self::TABLE_FileReference => [$this->recordIds['newSysFileReference']]]
200  );
201  }
202 }
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\FAL\AbstractActionTestCase
Definition: AbstractActionTestCase.php:26
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\FAL\AbstractActionTestCase\moveContentToDifferentPageAndChangeSorting
‪moveContentToDifferentPageAndChangeSorting()
Definition: AbstractActionTestCase.php:122
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\FAL\AbstractActionTestCase\FIELD_ContentImage
‪const FIELD_ContentImage
Definition: AbstractActionTestCase.php:47
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\FAL\AbstractActionTestCase\VALUE_FileReferenceContentFirstFileLast
‪const VALUE_FileReferenceContentFirstFileLast
Definition: AbstractActionTestCase.php:37
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\FAL\AbstractActionTestCase\VALUE_FileReferenceContentLastFileLast
‪const VALUE_FileReferenceContentLastFileLast
Definition: AbstractActionTestCase.php:38
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\FAL\AbstractActionTestCase\createContentWithFileReferenceAndDeleteFileReference
‪createContentWithFileReferenceAndDeleteFileReference()
Definition: AbstractActionTestCase.php:182
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\FAL\AbstractActionTestCase\copyContentToLanguage
‪copyContentToLanguage()
Definition: AbstractActionTestCase.php:92
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\AbstractDataHandlerActionTestCase\setUpFrontendSite
‪setUpFrontendSite(int $pageId, array $additionalLanguages=[])
Definition: AbstractDataHandlerActionTestCase.php:127
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\FAL\AbstractActionTestCase\copyContent
‪copyContent()
Definition: AbstractActionTestCase.php:83
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\FAL
Definition: AbstractActionTestCase.php:18
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\FAL\AbstractActionTestCase\SCENARIO_DataSet
‪const SCENARIO_DataSet
Definition: AbstractActionTestCase.php:50
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\FAL\AbstractActionTestCase\VALUE_ContentIdLast
‪const VALUE_ContentIdLast
Definition: AbstractActionTestCase.php:31
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\FAL\AbstractActionTestCase\VALUE_ContentIdFirst
‪const VALUE_ContentIdFirst
Definition: AbstractActionTestCase.php:30
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\FAL\AbstractActionTestCase\TABLE_File
‪const TABLE_File
Definition: AbstractActionTestCase.php:43
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\FAL\AbstractActionTestCase\modifyContent
‪modifyContent()
Definition: AbstractActionTestCase.php:73
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\FAL\AbstractActionTestCase\VALUE_FileReferenceContentFirstFileFirst
‪const VALUE_FileReferenceContentFirstFileFirst
Definition: AbstractActionTestCase.php:36
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\FAL\AbstractActionTestCase\VALUE_LanguageId
‪const VALUE_LanguageId
Definition: AbstractActionTestCase.php:34
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\FAL\AbstractActionTestCase\VALUE_FileIdLast
‪const VALUE_FileIdLast
Definition: AbstractActionTestCase.php:33
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\AbstractDataHandlerActionTestCase
Definition: AbstractDataHandlerActionTestCase.php:41
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\FAL\AbstractActionTestCase\modifyContentAndDeleteFileReference
‪modifyContentAndDeleteFileReference()
Definition: AbstractActionTestCase.php:162
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\FAL\AbstractActionTestCase\VALUE_PageIdWebsite
‪const VALUE_PageIdWebsite
Definition: AbstractActionTestCase.php:29
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\FAL\AbstractActionTestCase\deleteContent
‪deleteContent()
Definition: AbstractActionTestCase.php:78
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\FAL\AbstractActionTestCase\$testExtensionsToLoad
‪$testExtensionsToLoad
Definition: AbstractActionTestCase.php:52
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\FAL\AbstractActionTestCase\localizeContent
‪localizeContent()
Definition: AbstractActionTestCase.php:98
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\FAL\AbstractActionTestCase\VALUE_FileIdFirst
‪const VALUE_FileIdFirst
Definition: AbstractActionTestCase.php:32
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\FAL\AbstractActionTestCase\modifyContentAndDeleteAllFileReference
‪modifyContentAndDeleteAllFileReference()
Definition: AbstractActionTestCase.php:172
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\FAL\AbstractActionTestCase\createContentWithFileReference
‪createContentWithFileReference()
Definition: AbstractActionTestCase.php:128
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\FAL\AbstractActionTestCase\TABLE_Page
‪const TABLE_Page
Definition: AbstractActionTestCase.php:41
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\FAL\AbstractActionTestCase\modifyContentAndAddFileReference
‪modifyContentAndAddFileReference()
Definition: AbstractActionTestCase.php:151
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\FAL\AbstractActionTestCase\FIELD_FileReferenceImage
‪const FIELD_FileReferenceImage
Definition: AbstractActionTestCase.php:48
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\FAL\AbstractActionTestCase\modifyContentWithFileReference
‪modifyContentWithFileReference()
Definition: AbstractActionTestCase.php:140
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\FAL\AbstractActionTestCase\changeContentSorting
‪changeContentSorting()
Definition: AbstractActionTestCase.php:107
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\FAL\AbstractActionTestCase\TABLE_Content
‪const TABLE_Content
Definition: AbstractActionTestCase.php:42
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\FAL\AbstractActionTestCase\TABLE_FileReference
‪const TABLE_FileReference
Definition: AbstractActionTestCase.php:45
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\FAL\AbstractActionTestCase\TABLE_FileMetadata
‪const TABLE_FileMetadata
Definition: AbstractActionTestCase.php:44
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\FAL\AbstractActionTestCase\moveContentToDifferentPage
‪mixed moveContentToDifferentPage()
Definition: AbstractActionTestCase.php:117
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\FAL\AbstractActionTestCase\VALUE_PageId
‪const VALUE_PageId
Definition: AbstractActionTestCase.php:27
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\FAL\AbstractActionTestCase\VALUE_FileReferenceContentLastFileFirst
‪const VALUE_FileReferenceContentLastFileFirst
Definition: AbstractActionTestCase.php:39
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\FAL\AbstractActionTestCase\VALUE_PageIdTarget
‪const VALUE_PageIdTarget
Definition: AbstractActionTestCase.php:28
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\FAL\AbstractActionTestCase\setUp
‪setUp()
Definition: AbstractActionTestCase.php:56