From 7cce622b3d6e0695b87ad86c76875b29eaad99d7 Mon Sep 17 00:00:00 2001 From: Karsten Nowak Date: Tue, 30 Jul 2024 20:19:18 +0200 Subject: [PATCH] [TASK] Check that existing teas in other pids were not deleted Related #1120 --- .../Command/CreateTestDataCommandTest.php | 15 +++++++++++++++ .../Fixtures/Database/OtherExistingTeas.csv | 6 ++++++ .../Command/Fixtures/Database/OtherTeas.csv | 6 ------ .../Database/TeasAfterDeleteOtherExistingTeas.csv | 6 ++++++ 4 files changed, 27 insertions(+), 6 deletions(-) create mode 100644 Tests/Functional/Command/Fixtures/Database/OtherExistingTeas.csv delete mode 100644 Tests/Functional/Command/Fixtures/Database/OtherTeas.csv create mode 100644 Tests/Functional/Command/Fixtures/Database/TeasAfterDeleteOtherExistingTeas.csv diff --git a/Tests/Functional/Command/CreateTestDataCommandTest.php b/Tests/Functional/Command/CreateTestDataCommandTest.php index 400a543..0f28823 100644 --- a/Tests/Functional/Command/CreateTestDataCommandTest.php +++ b/Tests/Functional/Command/CreateTestDataCommandTest.php @@ -103,4 +103,19 @@ class CreateTestDataCommandTest extends FunctionalTestCase self::assertCSVDataSet(__DIR__ . '/Fixtures/Database/TeasAfterDelete.csv'); } + /** + * @test + */ + public function existingDataWillBeNotDeleted(): void + { + $this->importCSVDataSet(__DIR__ . '/Fixtures/Database/OtherExistingTeas.csv'); + $this->commandTester->execute( + [ + 'pageUid' => '1', + '--delete-data-before' => true, + ] + ); + self::assertCSVDataSet(__DIR__ . '/Fixtures/Database/TeasAfterDeleteOtherExistingTeas.csv'); + } + } diff --git a/Tests/Functional/Command/Fixtures/Database/OtherExistingTeas.csv b/Tests/Functional/Command/Fixtures/Database/OtherExistingTeas.csv new file mode 100644 index 0000000..f78bd2e --- /dev/null +++ b/Tests/Functional/Command/Fixtures/Database/OtherExistingTeas.csv @@ -0,0 +1,6 @@ +"tx_tea_domain_model_tea" +,"uid","pid","title","description","deleted" +,3,1,"Darjeeling","Exists and should be deleted","0" +,4,1,"Earl Grey","Exists and should be deleted","0" +,1,2,"Darjeeling","Which already existed in the system",0 +,2,2,"Earl Grey","Which already existed in the system",0 diff --git a/Tests/Functional/Command/Fixtures/Database/OtherTeas.csv b/Tests/Functional/Command/Fixtures/Database/OtherTeas.csv deleted file mode 100644 index fab4071..0000000 --- a/Tests/Functional/Command/Fixtures/Database/OtherTeas.csv +++ /dev/null @@ -1,6 +0,0 @@ -"tx_tea_domain_model_tea" -,"uid","pid","title","description","deleted" -,3,1,"Darjeeling","I love that tea!","0" -,4,1,"Earl Grey","A nice tea!","0" -,1,2,"Black tea","I hate that.","0" -,2,2,"Green tea","Is ok.","0" diff --git a/Tests/Functional/Command/Fixtures/Database/TeasAfterDeleteOtherExistingTeas.csv b/Tests/Functional/Command/Fixtures/Database/TeasAfterDeleteOtherExistingTeas.csv new file mode 100644 index 0000000..a427bf0 --- /dev/null +++ b/Tests/Functional/Command/Fixtures/Database/TeasAfterDeleteOtherExistingTeas.csv @@ -0,0 +1,6 @@ +"tx_tea_domain_model_tea" +,"pid","title","description","deleted" +,1,"Darjeeling","I love that tea!",0 +,1,"Earl Grey","A nice tea!",0 +,2,"Darjeeling","Which already existed in the system",0 +,2,"Earl Grey","Which already existed in the system",0