Skip to content

Commit fe8a52f

Browse files
committed
[TASK] Functionally test TCA enableCascadingDelete
The heavily mocking unit test regarding TCA inline 'enableCascadingDelete' is turned into functional DataHandler DataScenarios tests. This reveals workspaces does not handle the property properly, now commented with test todos. Resolves: #106082 Releases: main, 13.4 Change-Id: I1060e80b927c37d72bb616fe84f4c25ace143867 Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/88020 Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de> Reviewed-by: Garvin Hicking <gh@faktor-e.de> Reviewed-by: Andreas Nedbal <andy@pixelde.su> Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch> Tested-by: Christian Kuhn <lolli@schwarzbu.ch> Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de> Tested-by: core-ci <typo3@b13.com> Tested-by: Garvin Hicking <gh@faktor-e.de> Tested-by: Andreas Nedbal <andy@pixelde.su>
1 parent d359387 commit fe8a52f

File tree

6 files changed

+135
-25
lines changed

6 files changed

+135
-25
lines changed

typo3/sysext/core/Tests/Functional/DataScenarios/IrreForeignField/AbstractActionTestCase.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,13 @@ public function deleteParentContent(): void
9393
$this->actionService->deleteRecord(self::TABLE_Content, self::VALUE_ContentIdLast);
9494
}
9595

96+
public function deleteParentContentWithoutCascadingDelete(): void
97+
{
98+
$GLOBALS['TCA']['tx_testirreforeignfield_hotel']['columns']['offers']['config']['behaviour']['enableCascadingDelete'] = false;
99+
$this->get(TcaSchemaFactory::class)->rebuild($GLOBALS['TCA']);
100+
$this->actionService->deleteRecord(self::TABLE_Content, self::VALUE_ContentIdLast);
101+
}
102+
96103
public function copyParentContent(): void
97104
{
98105
$newTableIds = $this->actionService->copyRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_PageId);

typo3/sysext/core/Tests/Functional/DataScenarios/IrreForeignField/Modify/ActionTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,13 @@ public function deleteParentContent(): void
7777
->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #2'));
7878
}
7979

