‪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 = 88;
28  protected const ‪VALUE_TargetPageId = 89;
29  protected const ‪VALUE_CategoryPageId = 0;
30  protected const ‪VALUE_ContentIdFirst = 297;
31  protected const ‪VALUE_ContentIdLast = 298;
32  protected const ‪VALUE_CategoryIdFirst = 28;
33  protected const ‪VALUE_CategoryIdSecond = 29;
34  protected const ‪VALUE_CategoryIdThird = 30;
35  protected const ‪VALUE_CategoryIdFourth = 31;
36 
37  protected const ‪TABLE_Content = 'tt_content';
38  protected const ‪TABLE_Category = 'sys_category';
39 
40  protected const ‪FIELD_Category = 'tx_testdatahandler_category';
41 
42  protected const ‪SCENARIO_DataSet = __DIR__ . '/DataSet/ImportDefault.csv';
43 
44  protected array ‪$testExtensionsToLoad = [
45  'typo3/sysext/core/Tests/Functional/Fixtures/Extensions/test_datahandler',
46  ];
47 
48  protected function ‪setUp(): void
49  {
50  parent::setUp();
51  // Prepend label for copied sys_category records
52  ‪$GLOBALS['TCA']['sys_category']['ctrl']['prependAtCopy'] = 'LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.prependAtCopy';
53  // Show copied tt_content records in frontend request
54  ‪$GLOBALS['TCA']['tt_content']['ctrl']['hideAtCopy'] = false;
55  $this->importCSVDataSet(static::SCENARIO_DataSet);
57  'test',
58  $this->‪buildSiteConfiguration(1, '/'),
59  [
60  $this->‪buildDefaultLanguageConfiguration('EN', '/'),
61  $this->‪buildLanguageConfiguration('DA', '/da/', ['EN']),
62  $this->‪buildLanguageConfiguration('DE', '/de/', ['DA', 'EN']),
63  ]
64  );
65  $this->setUpFrontendRootPage(1, ['EXT:core/Tests/Functional/Fixtures/Frontend/JsonRenderer.typoscript']);
66  }
67 
68  public function ‪addCategoryRelation(): void
69  {
70  $this->actionService->modifyRecord(
71  self::TABLE_Content,
72  self::VALUE_ContentIdLast,
73  [self::FIELD_Category => self::VALUE_CategoryIdFourth]
74  );
75  }
76 
77  public function ‪createAndAddCategoryRelation(): void
78  {
79  $newTableIds = $this->actionService->createNewRecord(
80  self::TABLE_Category,
81  self::VALUE_CategoryPageId,
82  [
83  'title' => 'Category B.A',
84  'parent' => self::VALUE_CategoryIdSecond,
85  ]
86  );
87 
88  $this->recordIds['newCategoryId'] = $newTableIds[‪self::TABLE_Category][0];
89 
90  $this->actionService->modifyRecord(
91  self::TABLE_Content,
92  self::VALUE_ContentIdLast,
93  [self::FIELD_Category => $this->recordIds['newCategoryId']]
94  );
95  }
96 
97  public function ‪createAndReplaceCategoryRelation(): void
98  {
99  $newTableIds = $this->actionService->createNewRecord(
100  self::TABLE_Category,
101  self::VALUE_CategoryPageId,
102  [
103  'title' => 'Category B.A',
104  'parent' => self::VALUE_CategoryIdSecond,
105  ]
106  );
107 
108  $this->recordIds['newCategoryId'] = $newTableIds[‪self::TABLE_Category][0];
109 
110  $this->actionService->modifyRecord(
111  self::TABLE_Content,
112  self::VALUE_ContentIdFirst,
113  [self::FIELD_Category => $this->recordIds['newCategoryId']]
114  );
115  }
116 
117  public function ‪changeExistingCategoryRelation(): void
118  {
119  $this->actionService->modifyRecord(
120  self::TABLE_Content,
121  self::VALUE_ContentIdFirst,
122  [self::FIELD_Category => self::VALUE_CategoryIdSecond]
123  );
124  }
125 
126  public function ‪modifyReferencingContentElement(): void
127  {
128  $this->actionService->modifyRecord(
129  self::TABLE_Content,
130  self::VALUE_ContentIdFirst,
131  ['header' => 'Testing #1']
132  );
133  }
134 
135  public function ‪modifyContentOfRelatedCategory(): void
136  {
137  $this->actionService->modifyRecord(
138  self::TABLE_Category,
139  self::VALUE_CategoryIdThird,
140  ['title' => 'Testing #1']
141  );
142  }
143 
145  {
146  $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdFirst, self::VALUE_TargetPageId);
147  $this->actionService->moveRecord(self::TABLE_Category, self::VALUE_CategoryIdThird, self::VALUE_TargetPageId);
148  }
149 
150  public function ‪changeContentAndCategorySorting(): void
151  {
152  $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_PageId);
153  $this->actionService->moveRecord(self::TABLE_Category, self::VALUE_CategoryIdThird, -self::VALUE_CategoryIdFourth);
154  }
155 
156  public function ‪copyContentAndCategoryRelation(): void
157  {
158  $newTableIds = $this->actionService->copyRecord(self::TABLE_Content, self::VALUE_ContentIdFirst, self::VALUE_PageId);
159  $this->recordIds['copiedContentId'] = $newTableIds[‪self::TABLE_Content][‪self::VALUE_ContentIdFirst];
160  $newTableIds = $this->actionService->copyRecord(self::TABLE_Category, self::VALUE_CategoryIdFourth, self::VALUE_CategoryPageId);
161  $this->recordIds['copiedCategoryId'] = $newTableIds[‪self::TABLE_Category][‪self::VALUE_CategoryIdFourth];
162  }
163 
164  public function ‪deleteCategoryRelation(): void
165  {
166  $this->actionService->modifyRecord(
167  self::TABLE_Content,
168  self::VALUE_ContentIdFirst,
169  [self::FIELD_Category => 0]
170  );
171  }
172 }
‪TYPO3\CMS\Core\Tests\Functional\DataScenarios\CategoryOneToOne\AbstractActionTestCase\createAndReplaceCategoryRelation
‪createAndReplaceCategoryRelation()
Definition: AbstractActionTestCase.php:96
‪TYPO3\CMS\Core\Tests\Functional\DataScenarios\CategoryOneToOne\AbstractActionTestCase\createAndAddCategoryRelation
‪createAndAddCategoryRelation()
Definition: AbstractActionTestCase.php:76
‪TYPO3\CMS\Core\Tests\Functional\DataScenarios\CategoryOneToOne\AbstractActionTestCase\VALUE_CategoryIdFirst
‪const VALUE_CategoryIdFirst
Definition: AbstractActionTestCase.php:31
‪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\CategoryOneToOne\AbstractActionTestCase\VALUE_CategoryIdSecond
‪const VALUE_CategoryIdSecond
Definition: AbstractActionTestCase.php:32
‪TYPO3\CMS\Core\Tests\Functional\DataScenarios\CategoryOneToOne
Definition: AbstractActionTestCase.php:18
‪TYPO3\CMS\Core\Tests\Functional\DataScenarios\CategoryOneToOne\AbstractActionTestCase\VALUE_CategoryIdThird
‪const VALUE_CategoryIdThird
Definition: AbstractActionTestCase.php:33
‪TYPO3\CMS\Core\Tests\Functional\DataScenarios\CategoryOneToOne\AbstractActionTestCase\VALUE_CategoryPageId
‪const VALUE_CategoryPageId
Definition: AbstractActionTestCase.php:28
‪TYPO3\CMS\Core\Tests\Functional\DataScenarios\CategoryOneToOne\AbstractActionTestCase\VALUE_CategoryIdFourth
‪const VALUE_CategoryIdFourth
Definition: AbstractActionTestCase.php:34
‪TYPO3\CMS\Core\Tests\Functional\SiteHandling\SiteBasedTestTrait
Definition: SiteBasedTestTrait.php:37
‪TYPO3\CMS\Core\Tests\Functional\DataScenarios\CategoryOneToOne\AbstractActionTestCase\VALUE_PageId
‪const VALUE_PageId
Definition: AbstractActionTestCase.php:26
‪TYPO3\CMS\Core\Tests\Functional\DataScenarios\CategoryOneToOne\AbstractActionTestCase
Definition: AbstractActionTestCase.php:24
‪TYPO3\CMS\Core\Tests\Functional\DataScenarios\CategoryOneToOne\AbstractActionTestCase\SCENARIO_DataSet
‪const SCENARIO_DataSet
Definition: AbstractActionTestCase.php:41
‪TYPO3\CMS\Core\Tests\Functional\DataScenarios\CategoryOneToOne\AbstractActionTestCase\$testExtensionsToLoad
‪array $testExtensionsToLoad
Definition: AbstractActionTestCase.php:43
‪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\SiteHandling\SiteBasedTestTrait\buildSiteConfiguration
‪buildSiteConfiguration(int $rootPageId, string $base='')
Definition: SiteBasedTestTrait.php:88
‪TYPO3\CMS\Core\Tests\Functional\DataScenarios\CategoryOneToOne\AbstractActionTestCase\TABLE_Category
‪const TABLE_Category
Definition: AbstractActionTestCase.php:37
‪TYPO3\CMS\Core\Tests\Functional\DataScenarios\CategoryOneToOne\AbstractActionTestCase\deleteCategoryRelation
‪deleteCategoryRelation()
Definition: AbstractActionTestCase.php:163
‪TYPO3\CMS\Core\Tests\Functional\DataScenarios\CategoryOneToOne\AbstractActionTestCase\changeExistingCategoryRelation
‪changeExistingCategoryRelation()
Definition: AbstractActionTestCase.php:116
‪TYPO3\CMS\Core\Tests\Functional\DataScenarios\AbstractDataHandlerActionTestCase
Definition: AbstractDataHandlerActionTestCase.php:37
‪TYPO3\CMS\Core\Tests\Functional\DataScenarios\CategoryOneToOne\AbstractActionTestCase\FIELD_Category
‪const FIELD_Category
Definition: AbstractActionTestCase.php:39
‪TYPO3\CMS\Core\Tests\Functional\DataScenarios\CategoryOneToOne\AbstractActionTestCase\addCategoryRelation
‪addCategoryRelation()
Definition: AbstractActionTestCase.php:67
‪TYPO3\CMS\Core\Tests\Functional\DataScenarios\CategoryOneToOne\AbstractActionTestCase\TABLE_Content
‪const TABLE_Content
Definition: AbstractActionTestCase.php:36
‪TYPO3\CMS\Core\Tests\Functional\DataScenarios\CategoryOneToOne\AbstractActionTestCase\moveContentAndCategoryRelationToDifferentPage
‪moveContentAndCategoryRelationToDifferentPage()
Definition: AbstractActionTestCase.php:143
‪TYPO3\CMS\Core\Tests\Functional\DataScenarios\CategoryOneToOne\AbstractActionTestCase\copyContentAndCategoryRelation
‪copyContentAndCategoryRelation()
Definition: AbstractActionTestCase.php:155
‪TYPO3\CMS\Core\Tests\Functional\DataScenarios\CategoryOneToOne\AbstractActionTestCase\VALUE_ContentIdLast
‪const VALUE_ContentIdLast
Definition: AbstractActionTestCase.php:30
‪TYPO3\CMS\Core\Tests\Functional\DataScenarios\CategoryOneToOne\AbstractActionTestCase\modifyReferencingContentElement
‪modifyReferencingContentElement()
Definition: AbstractActionTestCase.php:125
‪TYPO3\CMS\Core\Tests\Functional\DataScenarios\CategoryOneToOne\AbstractActionTestCase\VALUE_TargetPageId
‪const VALUE_TargetPageId
Definition: AbstractActionTestCase.php:27
‪TYPO3\CMS\Core\Tests\Functional\DataScenarios\CategoryOneToOne\AbstractActionTestCase\VALUE_ContentIdFirst
‪const VALUE_ContentIdFirst
Definition: AbstractActionTestCase.php:29
‪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\CategoryOneToOne\AbstractActionTestCase\changeContentAndCategorySorting
‪changeContentAndCategorySorting()
Definition: AbstractActionTestCase.php:149
‪TYPO3\CMS\Core\Tests\Functional\DataScenarios\CategoryOneToOne\AbstractActionTestCase\modifyContentOfRelatedCategory
‪modifyContentOfRelatedCategory()
Definition: AbstractActionTestCase.php:134
‪TYPO3\CMS\Core\Tests\Functional\DataScenarios\CategoryOneToOne\AbstractActionTestCase\setUp
‪setUp()
Definition: AbstractActionTestCase.php:47