80+
#[Test]
81+
public function deleteParentContentWithoutCascadingDelete(): void
82+
{
83+
parent::deleteParentContentWithoutCascadingDelete();
84+
$this->assertCSVDataSet(__DIR__ . '/DataSet/deleteParentContentWithoutCascadingDelete.csv');
85+
}
86+
8087
#[Test]
8188
public function copyParentContent(): void
8289
{
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
"pages",,,,,,,,,,,,,,,,
2+
,"uid","pid","sorting","deleted","t3ver_wsid","t3ver_state","t3ver_stage","t3ver_oid","title","tx_testirreforeignfield_hotels",,,,,
3+
,1,0,256,0,0,0,0,0,"FunctionalTest",0,,,,,
4+
,88,1,256,0,0,0,0,0,"DataHandlerTest",0,,,,,
5+
,89,88,256,0,0,0,0,0,"Relations",1,,,,,
6+
,90,88,512,0,0,0,0,0,"Target",0,,,,,
7+
"tt_content",,,,,,,,,,,,,,,,
8+
,"uid","pid","sorting","deleted","sys_language_uid","l18n_parent","t3ver_wsid","t3ver_state","t3ver_stage","t3ver_oid","header","tx_testirreforeignfield_hotels",,,
9+
,297,89,256,0,0,0,0,0,0,0,"Regular Element #1",2,,,
10+
,298,89,512,1,0,0,0,0,0,0,"Regular Element #2",1,,,
11+
"tx_testirreforeignfield_hotel",,,,,,,,,,,,,,,,
12+
,"uid","pid","sorting","deleted","sys_language_uid","l18n_parent","t3_origuid","t3ver_wsid","t3ver_state","t3ver_stage","t3ver_oid","title","parentid","parenttable","parentidentifier","offers"
13+
,2,89,1,0,0,0,0,0,0,0,0,"Hotel #0",89,"pages",,0
14+
,3,89,1,0,0,0,0,0,0,0,0,"Hotel #1",297,"tt_content","1nff.hotels",2
15+
,4,89,2,0,0,0,0,0,0,0,0,"Hotel #2",297,"tt_content","1nff.hotels",1
16+
,5,89,1,1,0,0,0,0,0,0,0,"Hotel #1",298,"tt_content","1nff.hotels",1
17+
"tx_testirreforeignfield_offer",,,,,,,,,,,,,,,,
18+
,"uid","pid","sorting","deleted","sys_language_uid","l18n_parent","t3_origuid","t3ver_wsid","t3ver_state","t3ver_stage","t3ver_oid","title","parentid","parenttable","parentidentifier","prices"
19+
,5,89,1,0,0,0,0,0,0,0,0,"Offer #1.1",3,"tx_testirreforeignfield_hotel",,3
20+
,6,89,2,0,0,0,0,0,0,0,0,"Offer #1.2",3,"tx_testirreforeignfield_hotel",,2
21+
,7,89,1,0,0,0,0,0,0,0,0,"Offer #2.1",4,"tx_testirreforeignfield_hotel",,1
22+
,8,89,1,0,0,0,0,0,0,0,0,"Offer #1.1",5,"tx_testirreforeignfield_hotel",,1
23+
"tx_testirreforeignfield_price",,,,,,,,,,,,,,,,
24+
,"uid","pid","sorting","deleted","sys_language_uid","l18n_parent","t3_origuid","t3ver_wsid","t3ver_state","t3ver_stage","t3ver_oid","title","parentid","parenttable","parentidentifier",
25+
,7,89,1,0,0,0,0,0,0,0,0,"Price #1.1.1",5,"tx_testirreforeignfield_offer",,
26+
,8,89,2,0,0,0,0,0,0,0,0,"Price #1.1.2",5,"tx_testirreforeignfield_offer",,
27+
,9,89,3,0,0,0,0,0,0,0,0,"Price #1.1.3",5,"tx_testirreforeignfield_offer",,
28+
,10,89,1,0,0,0,0,0,0,0,0,"Price #1.2.1",6,"tx_testirreforeignfield_offer",,
29+
,11,89,2,0,0,0,0,0,0,0,0,"Price #1.2.2",6,"tx_testirreforeignfield_offer",,
30+
,12,89,1,0,0,0,0,0,0,0,0,"Price #2.1.1",7,"tx_testirreforeignfield_offer",,
31+
,13,89,1,0,0,0,0,0,0,0,0,"Price #1.1.1",8,"tx_testirreforeignfield_offer",,
32+
"sys_refindex"
33+
,"hash","tablename","recuid","field","hidden","starttime","endtime","t3ver_state","flexpointer","softref_key","softref_id","sorting","workspace","ref_table","ref_uid","ref_field","ref_hidden","ref_starttime","ref_endtime","ref_t3ver_state","ref_sorting","ref_string"
34+
,"f6c496743ae6ceac1e6ef37f59ac6ce4","pages",89,"tx_testirreforeignfield_hotels",0,0,2147483647,0,,,,0,0,"tx_testirreforeignfield_hotel",2,,0,0,2147483647,0,0,
35+
,"9a75607fd165efe8f436d7feb1ddb99a","tt_content",297,"tx_testirreforeignfield_hotels",0,0,2147483647,0,,,,0,0,"tx_testirreforeignfield_hotel",3,,0,0,2147483647,0,0,
36+
,"4c64465dd909cfa96bd0c44d49a622e7","tt_content",297,"tx_testirreforeignfield_hotels",0,0,2147483647,0,,,,1,0,"tx_testirreforeignfield_hotel",4,,0,0,2147483647,0,0,
37+
,"6fef6909e8f62102ae677abfa03107cf","tx_testirreforeignfield_hotel",3,"offers",0,0,2147483647,0,,,,0,0,"tx_testirreforeignfield_offer",5,,0,0,2147483647,0,0,
38+
,"ffb9e85b1aa9c4a79f8ab1dacdd79272","tx_testirreforeignfield_hotel",3,"offers",0,0,2147483647,0,,,,1,0,"tx_testirreforeignfield_offer",6,,0,0,2147483647,0,0,
39+
,"f4435baee14a296e0f9f9e7584d12cdc","tx_testirreforeignfield_hotel",4,"offers",0,0,2147483647,0,,,,0,0,"tx_testirreforeignfield_offer",7,,0,0,2147483647,0,0,
40+
,"807dff67144b63742051ca04c63e1e21","tx_testirreforeignfield_offer",5,"prices",0,0,2147483647,0,,,,0,0,"tx_testirreforeignfield_price",7,,0,0,2147483647,0,0,
41+
,"047b010df406545869b08e32fbff771e","tx_testirreforeignfield_offer",5,"prices",0,0,2147483647,0,,,,1,0,"tx_testirreforeignfield_price",8,,0,0,2147483647,0,0,
42+
,"cd023990f84c912c5fa983b9650b5701","tx_testirreforeignfield_offer",5,"prices",0,0,2147483647,0,,,,2,0,"tx_testirreforeignfield_price",9,,0,0,2147483647,0,0,
43+
,"02f4fe88195ff6c918964a30ecb5292c","tx_testirreforeignfield_offer",6,"prices",0,0,2147483647,0,,,,0,0,"tx_testirreforeignfield_price",10,,0,0,2147483647,0,0,
44+
,"9fcc5a8d98b0e590ed343caddb550d4e","tx_testirreforeignfield_offer",6,"prices",0,0,2147483647,0,,,,1,0,"tx_testirreforeignfield_price",11,,0,0,2147483647,0,0,
45+
,"8d807bac697427ba7fb0b2f0e1f12493","tx_testirreforeignfield_offer",7,"prices",0,0,2147483647,0,,,,0,0,"tx_testirreforeignfield_price",12,,0,0,2147483647,0,0,
46+
,"15dfcd32a2cd2a07f68a7a87902bee5a","tx_testirreforeignfield_offer",8,"prices",0,0,2147483647,0,,,,0,0,"tx_testirreforeignfield_price",13,,0,0,2147483647,0,0,

typo3/sysext/core/Tests/Functional/DataScenarios/IrreForeignField/WorkspacesModify/ActionTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,16 @@ public function deleteParentContent(): void
8787
->setTable(self::TABLE_Content)->setField('header')->setValues('Regular Element #2'));
8888
}
8989

90+
#[Test]
91+
public function deleteParentContentWithoutCascadingDelete(): void
92+
{
93+
// @todo: TCA 'enableCascadingDelete' = false is *not* honored in workspaces. There
94+
// are follow-up issues with discard and publish, their tests should be added
95+
// when fixing this.
96+
parent::deleteParentContentWithoutCascadingDelete();
97+
$this->assertCSVDataSet(__DIR__ . '/DataSet/deleteParentContentWithoutCascadingDelete.csv');
98+
}
99+
90100
#[Test]
91101
public function copyParentContent(): void
92102
{
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
"pages",,,,,,,,,,,,,,,,,
2+
,"uid","pid","sorting","deleted","t3ver_wsid","t3ver_state","t3ver_stage","t3ver_oid","title","tx_testirreforeignfield_hotels",,,,,,,
3+
,1,0,256,0,0,0,0,0,"FunctionalTest",0,,,,,,,
4+
,88,1,256,0,0,0,0,0,"DataHandlerTest",0,,,,,,,
5+
,89,88,256,0,0,0,0,0,"Relations",1,,,,,,,
6+
,90,88,512,0,0,0,0,0,"Target",0,,,,,,,
7+
"sys_workspace",,,,,,,,,,,,,,,,,
8+
,"uid","pid","deleted","title","adminusers","members","db_mountpoints","file_mountpoints","freeze","live_edit","publish_access","custom_stages","stagechg_notification","edit_notification_defaults","edit_allow_notificaton_settings","publish_notification_defaults","publish_allow_notificaton_settings"
9+
,1,0,0,"Workspace #1",,,,,0,0,0,0,0,0,0,0,0
10+
,2,0,0,"Workspace #2",,,,,0,0,0,0,0,0,0,0,0
11+
"sys_workspace_stage",,,,,,,,,,,,,,,,,
12+
,"uid","pid","tstamp","deleted","sorting","title","responsible_persons","default_mailcomment","parentid","notification_defaults","allow_notificaton_settings",,,,,
13+
,1,0,1290048921,0,1,"Stage 1","be_users_3",,1,0,0,,,,,
14+
"tt_content",,,,,,,,,,,,,,,,,
15+
,"uid","pid","sorting","deleted","sys_language_uid","l18n_parent","t3ver_wsid","t3ver_state","t3ver_stage","t3ver_oid","header","tx_testirreforeignfield_hotels",,,,,
16+
,297,89,256,0,0,0,0,0,0,0,"Regular Element #1",2,,,,,
17+
,298,89,512,0,0,0,0,0,0,0,"Regular Element #2",1,,,,,
18+
,299,89,512,0,0,0,1,2,0,298,"Regular Element #2",1,,,,,
19+
"tx_testirreforeignfield_hotel",,,,,,,,,,,,,,,,,
20+
,"uid","pid","sorting","deleted","sys_language_uid","l18n_parent","t3ver_wsid","t3ver_state","t3ver_stage","t3ver_oid","title","parentid","parenttable","parentidentifier","offers",,
21+
,2,89,1,0,0,0,0,0,0,0,"Hotel #0",89,"pages",,0,,
22+
,3,89,1,0,0,0,0,0,0,0,"Hotel #1",297,"tt_content","1nff.hotels",2,,
23+
,4,89,2,0,0,0,0,0,0,0,"Hotel #2",297,"tt_content","1nff.hotels",1,,
24+
,5,89,1,0,0,0,0,0,0,0,"Hotel #1",298,"tt_content","1nff.hotels",1,,
25+
,6,89,1,0,0,0,1,2,0,5,"Hotel #1",298,"tt_content","1nff.hotels",1,,
26+
"tx_testirreforeignfield_offer",,,,,,,,,,,,,,,,,
27+
,"uid","pid","sorting","deleted","sys_language_uid","l18n_parent","t3ver_wsid","t3ver_state","t3ver_stage","t3ver_oid","title","parentid","parenttable","parentidentifier","prices",,
28+
,5,89,1,0,0,0,0,0,0,0,"Offer #1.1",3,"tx_testirreforeignfield_hotel",,3,,
29+
,6,89,2,0,0,0,0,0,0,0,"Offer #1.2",3,"tx_testirreforeignfield_hotel",,2,,
30+
,7,89,1,0,0,0,0,0,0,0,"Offer #2.1",4,"tx_testirreforeignfield_hotel",,1,,
31+
,8,89,1,0,0,0,0,0,0,0,"Offer #1.1",5,"tx_testirreforeignfield_hotel",,1,,
32+
# @todo: This should not be created with enabledCascadingDelete=false
33+
,9,89,1,0,0,0,1,2,0,8,"Offer #1.1",5,"tx_testirreforeignfield_hotel",,1,,
34+
"tx_testirreforeignfield_price",,,,,,,,,,,,,,,,,
35+
,"uid","pid","sorting","deleted","sys_language_uid","l18n_parent","t3ver_wsid","t3ver_state","t3ver_stage","t3ver_oid","title","parentid","parenttable","parentidentifier",,,
36+
,7,89,1,0,0,0,0,0,0,0,"Price #1.1.1",5,"tx_testirreforeignfield_offer",,,,
37+
,8,89,2,0,0,0,0,0,0,0,"Price #1.1.2",5,"tx_testirreforeignfield_offer",,,,
38+
,9,89,3,0,0,0,0,0,0,0,"Price #1.1.3",5,"tx_testirreforeignfield_offer",,,,
39+
,10,89,1,0,0,0,0,0,0,0,"Price #1.2.1",6,"tx_testirreforeignfield_offer",,,,
40+
,11,89,2,0,0,0,0,0,0,0,"Price #1.2.2",6,"tx_testirreforeignfield_offer",,,,
41+
,12,89,1,0,0,0,0,0,0,0,"Price #2.1.1",7,"tx_testirreforeignfield_offer",,,,
42+
,13,89,1,0,0,0,0,0,0,0,"Price #1.1.1",8,"tx_testirreforeignfield_offer",,,,
43+
,14,89,1,0,0,0,1,2,0,13,"Price #1.1.1",8,"tx_testirreforeignfield_offer",,,,
44+
"sys_refindex"
45+
,"hash","tablename","recuid","field","hidden","starttime","endtime","t3ver_state","flexpointer","softref_key","softref_id","sorting","workspace","ref_table","ref_uid","ref_field","ref_hidden","ref_starttime","ref_endtime","ref_t3ver_state","ref_sorting","ref_string"
46+
,"f6c496743ae6ceac1e6ef37f59ac6ce4","pages",89,"tx_testirreforeignfield_hotels",0,0,2147483647,0,,,,0,0,"tx_testirreforeignfield_hotel",2,,0,0,2147483647,0,0,
47+
,"6f85cfacfff942817392efe26ff1ade0","sys_workspace",1,"custom_stages",0,0,2147483647,0,,,,0,0,"sys_workspace_stage",1,,0,0,2147483647,0,0,
48+
,"96a6b7ec63daee0e0ce5d4908b6eda6f","sys_workspace_stage",1,"responsible_persons",0,0,2147483647,0,,,,0,0,"be_users",3,,0,0,2147483647,0,0,
49+
,"9a75607fd165efe8f436d7feb1ddb99a","tt_content",297,"tx_testirreforeignfield_hotels",0,0,2147483647,0,,,,0,0,"tx_testirreforeignfield_hotel",3,,0,0,2147483647,0,0,
50+
,"4c64465dd909cfa96bd0c44d49a622e7","tt_content",297,"tx_testirreforeignfield_hotels",0,0,2147483647,0,,,,1,0,"tx_testirreforeignfield_hotel",4,,0,0,2147483647,0,0,
51+
,"7d6fbd99ec79acf961d9cc5d8fd4045a","tt_content",298,"tx_testirreforeignfield_hotels",0,0,2147483647,0,,,,0,0,"tx_testirreforeignfield_hotel",5,,0,0,2147483647,0,0,
52+
,"6fef6909e8f62102ae677abfa03107cf","tx_testirreforeignfield_hotel",3,"offers",0,0,2147483647,0,,,,0,0,"tx_testirreforeignfield_offer",5,,0,0,2147483647,0,0,
53+
,"ffb9e85b1aa9c4a79f8ab1dacdd79272","tx_testirreforeignfield_hotel",3,"offers",0,0,2147483647,0,,,,1,0,"tx_testirreforeignfield_offer",6,,0,0,2147483647,0,0,
54+
,"f4435baee14a296e0f9f9e7584d12cdc","tx_testirreforeignfield_hotel",4,"offers",0,0,2147483647,0,,,,0,0,"tx_testirreforeignfield_offer",7,,0,0,2147483647,0,0,
55+
,"a35e1e3e1ec7fbb97925a8bcbe2e4da5","tx_testirreforeignfield_hotel",5,"offers",0,0,2147483647,0,,,,0,0,"tx_testirreforeignfield_offer",8,,0,0,2147483647,0,0,
56+
,"807dff67144b63742051ca04c63e1e21","tx_testirreforeignfield_offer",5,"prices",0,0,2147483647,0,,,,0,0,"tx_testirreforeignfield_price",7,,0,0,2147483647,0,0,
57+
,"047b010df406545869b08e32fbff771e","tx_testirreforeignfield_offer",5,"prices",0,0,2147483647,0,,,,1,0,"tx_testirreforeignfield_price",8,,0,0,2147483647,0,0,
58+
,"cd023990f84c912c5fa983b9650b5701","tx_testirreforeignfield_offer",5,"prices",0,0,2147483647,0,,,,2,0,"tx_testirreforeignfield_price",9,,0,0,2147483647,0,0,
59+
,"02f4fe88195ff6c918964a30ecb5292c","tx_testirreforeignfield_offer",6,"prices",0,0,2147483647,0,,,,0,0,"tx_testirreforeignfield_price",10,,0,0,2147483647,0,0,
60+
,"9fcc5a8d98b0e590ed343caddb550d4e","tx_testirreforeignfield_offer",6,"prices",0,0,2147483647,0,,,,1,0,"tx_testirreforeignfield_price",11,,0,0,2147483647,0,0,
61+
,"8d807bac697427ba7fb0b2f0e1f12493","tx_testirreforeignfield_offer",7,"prices",0,0,2147483647,0,,,,0,0,"tx_testirreforeignfield_price",12,,0,0,2147483647,0,0,
62+
,"15dfcd32a2cd2a07f68a7a87902bee5a","tx_testirreforeignfield_offer",8,"prices",0,0,2147483647,0,,,,0,0,"tx_testirreforeignfield_price",13,,0,0,2147483647,0,0,
63+
,"bf91e191783cb6c002909c94dbbb87a5","tx_testirreforeignfield_offer",9,"prices",0,0,2147483647,2,,,,0,1,"tx_testirreforeignfield_price",14,,0,0,2147483647,2,0,
64+
,"703c84037e02715eabd3b553b76493a7","tx_testirreforeignfield_hotel",6,"offers",0,0,2147483647,2,,,,0,1,"tx_testirreforeignfield_offer",9,,0,0,2147483647,2,0,
65+
,"7bdd4ed17c7f936a9bceebb611b32bdc","tt_content",299,"tx_testirreforeignfield_hotels",0,0,2147483647,2,,,,0,1,"tx_testirreforeignfield_hotel",6,,0,0,2147483647,2,0,

typo3/sysext/core/Tests/Unit/DataHandling/DataHandlerTest.php

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
use TYPO3\CMS\Core\Crypto\PasswordHashing\PasswordHashFactory;
3232
use TYPO3\CMS\Core\Crypto\Random;
3333
use TYPO3\CMS\Core\Database\ConnectionPool;
34-
use TYPO3\CMS\Core\Database\RelationHandler;
3534
use TYPO3\CMS\Core\DataHandling\DataHandler;
3635
use TYPO3\CMS\Core\DataHandling\DataHandlerCheckModifyAccessListHookInterface;
3736
use TYPO3\CMS\Core\DataHandling\PageDoktypeRegistry;
@@ -1097,30 +1096,6 @@ public function deletePagesOnRootLevelIsDenied(): void
10971096
$dataHandlerMock->deleteEl('pages', 0);
10981097
}
10991098

1100-
#[Test]
1101-
public function deleteRecord_procBasedOnFieldTypeRespectsEnableCascadingDelete(): void
1102-
{
1103-
$table = StringUtility::getUniqueId('foo_');
1104-
$conf = [
1105-
'type' => 'inline',
1106-
'foreign_table' => StringUtility::getUniqueId('foreign_foo_'),
1107-
'behaviour' => [
1108-
'enableCascadingDelete' => 0,
1109-
],
1110-
];
1111-
1112-
$mockRelationHandler = $this->createMock(RelationHandler::class);
1113-
$mockRelationHandler->itemArray = [
1114-
'1' => ['table' => StringUtility::getUniqueId('bar_'), 'id' => 67],
1115-
];
1116-
1117-
$mockDataHandler = $this->getAccessibleMock(DataHandler::class, ['getRelationFieldType', 'deleteAction', 'createRelationHandlerInstance'], [], '', false);
1118-
$mockDataHandler->expects(self::once())->method('getRelationFieldType')->willReturn('field');
1119-
$mockDataHandler->expects(self::once())->method('createRelationHandlerInstance')->willReturn($mockRelationHandler);
1120-
$mockDataHandler->expects(self::never())->method('deleteAction');
1121-
$mockDataHandler->_call('deleteRecord_procBasedOnFieldType', $table, 42, 'bar', $conf);
1122-
}
1123-
11241099
public static function checkValue_checkReturnsExpectedValuesDataProvider(): array
11251100
{
11261101
return [

0 commit comments

Comments
 (0)